GithubHelp home page GithubHelp logo

Perf measurements about chunked-bytes HOT 9 OPEN

mzabaluev avatar mzabaluev commented on September 25, 2024 1
Perf measurements

from chunked-bytes.

Comments (9)

tekjar avatar tekjar commented on September 25, 2024

Surprisingly throughput went down drastically. Maybe I'm doing something wrong?

tekjar/numbers@2c9fced#diff-f0bee5e53cdb498867700a698edbb6e5
https://github.com/tekjar/numbers/tree/master/minimqtt

I'll read up more. Please let me know if you find any red flags.

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

Surprisingly throughput went down drastically. Maybe I'm doing something wrong?

tekjar/numbers@2c9fced#diff-f0bee5e53cdb498867700a698edbb6e5

This uses ChunkedBytes as an additional buffer on top of BytesMut that Framed uses internally.
To get a performance gain, you would need to replace the Framed sink with something similar to the implementation in the example.

I'm thinking of providing a replacement for tokio_util::codec that would use ChunkedBytes as the buffer for the writing half, but I haven't gotten up to it yet.

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

Wait, no, you have hacked into the Framed to get at the output object directly.
I'd like to isolate this as a benchmarkable test case.

In general, if the messages are predominantly smaller than the pre-allocated buffer and the output usually consumes the entire accumulated buffer, there won't be any benefits in using ChunkedBytes against BytesMut or Vec.

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

I have commented on the commit (1 2) about the potential pitfalls.

from chunked-bytes.

tekjar avatar tekjar commented on September 25, 2024

I've performed more experiments now and I think the problem isn't with my code. Went through the source code here but I couldn't find anything obvious. Will recheck this when I get time again. But I can support you with more experiments if you like :)

update: I think this advance is wrong

https://github.com/tekjar/numbers/blob/master/minimqtt/vectored/src/bin/tokio.rs#L74

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

@tekjar Thank you! Can you submit a minimized benchmark added to benches/ in a PR? I'd like to profile it to see where the performance penalty is coming from.

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

update: I think this advance is wrong

https://github.com/tekjar/numbers/blob/master/minimqtt/vectored/src/bin/tokio.rs#L74

write_buf already calls it internally, indeed. Please check that the code still works as intended, that's more important than performance :)

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

Replacing put_bytes with put_slice might do the trick, if the Bytes slices tend to be small.

from chunked-bytes.

mzabaluev avatar mzabaluev commented on September 25, 2024

I have added a benchmark in bf1c712 that may illustrate the penalty observed here, and documented the tradeoff of put_bytes in 27c0846.

from chunked-bytes.

Related Issues (2)

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.