Skip to content
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

Cache performance is extremely disappointing #649

Open
abitofevrything opened this issue Apr 3, 2024 · 0 comments
Open

Cache performance is extremely disappointing #649

abitofevrything opened this issue Apr 3, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@abitofevrything
Copy link
Member

Describe the bug
I recently had the chance to run nyxx on a bot with a few thousand members, and noticed the main isolate was processing Gateway events much slower than the Shard isolates were receiving them. A quick profile of the library reveals that 100.00% of CPU time was spent in Cache.filterItems (less than 0.005% of time was spent elsewhere, so it was rounded up):
screenshot
screenshot

This isn't acceptable. We need to rework how caching is handled, as it was always a patched-together feature since the rewrite anyway.

To Reproduce
Run a bot which receives many events that update its cache. In my case, I was running client.gateway.listGuildMembers with no filters for a few guilds with other 5000 members in parallel.

Expected behavior
The cache should be much less demanding in terms of CPU usage.

Desktop (please complete the following information):

  • OS: Linux
  • Dart version: 3.4.0 (dev)
  • Nyxx version: 6.2.1

Additional context
Note that this will not cause any bots to go offline, as the shard runners are responsible for keeping the connection alive since 6.0.0. It might however cause the bot to become unresponsive, as the main isolate running any user code is bogged down by cache updates. This also causes the CliIntegration plugin to become useless as it takes a long time for it to catch up and close the client.

This also can't be fixed by setting a lower max cache size.

This issue would also become worse over time as the overall cache size increases.

@abitofevrything abitofevrything added the bug Something isn't working label Apr 3, 2024
@abitofevrything abitofevrything added this to the 6.3.0 milestone Apr 3, 2024
@abitofevrything abitofevrything modified the milestones: 6.3.0, 6.4.0 Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant