You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: RateLimiter::check allocates String on every request even for existing keys #252
let bucket = shard.entry(key.to_string()).or_insert_with(|| BucketState{tokens: limit_f64,last_update: now,});
Because std::collections::hash_map::Entry requires ownership of the key, key.to_string() is evaluated unconditionally on every single request, allocating a String on the heap even when the client's bucket already exists in the shard (the 99.9% common case).
Fix direction:
Look up using shard.get_mut(key) first without allocating. Only allocate key.to_string() when inserting a new bucket:
Activity
Merge pull request #259 from QueryaHub/issue-252-ratelimit-no-alloc
ZhuchkaTriplesix commentedon Oct 18, 2026
Resolved in PR #259