Skip to content

[TD-08] Arc<Mutex<>> in search/handle could be Arc<RwLock<>> #326

@intendednull

Description

@intendednull

Audit finding from #300 (commit 679f9fe)

Severity: low
Category: tech debt / performance
File: crates/client/src/search/handle.rs:29-32 ; crates/web/src/state_bridge.rs:23 ; crates/client/src/{listeners.rs:28, mutations.rs:47}
Obvious fix: yes for index; no for state_bridge.rs

Description

12 Arc sites total. The search handle wraps four fields each in an Arc — for a read-mostly index (queries vastly outnumber inserts) an Arc<RwLock> would let multiple lookups proceed concurrently. The state_bridge.rs doc-comment even calls out the choice as deliberate-for-mutation, but reads dominate the actual call sites.

Impact / Threat

Maintenance, performance — clarifies intent and removes unnecessary lock contention on the search hot path.

Suggested fix

Switch index and config in search/handle.rs to Arc<RwLock>. Keep status as Mutex since it's small and write-on-completion.

Verify

rg "Arc<Mutex" --type rust crates/ | wc -l
rg "Arc<Mutex" crates/client/src/search/handle.rs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions