Rust-test
Prompt
Implement a production-grade, fully lock-free concurrent SkipList map (`ConcurrentSkipListMap<K, V>`) in pure Rust from scratch (`#![no_std]` compatible, alloc allowed for nodes). Target & Architecture Constraints: 1. Dynamic Memory Reclamation (Lock-Free): - You MUST implement a custom, lock-free Hazard Pointer scheme from scratch to safely reclaim node memory without blocking or leaking. - Strictly NO garbage collection, NO reference counting (`Arc` is forbidden for nodes), and NO epoch-based libraries (e.g. crossbeam-epoch forbidden). 2. Concurrency & Linearizability: - Implement concurrent `insert`, `remove`, and `get` operations using Harris-style logical deletion (marking next pointers using atomic tag bits). - CAS operations must correctly use `Acquire`, `Release`, and `AcqRel` memory orderings. Document exact ordering rationale on every atomic step. 3. Cache & CPU Optimization: - Nodes must be cache-line aligned (`#[repr(align(64))]`) to eliminate false sharing between adjacent towers/pointers. - Pointers must use tagged pointer packing inside atomic 64-bit words without undefined behavior. 4. Correctness & Drop Safety: - Handle custom `Drop` properly: dropping the map must safely retire and free all active and pending hazard nodes without memory leaks. 5. Verification & Test Harness: - Provide a complete, self-contained `main` or `#[test]` harness: - 16 threads (8 writers doing mixed insert/delete, 8 readers doing continuous lookups) running 500,000 operations concurrently. - Zero data races, zero dangling pointers, and 100% compliant with `cargo miri` (no undefined behavior under Miri execution). Return ONLY the complete, compilable, self-contained Rust source code with tests included.
Response not available
Response not available