feat(app): R4.3a the page reads the file chunk by chunk and streams it to the worker's sink
Measured at R4.3a (RUST.md §10.5): reading a file inside a WebKit worker costs about 180 MiB of content RSS whatever the method (arrayBuffer, stream, BYOB), 14 MiB on the page; a page-side BYOB read feeding the worker's FileBytes gives 106 MiB on a 50 MiB file against 272 in the worker and 76 for the TypeScript. Protocol v1 gains chunk / ack / end: one 1 MiB buffer travels (transferred) and comes back after each push, so the page holds one chunk and the worker's sink the only whole copy; no byte is parsed on the page. The worker refuses an oversize announced before any chunk and a size that changes while reading. Tests adapted (handler, client with a scripted ack, read failure on the page).
This commit is contained in:
1 parent
49591c53cd
commit
e659924ec0
12 files changed
+552
-272
No files matched your search
@@ -39,6 +39,8 @@ export interface FakeWorker extends WorkerLike {
|
||||
received: unknown[]
|
||||
/** Every message the worker posted, dropped or delivered. */
|
||||
posted: WorkerMessage[]
|
||||
/** The posted message types without the per-chunk `ack`s. */
|
||||
sequence(): string[]
|
||||
}
|
||||
|
||||
export function inProcessWorker(
|
||||
@@ -54,6 +56,9 @@ export function inProcessWorker(
|
||||
terminate() {
|
||||
worker.terminated = true
|
||||
},
|
||||
sequence() {
|
||||
return worker.posted.map((m) => m.type).filter((t) => t !== 'ack')
|
||||
},
|
||||
postMessage(message) {
|
||||
worker.received.push(message)
|
||||
void handle(message)
|
||||
|
||||
Reference in new issue
Block a user