GithubHelp home page GithubHelp logo

Comments (4)

Lunarmagpie avatar Lunarmagpie commented on July 3, 2024 1

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

from hikari.

davfsa avatar davfsa commented on July 3, 2024 1

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 ujson here and did see orjson performing considerably better, but when it comes to a Discord workload, ujson shows better performance. I havent really looked into it (a bit why I opened this issue instead of a PR).

You can test it out yourself by replacing this specific line with send_bytes

await self._ws.send_str(pl)

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)

from hikari.

parafoxia avatar parafoxia commented on July 3, 2024

So I've experimented on Carberretta, and the differences are pretty minimal. I tried 3 times with each, and these were the average results:

  • Normal: 2.22s
  • ujson: 2.17s
  • orjson: 2.25s

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.

from hikari.

davfsa avatar davfsa commented on July 3, 2024

Since orjson was brought up, I experimented a bit with it and came up this branch.

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 json.loads and json.dumps singnature compliant functions.

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:

pip install git+https://github.com/davfsa/hikari@task/orjson#egg=hikari[speedups]

from hikari.

Related Issues (20)

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.