Skip to content

perf: handle_rsgi acquires RwLock<AppState> read lock redundantly #256

Closed

Description

@ZhuchkaTriplesix

Where: src/lib.rs:859-865 (handle_rsgi) and src/dispatch.rs:360.

Currently:
On every single request in handle_rsgi:

let (in_flight, max_c) = {
    let st = this.state.read();
    (Arc::clone(&st.in_flight), st.max_concurrency.load(...))
};

And immediately afterwards, inside try_rsgi_sync_short_circuit:

let snapshot = state.read().hot_snapshot();

in_flight and max_concurrency are Arc<AtomicUsize> whose pointer never changes after App creation. Acquiring state.read() twice per request causes unnecessary reader lock contention and cache-line bouncing under multi-threaded concurrency.

Fix direction:
Store in_flight and max_concurrency directly on App (or acquire the read lock once and pass the snapshot into try_rsgi_sync_short_circuit).

Activity

  1. added
    enhancement
    on Oct 18, 2026
  2. added a commit that references this issue on Oct 18, 2026
  3. ZhuchkaTriplesix commented on Oct 18, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Resolved by #263

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions