Git Product home page Git Product logo

Comments (2)

silvanshade avatar silvanshade commented on July 22, 2024 1

The previous implementation used to a remaining_msg_bytes field to return Ok(None) immediately if the message payload wasn't entirely buffered into memory. By contrast, the lspower implementation attempts to blindly reparse the headers with httparse every time.

You are right about this. It's strange because I clearly remember doing some debugging and seeing opportunities to minimize the reparsing.

In fact, it looks like at one point I did still use that field but removed it in a refactoring: silvanshade/lspower@c642b2b

But that refactoring actually seems to have done the opposite of what I claimed. I must have been confused or maybe rebased things incorrectly and didn't notice somehow.

I think should be pretty easy to add in a remaining_msg_bytes field into the new codec so that it truly runs as fast as it claims, though.

Indeed it is. You can see how I did it here: silvanshade/lspower@c642b2b#diff-ca14eabd5ab83f72548cd7e44eaea3f56a5d2808e3275c6b2a97622ebe5d1dd0L156-L161

Also, I've identified another optimization that would also boost efficiency beyond both the original and lspower codec implementations: it would be nice if we could eagerly advance the src buffer past the HTTP headers once we're done parsing them, so that we don't need to re-run httparse each time the codec is still waiting for the payload to come through.

Yes, this was in fact the original intention behind what I was trying to do (that and the fast advance with twoway). In fact, it makes more sense to me now why I was storing header_len and content_len in the codec state (which I removed in the PR I sent). I couldn't figure out why I had stored them there, but it was precisely because of this (before I made the incorrect change in the linked commit).

I could either create a PR to go back to this behavior or if you want to just go ahead implement it yourself (or maybe already have) that would be great.

from tower-lsp.

ebkalderon avatar ebkalderon commented on July 22, 2024

Perhaps we could also add a criterion.rs bench test to the repo, so we can keep proper tabs on the actual performance of the codec rather than speculating.

from tower-lsp.

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.