Coder Social home page Coder Social logo

Comments (5)

djc avatar djc commented on August 21, 2024

Thanks for the suggestion! The proposed API seems a bit tricky because this is all happening in the context of a larger connection. Presumably if some other stream needs to send a packet and there's some space left over in that packet, you wouldn't mind the stream packing its bits in with that packet?

Alternatively, could we get away with a flag that prevents the stream from triggering any packet sends, leaving it to the application to trigger sends immediately? This grants more control to the application at the cost of making its life a little harder (but might not be a big deal if your application has a clear idea of when it wants to send).

Another issue that I see is that "a packet size" worth of data isn't very deterministic, because it might depend on what else gets send in that packet how much space there is. So presumably you'd definitely like your data to piggyback on packets that are sent anyway, but you want to ensure some minimal outstanding buffer before a packet is triggered.

from quinn.

flub avatar flub commented on August 21, 2024

So this idea came from @Ralith on matrix, I tried to put it down in an issue but may have some pieces wrong. Please correct me if so.

It is indeed a good point that packets already send on the connection anyway are used to attach frames to. I don't think the idea of not fully sending the stream has to conflict with this. If you can attach a STREAM frame to the packet while still leaving unsent data in the stream then that can be done. But you wouldn't send a packet just because there is data in this stream, nor would you send the last bit of data of the stream because you might still need to set the FIN bit to that frame.

from quinn.

Ralith avatar Ralith commented on August 21, 2024

@djc raises some good points that weren't immediately obvious to me. In particular, not sending data on a packet that's outgoing anyway and has free space seems pessimal, but sending data while reserving at least one byte, even if there's room for it, to avoid finishing an application-layer message feels cheesy. Maybe we shouldn't try to solve that, since peers can avoid the problem robustly by reading to end anyway? Reducing unintended fragmentation with small application writes is probably independently useful.

from quinn.

Ralith avatar Ralith commented on August 21, 2024

Thought: if your application protocol is not intended to have any data following a certain message, you might want to detect cases where that isn't upheld (i.e. where the peer is badly behaved), which requires reading the stream until finished.

from quinn.

Ralith avatar Ralith commented on August 21, 2024

Another related but slightly different case: when opening a new connection and sending 0-RTT data, Quinn will typically send a padded 1200-byte UDP datagram bearing the Initial packet, followed by some number of datagrams bearing the 0-RTT data. This is inefficient; 0-RTT data could have been replaced the padding.

Deferring opening the connection will probably require a different API than deferring use of a single stream... but maybe stream granularity isn't a complete solution anyway? For example, you might want to buffer up small writes to multiple streams before sending a packet...

from quinn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.