-
Notifications
You must be signed in to change notification settings - Fork 6
Document how to speed up your bot in a seperate optimizing page #247
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,82 @@ | ||||||
Optimizing | ||||||
========== | ||||||
Heres a few tips to make your bot run a tiny bit faster, from most impact to least. The accuracy of the ordering is more of a guess, and depends on your usage. | ||||||
|
||||||
.. Adjust the global rate limit | ||||||
.. ---------------------------- | ||||||
.. TODO: This needs to be properly supported in HTTPClient first imo. | ||||||
|
||||||
Relative time | ||||||
------------- | ||||||
Nextcore uses your computer's time to work with rate limits. | ||||||
|
||||||
By default this is on, however your clock might not be syncronized. | ||||||
|
||||||
|
||||||
|
||||||
.. tab:: Ubuntu | ||||||
|
||||||
You can check if your clock is synchronized by running the following command: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
timedatectl | ||||||
|
||||||
If it is synchronized, it will show "System clock synchronized: yes" and "NTP service: running" | ||||||
|
||||||
If the system clock is not synchronized but the ntp service is running you will have to wait a few minutes for it to sync. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
To enable the ntp service run the following command: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
sudo timedatectl set-ntp on | ||||||
|
||||||
This will automatically sync the system clock every once in a while. | ||||||
|
||||||
.. tab:: Arch | ||||||
|
||||||
You can check if your clock is synchronized by running the following command: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
timedatectl | ||||||
|
||||||
If it is synchronized, it will show "System clock synchronized: yes" and "NTP service: running" | ||||||
|
||||||
If the system clock is not synchronized but the ntp service is running you will have to wait a few minutes for it to sync. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
To enable the ntp service run the following command: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
sudo timedatectl set-ntp on | ||||||
|
||||||
This will automatically sync the system clock every once in a while. | ||||||
|
||||||
.. tab:: Windows | ||||||
|
||||||
This can be turned on by going to ``Settings -> Time & language -> Date & time`` and turning on ``Set time automatically``. | ||||||
|
||||||
Switch to ORJSON | ||||||
---------------- | ||||||
Nextcore handles quite a bit of JSON encoding and decoding. | ||||||
By default, nextcore uses the :mod:`json` module, which is quite a bit slower than :mod:`orjson` | ||||||
|
||||||
You can switch to ORJSON by installing the speed package and setting it as the global aiohttp default | ||||||
|
||||||
.. tab:: Pip | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
pip install "nextcore[speed]" | ||||||
|
||||||
.. tab:: Poetry | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
poetry add "nextcore[speed]" | ||||||
|
||||||
This will make :mod:`nextcore.gateway` use orjson, if it is installed. | ||||||
|
||||||
.. TODO: How do we enable it for nextcore.http too? |
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.