-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Migrated to sharded latch & commit buffer #12
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sthagen
added a commit
to sthagen/kelindar-column
that referenced
this pull request
Jul 14, 2021
Migrated to sharded latch & commit buffer (kelindar#12)
Hi! Thanks for the information, it seems that register-based calling convention is giving excellent performance benefits. Did you run the benchmark with the officially released Go 1.17 too? |
@objectref I did over the weekend, the numbers looked roughly the same as the beta. |
Ok, thank you! Impressive difference, indeed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a couple of major changes in this library.
[]byte
which can be potentially written to disk in future for disaster recovery, see Persistency (at least for fast recovery - maybe some log of requests?) #5. This commit buffer stores various operations and their offsets and has been optimized.read committed
, its introducing a shared mutex, as discussed Txn Commit can result in transaction guarantee violation #6. This increases overall concurrency of a single large collection. The collection is essentially divided in "chunks" of 16K elements and we're now using 128 latches (shardedRWMutex
) in order to control concurrent access.Performance hit of sharded mutex is relatively small, and in case of updates the new commit buffer it actually reduces heap allocations as it no longer requires to allocate a single
interface{}
on the heap.Benchmark go1.16
I ran a small benchmark with various workloads (90% read / 10% write, etc) on a collection of 1 million elements with different goroutine pools. In this example we're combining two types of transactions:
Note that the goal of this benchmark is to validate concurrency, not throughput this represents the current "best" case scenario when the updates are random and do less likely to incur contention. Reads, however quite often would hit the same chunks as only the index itself is randomized.
As expected, it scales quite well to large number of goroutines unless the workload extremely write-heavy in which case exclusive latches on chunks would lead to contentions across the board and decrease the performance.
Benchmark go1.17beta1
I also ran the exact same benchmark on
go 1.17 beta1
and the improvement is quite impressive. I suspect because of golang/go#40724 major change by the amazing Go team.