Implement asyncstreams
Implements:
- Async streaming I/O when httpxUseStreams is true
- Exposes request ID
- Exposes parsed request content length
TODO In another PR:
- Limit request header sizes to 8kib
- Write documentation for streams mode
Tested with Prologue, it passes as well.
how's the performance change?
@bung87 Really bad. That's part of why I never finished it. You can checkout the branch and try it for yourself.
I've heard of the low performance when nim std provide stream api, because it uses dynamic dispatch functions.
I don't think mine uses dynamic dispatch, but there are problems with how httpx/httpbeast read sockets which makes the problem worse.
You can see my implementation here:
https://github.com/ringabout/httpx/blob/83f6a1a839ba0c322859f876938a8881100df4ec/src/httpx/asyncstream.nim
And its tests:
https://github.com/ringabout/httpx/blob/83f6a1a839ba0c322859f876938a8881100df4ec/tests/t_streams.nim
these functions associate with stream object are dynamic dispatch, no ?
result.readCbs = initDeque[AsyncStreamCb](1)
result.writeCbs = initDeque[AsyncStreamCb](1)
result.afterReadCb = afterReadCb
result.afterWriteCb = afterWriteCb
@bung87 AsyncStreamCb just a typedesc, not a method. It won't use dynamic dispatch vtables, but it does run a proc via its pointer. Not sure if that counts.
Any progress on this one?
@atlas-pouriya I've abandoned it, the architecture is just too different to support it without breaking everything or making a compiletime switch that requires a lot of conditional code which is hard to test.
I'll close it now.