Conversation
🚀 KeyValueStore Performance BenchmarksOptimized with double hashing, memcmp equality, and derived hash2 Core Operations (100 ops)
Load Factor Performance (10,000 lookups)
Key Length Impact (100 ops)
Main Thread Guidelines
Target: 16.67ms per frame @ 60fps, 8.33ms @ 120fps Total tests: 25 passed | Generated 2025-11-16 20:19:20 |
8446555 to
26d3e61
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KeyValueStore Performance Optimizations & Improvements
Summary
Major performance overhaul of
KeyValueStorewith algorithm improvements and optimizations specifically tuned for memory-mapped storage and main thread usage.Performance Improvements
Core Operations
Load Factor Performance
Degradation reduced from 10x to 6x (25% → 99% load)
Optimizations Implemented
1. Double Hashing (vs Linear Probing)
2. Optimized Key Comparison
memcmp()instead of byte-by-byte iterationwithUnsafeBytescall instead of 64 calls per comparison3. Optimized Hashing
4. Memory-Mapped Aware Design
Bug Fixes
KeyStorage.init(truncating:)- Now correctly checksresult.fitscompact()- Prevents silent data loss withpreconditionDocumentation Updates
Key.initdocumentation (removed incorrect assertion reference)setValueerror handling differencesValidation
All Tests Pass
Benchmarks
All operations now well within main thread acceptable limits:
CI/CD Updates
Updated
.github/workflows/benchmarks.ymlto:Testing: