[streams] More concrete examples of "optimization" of pipeTo (#359)

Potential targets of optimization

- TextEncodingTransformByteStream
- IdentityTransformByteStream
- BufferingTransformByteStream
- ByteCountingIdentityTransformByteStream
    - The wrapper is not a pure identify transform but with observation functionality.
    - In https://github.com/yutakahirano/fetch-with-streams/issues/37#issuecomment-105512434, 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

1. destMemory = sink.getMemoryToWrite()
1. source.generate(destMemory)
1. sink.notifyWritten()

### Source exposes a memory region where data for consuming is stored

1. sourceMemory = source.getMemoryToRead()
1. sink.consume(sourceMemory)
1. source.notifyConsumed()

### Both takes memory

1. tempMemory = allocate()
1. source.generate(tempMemory)
1. sink.consume(tempMemory)

### sendfile(2) style

1. transfer(lowerLayerSourceDescriptor, lowerLayerSinkDescriptor)

## Skipping an "identity" transform byte streams completely

```
a.pipeTo(id, options0);
id.pipeTo(b. options1);
```

Issues:

- Thread-safety: `a.pipeTo(id)` and `id.pipeTo(b)` may happen in different threads.
- How to observe bytes for ByteCountingIdentityTransformByteStream?


---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/359

Received on Friday, 29 May 2015 12:04:41 UTC