Skip to content

Eliminate redundant lock acquisitions in LookupKeyID#1563

Merged
lestrrat merged 2 commits intodevelop/v3from
perf-lookupkeyid
Feb 22, 2026
Merged

Eliminate redundant lock acquisitions in LookupKeyID#1563
lestrrat merged 2 commits intodevelop/v3from
perf-lookupkeyid

Conversation

@lestrrat
Copy link
Collaborator

Iterate s.keys directly under outer RLock instead of calling s.Len() and s.Key() which each reacquire the lock.

~2x faster across all set sizes:
size=1: 13.3→6.0 ns/op
size=10: 40→21 ns/op (mid), 62→32 ns/op (end)
size=100: 289→149 ns/op (mid), 566→291 ns/op (end)

Iterate s.keys directly under outer RLock instead of calling
s.Len() and s.Key() which each reacquire the lock.

~2x faster across all set sizes:
  size=1: 13.3→6.0 ns/op
  size=10: 40→21 ns/op (mid), 62→32 ns/op (end)
  size=100: 289→149 ns/op (mid), 566→291 ns/op (end)
@lestrrat lestrrat merged commit b4a958c into develop/v3 Feb 22, 2026
23 checks passed
@lestrrat lestrrat deleted the perf-lookupkeyid branch February 22, 2026 11:03
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.

1 participant