Join bytes in protocols instead of concatenating #2734
Unanswered
mabdullahsoyturk
asked this question in
Ideas
Replies: 2 comments 1 reply
-
|
Maybe we can use I would like to have a benchmark as part of the test suite using https://codspeed.io/. I think a good start would be to use the TechEmpower benchmark. Would you like to help here? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
My local experiments show that joining actually performs slightly better than bytearray concat but we can dig in a bit more for various cases. I would be happy to help but I don't think there is a test for file upload speed in TechEmpower benchmark. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In h11 and httptools, uvicorn concatenates the coming bytes into a bytes attribute. This incurs unnecessary overhead, especially for big files. Here is a benchmark to simulate the behavior:
On my machine, joining instead of concatenating improves the performance ~17-20%.
So, I suggest to use joining instead of concatenating. If approved, I can prepare the PR.
Beta Was this translation helpful? Give feedback.
All reactions