Skip to content

Instantly share code, notes, and snippets.

@komamitsu
Last active May 5, 2026 05:58
Show Gist options
  • Select an option

  • Save komamitsu/3edea7a83550402965eec8e68b73f60b to your computer and use it in GitHub Desktop.

Select an option

Save komamitsu/3edea7a83550402965eec8e68b73f60b to your computer and use it in GitHub Desktop.
wh-blog-gemini
### Blog Post Structure: "Scaling Wormhole4j: Lock-Free Concurrency and Verified Correctness"
#### 1. Introduction: The Evolution
* **The Mission:** Briefly recap the original *Wormhole* paper (EuroSys '19) goal: a fast $O(\log L)$ ordered index.
* **The Problem:** While the original was a performance breakthrough, it was strictly single-threaded. Real-world infrastructure requires concurrency.
* **The Announcement:** Introduce v0.3.0, the culmination of adding multi-threaded support while preserving the core performance advantages.
#### 2. The Architecture of Concurrency
* **The Structural Conflict:** Explain why concurrent ordered indexes are difficult—modifications like splits/merges ripple through both the `LeafList` and the `MetaTrieHT`, creating a bottleneck.
* **The Three-Layer Strategy:** Explain the concurrency model:
1. **Reads:** Lock-free, optimized for the hot path.
2. **Local Writes:** Fine-grained locking on leaf nodes to keep contention local.
3. **Structural Changes:** High-level orchestration for splits/merges.
#### 3. Core Implementation Techniques
* **Lock-Free Reads via QSBR:** Detail the dual-table (`T1`/`T2`) approach.
*
* Explain why explicit thread registration (`registerThread`/`unregisterThread`) was chosen over heavier reference counting to maintain performance.
* **Versioning for Consistency:** Describe the global version number system. Explain how readers use version checks to detect stale data and trigger light retries instead of blocking.
* **Fine-Grained Leaf Locking:** Showcase how leaf-level `StampedLock` usage keeps contention localized.
#### 4. Correctness through Verification
* **Beyond Manual Testing:** Acknowledge that concurrent code is notoriously difficult to debug using standard stress tests.
* **Leveraging Property-Based Testing:** Briefly mention the move to automated property-based testing (using Lincheck) to verify that `ConcurrentWormhole` always matches the behavior of a sequential `TreeMap`.
* **The Impact:** Note that this approach was essential in exposing and fixing subtle concurrency bugs that remained invisible during traditional testing.
#### 5. Performance Benchmarks
* **The Results:** Present the performance metrics from your `README.md`.
* **Scalability Analysis:** Discuss the performance trends as thread counts increase.
* **Trade-offs:** Be transparent about scenarios where the index excels (read-heavy/mixed workloads) versus areas where contention may naturally occur (e.g., heavy numeric key scans under intense write pressure).
#### 6. Lessons Learned & Looking Ahead
* **The Complexity Cost:** Acknowledge the "complexity tax"—the need for explicit thread management and spin-yield patterns—and why it was a necessary trade-off for performance.
* **Closing:** Conclude with the importance of having a robust verification strategy for any concurrent data structure.
* **Future Work:** Briefly tease the roadmap, such as planned persistence support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment