Giter VIP home page Giter VIP logo

Comments (6)

nhooyr avatar nhooyr commented on July 23, 2024

Also see golang/go#18152 (comment)

I don't think the writer allocation for every write is a big deal.

from websocket.

nhooyr avatar nhooyr commented on July 23, 2024

The major issue I see with the writer is you have to close it so every data msg greater than the buffer size of 4096 bytes will be sent with three writes on the conn instead of two.

from websocket.

nhooyr avatar nhooyr commented on July 23, 2024

I think the move is to remove the allocations altogether and just use a value type on the Conn and put the read/write state there.

from websocket.

nhooyr avatar nhooyr commented on July 23, 2024

That definitely removes the need for the Read method but the Write method makes sense to avoid the extra fin frame being written but I doubt anyone will ever notice that with the overhead of everything else in the stack so I'm good with the API as is.

from websocket.

nhooyr avatar nhooyr commented on July 23, 2024

Definitely should benchmark this at some point with big payloads.

from websocket.

nhooyr avatar nhooyr commented on July 23, 2024

So I benched this and it turns out there is no latency difference but the extra syscall adds 5000ns which is 5ยตs which isn't really that much at all so I don't think its a big deal. Can revisit if someone complains about performance but this isn't really going to show up if you're writing messages larger than 4096 bytes and I can always increase the buffer size to something like 32kb which would be good enough for pretty much everyone. I don't want to add a special case API unless absolutely necessary.

from websocket.

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.