More concrete examples of "optimization" of pipeTo
Opened this issue · 3 comments
tyoshino commented
Potential targets of optimization
- TextEncodingTransformByteStream
- IdentityTransformByteStream
- BufferingTransformByteStream
- ByteCountingIdentityTransformByteStream
- The wrapper is not a pure identify transform but with observation functionality.
- In yutakahirano/fetch-with-streams#37 (comment), use of a wrapper is proposed for counting the number of bytes consumed from a Request/Response.
Skipping JS processing between a ReadableByteStream and a WritableByteStream
Skip JS code invocation (write(), read(), etc.) and does the following internally.
Sink exposes a memory region for write
- destMemory = sink.getMemoryToWrite()
- source.generate(destMemory)
- sink.notifyWritten()
Source exposes a memory region where data for consuming is stored
- sourceMemory = source.getMemoryToRead()
- sink.consume(sourceMemory)
- source.notifyConsumed()
Both takes memory
- tempMemory = allocate()
- source.generate(tempMemory)
- sink.consume(tempMemory)
sendfile(2) style
- transfer(lowerLayerSourceDescriptor, lowerLayerSinkDescriptor)
Skipping an "identity" transform byte streams completely
a.pipeTo(id, options0);
id.pipeTo(b. options1);
Copy data from a to b directly.
Issues:
- Thread-safety:
a.pipeTo(id)
andid.pipeTo(b)
may happen in different threads. - How to observe bytes for ByteCountingIdentityTransformByteStream?
tyoshino commented
We've decided to introduce isDisturbed, not byte counting system. So, we should reinvestigate how we set isDisturbed.