Skip to content

Consolidate workspace into single crate v0.2.0: parking_lot mutex, HashTable-based LockMap, unified Entry#30

Merged
SF-Zhou merged 3 commits intomainfrom
copilot/update-lockmap-dependencies
Mar 5, 2026
Merged

Consolidate workspace into single crate v0.2.0: parking_lot mutex, HashTable-based LockMap, unified Entry#30
SF-Zhou merged 3 commits intomainfrom
copilot/update-lockmap-dependencies

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

Merge lockmap, lockmap-core, and lockmap-lru into a single lockmap crate. Replace custom futex mutex with parking_lot::RawMutex. Rewrite LockMap to use HashTable with key+hash stored in State (matching LruLockMap design).

Structural changes

  • Workspace → single crate. lockmap-core and lockmap-lru deleted.
  • LockMap and LruLockMap exported from lockmap crate at v0.2.0

LockMap rewrite

  • ShardsMap<K, HashMap>Vec<ShardMap> with hashbrown::HashTable<AliasableBox<State<K, V>>>
  • Key and pre-computed hash stored in State; hashed once per operation, upper 32 bits select shard
  • EntryByVal / EntryByRef → unified Entry (key read from State via entry.key())
  • CAS-loop fast path in Entry::drop avoids shard lock when entry still has value or other refs

Mutex replacement

  • Custom futex (lockmap-core::Mutex) + atomic-waitparking_lot::RawMutex

Docs

  • README: unified API docs, changelog, migration table from 0.1.x → 0.2.0
// Before (0.1.x)
use lockmap::EntryByVal;        // or EntryByRef
use lockmap_lru::LruLockMap;

// After (0.2.0)
use lockmap::{Entry, LockMap, LruLockMap, LruEntry};

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…t RawMutex, HashTable-based LockMap, and unified Entry type

Co-authored-by: SF-Zhou <7477599+SF-Zhou@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor lockmap with parking_lot and API changes Consolidate workspace into single crate v0.2.0: parking_lot mutex, HashTable-based LockMap, unified Entry Mar 5, 2026
@SF-Zhou SF-Zhou marked this pull request as ready for review March 5, 2026 03:23
Copilot AI review requested due to automatic review settings March 5, 2026 03:23
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (dccccdb) to head (3b7314c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.rs and lru_lockmap.rs into src/ and deleting the three subcrate directories
  • Rewrite LockMap internals: replace ShardsMap<K, HashMap> with Vec<ShardMap> using HashTable, store key+hash in State, unify EntryByVal/EntryByRef into a single Entry type with a CAS-loop fast path in Drop
  • Replace custom futex-based Mutex (from lockmap-core) with parking_lot::RawMutex in both LockMap and LruLockMap

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 MutexRawMutex, 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.

@SF-Zhou SF-Zhou merged commit fd682be into main Mar 5, 2026
7 checks passed
@SF-Zhou SF-Zhou deleted the copilot/update-lockmap-dependencies branch March 5, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants