-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Pottential speedup: ujson or orjson #1453
Comments
Have you looked into orjson? orjson is a larger library compared to ujson but its marginally faster in decoding benchmarks I think are more applicable to this project and its encoding speed is over 2x faster than ujson in all the benchmarks. https://github.com/ultrajson/ultrajson#benchmarks |
I did in fact look at it, but it seems to perform slower than ujson in our case. I re-ran the benchmarks provided by You can test it out yourself by replacing this specific line with Line 201 in deb3ed1
If anyone can run performance tests on their bots, please feel free to share, they are greatly welcome! PS: While looking into this, I stumbled on this issue from Sanic regarding the same results I encountered: sanic-org/sanic#1479 (comment) |
So I've experimented on Carberretta, and the differences are pretty minimal. I tried 3 times with each, and these were the average results:
I reckon some more data could be helpful, but there doesn't seem to be any major differences. The differences are smaller on a bot with more parts at the very least. |
Since I am still not fully happy with the outcome and have some plans to improve it even more, bringing in support to be able to pass Regardless, any testing on that branch (specially in large bots, if possible) would be welcome and appreciated! To install from the branch using pip, you can use:
|
A potential speedup we could add to the mix is ujson, which after some quick testing, it seems to be a drop in replacement to the standard libraries implementation, but performs a lot better, which is already noticeable on startup, so could be even more significant for large bots, so might be worth looking into:
stdlib:
ujson:
Typehints are provided through typeshed, so shouldnt have an issue with typecheckers
If you want to provide feedback on this issue and test it yourself, you can easily do it by adding the following lines to your bot script (after installing ujson):
The text was updated successfully, but these errors were encountered: