Skip to content

perf: lock-free routing#118

Merged
leiysky merged 2 commits into
scopedb:mainfrom
leiysky:chore/route-table
Oct 15, 2025
Merged

perf: lock-free routing#118
leiysky merged 2 commits into
scopedb:mainfrom
leiysky:chore/route-table

Conversation

@leiysky

@leiysky leiysky commented Oct 15, 2025

Copy link
Copy Markdown
Collaborator

Membership and HashRing are read-heavy data structures. Use lock-free multi version to reduce lock usage and full clone.

@leiysky leiysky requested review from Copilot and tisonkun October 15, 2025 06:16

Copilot AI left a comment

Copy link
Copy Markdown

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 refactors the gossip system to use lock-free data structures for improved performance in read-heavy scenarios. It replaces RwLock synchronization with ArcSwap for the membership and hash ring data structures to reduce lock contention and eliminate unnecessary cloning.

  • Replace RwLock<Membership> and RwLock<Arc<HashRing<Uuid>>> with ArcSwap variants
  • Add utility methods to Membership for better integration with the new lock-free approach
  • Update all membership and ring access patterns to use atomic operations instead of read/write locks

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/gossip/src/member.rs Adds into_members() method and FromIterator implementation for Membership
crates/gossip/src/gossip.rs Replaces RwLock with ArcSwap for membership and ring, updates all access patterns
crates/gossip/Cargo.toml Adds arc-swap dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread crates/gossip/src/gossip.rs
Comment thread crates/gossip/src/gossip.rs
@leiysky leiysky merged commit bc9e93d into scopedb:main Oct 15, 2025
4 checks passed
@leiysky leiysky deleted the chore/route-table branch October 15, 2025 15:01

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would this technique applicible for client's route table state also?

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