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

perf(gateway): optimize CommandRatelimiter size #2395

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vilgotf
Copy link
Member

@vilgotf vilgotf commented Dec 9, 2024

  • stores relative instead of absolute timestamps, going from 12 bytes to 2 bytes per item
  • implicitly store the first relative timestamp in delay (if delay > now, one permit + pending.len() is acquired, else zero permits are acquired)
  • always store waker (call Sleep::poll) in poll_pending
  • fix theoretical issue from slice::partition_point returning an arbitrary element in the set of elements matching the predicate (we depend upon the first being returned)

TODO:

  • Update doc comments
  • Explain algorithm more in code comments, the logic is complex
  • (maybe) add more tests for new edge cases.

@github-actions github-actions bot added c-gateway Affects the gateway crate t-perf Improves performace labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-gateway Affects the gateway crate t-perf Improves performace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant