Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key Locks #41

Merged
merged 2 commits into from
Feb 24, 2025
Merged

Key Locks #41

merged 2 commits into from
Feb 24, 2025

Conversation

bbengfort
Copy link
Contributor

@bbengfort bbengfort commented Feb 24, 2025

Scope of changes

Implements a fixed memory key lock mutex that balances keys across a fixed number of locks. The more locks, the better concurrency, but without unbounded growth. This data structure will be used to ensure concurrent accesses on a single node are safe.

Benchmarks:

goos: darwin
goarch: arm64
pkg: github.com/rotationalio/honu/pkg/store/locks
cpu: Apple M1 Max
BenchmarkLocks/Mutex-10         	      19	  59030469 ns/op	   62458 B/op	    1074 allocs/op
BenchmarkLocks/KeyLock-10       	      42	  29340972 ns/op	   49993 B/op	    1033 allocs/op

Under a lot of contention, the key lock allows more concurrent access to the lock space than a single mutex, doubling the concurrent performance with the same safety guarantees.

Type of change

  • new feature
  • bug fix
  • documentation
  • testing
  • technical debt
  • other (describe)

Acceptance criteria

This PR will be merged without review.

Definition of Done

  • I have manually tested the change running it locally (having rebuilt all containers) or via unit tests
  • I have added unit and/or integration tests that cover my changes
  • I have added new test fixtures as needed to support added tests
  • I have updated the dependencies list if necessary (including updating yarn.lock and/or go.sum)

@bbengfort bbengfort merged commit 4758944 into main Feb 24, 2025
5 checks passed
@bbengfort bbengfort deleted the keylocks branch February 24, 2025 15:32
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