-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid copy when encoding request body #2349
Conversation
memory test diff (
|
Once again, the load test is not affected in any obvious way. |
Whoa that is awesome, a 61% decrease! It's almost close to the same payload size!
🔥 Will also affect other http methods.
I think this is because we don't include a bulk insert in the load tests. We only have a single object POST. postgrest/test/load/targets.http Lines 1 to 30 in d87b622
Lines 1 to 3 in d87b622
If we include a bulk insert, this change should show improved numbers. |
Being close the payload size almost seems a bit too good to be true... By my understanding we should at least be strictly reading the body to a lazy bytestring, and then copying it to a strict bytestring. But that should mean we need at least 2x the payload size, right? |
I pushed an updated version with a milder dependency footprint. Memory results seem similar. In this version:
|
Just for my own sanity, the jsonBytesLazy -> PTI.json Nope, it uses LibPQ.Binary. Nice! |
Just added a bulk insert loadtest on #2358, if you rebase then I think we should see a change in the numbers. |
fba5b1a
to
9f01aa4
Compare
Hm, even with the bulk insert addition seems we're not getting better results, not sure if this is true or if our loadtest setup is at fault. One idea for later could be hosting an instance on AWS(like we do for our aarch64 builds) and use NixOps to deploy the built static binary and then run a more realistic load test there. NixOps has been getting some improvements(like using s3 instead of sqlite for its state) and seems 2.0 is becoming more usable nowadays(ref). |
I don't think the loadtest is "at fault". The loadtest is just not designed for this. The loadtest is designed for a single request at a time, not for concurrent access. The loadtest is not constrained on memory either. And the loadtest data is still not analyzed separately by request. Improvements in memory usage are just not expected to improve the loadtest's results. A full-system load test, including many concurrent requests with bigger request bodies at the same time could show some improvements with this change, so running something like that automatically could indeed help a lot. |
9f01aa4
to
b96b2da
Compare
b96b2da
to
b78c6e2
Compare
b487e08
to
7b9a905
Compare
- switch from "unknown" parameter in text format to a "json" parameter in binary format (no dependency update required) - use a lazy bytestring "json" encoder (via updated hasql)
7b9a905
to
8316104
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited to try this one 🎉
(Updated after the merge of #2467)
This update hasql and switches to the new lazy json byte encoder, saving one copy of the request body.
After the merge of the libpq change in #2467, this is now essentially what #2333 was.