Conversation
…t RawMutex, HashTable-based LockMap, and unified Entry type Co-authored-by: SF-Zhou <7477599+SF-Zhou@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 4 2 -2
Lines 1818 1533 -285
==========================================
- Hits 1818 1533 -285 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Pull request overview
This PR consolidates the lockmap workspace of three crates (lockmap, lockmap-core, lockmap-lru) into a single lockmap v0.2.0 crate. It rewrites LockMap to use hashbrown::HashTable with key+hash stored in State (matching the LruLockMap design), unifies the two entry types into a single Entry, and replaces the custom futex mutex with parking_lot::RawMutex.
Changes:
- Restructure from a Cargo workspace to a single crate, moving
lockmap.rsandlru_lockmap.rsintosrc/and deleting the three subcrate directories - Rewrite
LockMapinternals: replaceShardsMap<K, HashMap>withVec<ShardMap>usingHashTable, store key+hash inState, unifyEntryByVal/EntryByRefinto a singleEntrytype with a CAS-loop fast path inDrop - Replace custom futex-based
Mutex(fromlockmap-core) withparking_lot::RawMutexin bothLockMapandLruLockMap
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Workspace → single crate package with updated deps (added parking_lot, removed atomic-wait) |
src/lib.rs |
New crate root: module declarations + re-exports of LockMap, Entry, LruLockMap, LruEntry |
src/lockmap.rs |
Major rewrite: HashTable-based storage, unified Entry, CAS-loop drop, RawMutex |
src/lru_lockmap.rs |
Replace Mutex → RawMutex, update doc imports, streamline comments |
README.md |
Updated for single-crate structure, added changelog and migration guide |
benches/bench_lockmap.rs |
Benchmark moved from subcrate to root |
lockmap/, lockmap-core/, lockmap-lru/ |
All deleted (Cargo.toml, lib.rs, README, source files) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge
lockmap,lockmap-core, andlockmap-lruinto a singlelockmapcrate. Replace custom futex mutex withparking_lot::RawMutex. RewriteLockMapto useHashTablewith key+hash stored inState(matchingLruLockMapdesign).Structural changes
lockmap-coreandlockmap-lrudeleted.LockMapandLruLockMapexported fromlockmapcrate at v0.2.0LockMap rewrite
ShardsMap<K, HashMap>→Vec<ShardMap>withhashbrown::HashTable<AliasableBox<State<K, V>>>State; hashed once per operation, upper 32 bits select shardEntryByVal/EntryByRef→ unifiedEntry(key read fromStateviaentry.key())Entry::dropavoids shard lock when entry still has value or other refsMutex replacement
lockmap-core::Mutex) +atomic-wait→parking_lot::RawMutexDocs
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.