⚡ Bolt: Optimize HashMap hasher for room lookups#741
Conversation
Replaced `BuildHasherDefault<DefaultHasher>` (SipHash) with `hashbrown`'s default hasher (AHash) for `ALL_JOINED_ROOMS` and `IGNORED_USERS`. This is achieved by initializing these static collections using `std::sync::LazyLock` instead of `const` initialization, which enables using the faster, non-const-constructible AHash. This optimization improves performance for frequent HashMap lookups, particularly in the `matrix_worker_task` loop. Also updated `get_ignored_users` return type and removed unused imports. Co-authored-by: kevinaboos <1139460+kevinaboos@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Replaced
SipHash(viastd::collections::hash_map::DefaultHasher) withAHash(default inhashbrown) for critical static HashMaps (ALL_JOINED_ROOMSandIGNORED_USERS).🎯 Why:
SipHashis cryptographically secure but slower.AHashis significantly faster and sufficient for internal HashMap usage, especially with frequent lookups in the application's hot path.📊 Impact: Faster room lookups and set membership checks.
ALL_JOINED_ROOMSis accessed on every matrix request.🔬 Measurement: Verified with
cargo checkandcargo test. The change is internal refactoring of static initialization usingLazyLock.PR created automatically by Jules for task 16200498334128599928 started by @kevinaboos