-
Notifications
You must be signed in to change notification settings - Fork 861
[Requests] Use orjson to speed up encoding/decoding of response body #7734
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
Conversation
|
/smoke-test |
|
/smoke-test |
|
/smoke-test --kubernetes -k kubernetes |
|
/smoke-test --kubernetes |
|
/quicktest-core |
aylei
left a comment
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.
LGTM, thanks! @kevinmingtarja
|
Not part of this PR, but looks like it would pay-off if we make |
|
/quicktest-core --kubernetes |
|
/quicktest-core --kubernetes |
In
set_request_succeeded, I noticed we're spending a good amount of time doingjson.dumpson the return value, which makes sense, given that it could reach the order of 10s of MBs (see #7708) for a simple/statusrequest when you have thousands of clusters.We could also see that

set_request_succeededtakes a non-trivial amount of time, in proportion to the actual work:This PR switched to using orjson for encoding/decoding these things, which is faster than the stdlib json.
While we're at it, apparently FastAPI also supports using orjson for encoding/decoding the response body as a whole, so let's do that too: https://fastapi.tiangolo.com/advanced/custom-response/#use-orjsonresponse
Benchmarks:
sky statuscalls, 20 concurrent client processesBefore:
After:
Some improvements on the tail latency.
Tested (run the relevant ones):
bash format.sh/smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)