Problem Statement
TimeWindow::hourly(timestamp) = (timestamp / 3600) * 3600.
While the existing fast_window does support power-of-two bitwise
optimization, the cache layer (hourly_cached) always stores one
entry per session — not per user, not per power-of-two window.
Expected Outcome
Per-user CachedWindow storage so cooldown_ms reads are O(1).
Acceptance Criteria
cleanup_rate_limits reduced to constant-time.
- Test: 1000 user rate-limit reads in < 1 µs each.
Files Affected
peerx-contracts/counter/src/rate_limit.rs.
Difficulty / Effort 🥑 / M
Labels performance
Problem Statement
TimeWindow::hourly(timestamp) = (timestamp / 3600) * 3600.While the existing
fast_windowdoes support power-of-two bitwiseoptimization, the cache layer (
hourly_cached) always stores oneentry per session — not per user, not per power-of-two window.
Expected Outcome
Per-user
CachedWindowstorage socooldown_msreads are O(1).Acceptance Criteria
cleanup_rate_limitsreduced to constant-time.Files Affected
peerx-contracts/counter/src/rate_limit.rs.Difficulty / Effort 🥑 / M
Labels
performance