Skip to content

perf: resolve global lock contention in template server#2

Open
idogrady wants to merge 2 commits into
codag-megalith:masterfrom
idogrady:perf/resolve-global-lock-contention
Open

perf: resolve global lock contention in template server#2
idogrady wants to merge 2 commits into
codag-megalith:masterfrom
idogrady:perf/resolve-global-lock-contention

Conversation

@idogrady

@idogrady idogrady commented Jun 7, 2026

Copy link
Copy Markdown

Replaces the global RwLock over the server sessions map with dashmap to provide highly concurrent bucket-level sharding. This removes the latency bottleneck where single ingest requests would block all other sessions. Fine-grained locking has also been added to SessionEntry.

Replaces the global RwLock over the server sessions map with dashmap
to provide highly concurrent bucket-level sharding. This removes the
latency bottleneck where single ingest requests would block all other
sessions. Fine-grained locking has also been added to SessionEntry.
Copilot AI review requested due to automatic review settings June 7, 2026 19:08

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the example server’s session storage to improve concurrency by replacing a globally locked HashMap with DashMap and moving locking to per-session fields.

Changes:

  • Replace Arc<RwLock<HashMap<...>>> session store with Arc<DashMap<...>>.
  • Introduce per-session synchronization (RwLock for template index, Mutex for last-touch timestamp).
  • Update routes and TTL sweeper to operate on the new session store.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
examples/server/tests/integration.rs Updates test state construction to use DashMap sessions.
examples/server/src/session.rs Changes AppState.sessions type and adds per-session locks.
examples/server/src/routes.rs Adjusts session lookup/insert and per-session locking around index/last_touch.
examples/server/src/main.rs Updates TTL sweeper to retain entries directly in DashMap.
examples/server/Cargo.toml Adds dashmap dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/server/src/main.rs
Comment thread examples/server/src/routes.rs
Comment thread examples/server/src/routes.rs Outdated
Comment thread examples/server/src/routes.rs
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.

2 participants