Skip to content

perf: reduce lock contention on route match (RWLock or route snapshot) #4

Description

@ZhuchkaTriplesix

Context

  • state.lock() is taken in multiple places per request. AppState bundles routes plus five Mutex<Router<usize>> and an openapi mutex.

Direction A

  • After freeze(), build an Arc<CompiledRoutes> (clones of routers or a single matchit structure per method) behind ArcSwap or OnceLock and read with no write path.

Direction B

  • parking_lot::RwLock for openapi vs routes—measure with Criterion microbenches or wrk on a hello handler.

Acceptance criteria

  • No functional regression; benchmark numbers in the PR description or benches/.

Research

  • matchit Router and Sync—today wrapped in Mutex. Consider matchit 0.8 migration if applicable.

Activity

  1. added this to the v0.2.0 milestone on Apr 26, 2026
  2. added a commit that references this issue on Apr 26, 2026
  3. added a commit that references this issue on Apr 26, 2026
  4. ZhuchkaTriplesix commented on Apr 26, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Reopened after backlog review (2026-04-26): implementation is partial or the topic remains active (see .github/ISSUE_BACKLOG/bodies/04.md and PRIORITIES.md).

  5. ZhuchkaTriplesix commented on Apr 26, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Note: body file is .github/ISSUE_BACKLOG/bodies/04.md.

  6. linked a pull request that will close this issueIssue 4 lock free route snapshot #55on Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions