-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
kvevent: implement chunked blocking buffer #86421
kvevent: implement chunked blocking buffer #86421
Conversation
9a6052f
to
ced8985
Compare
This change updates the blocking buffer micro benchmark in several ways: - it uses different types of events - it uses more producers than consumers to keep the buffer full - it makes b.N correspond to the total number of events, so the benchmark can analyze allocs per event Release note: None Release justification: This change updates a benchmark only.
This change implements a simple chunked event queue. The purpose of this queue is to be used by kvevent.blockingBuffer in subsequent commits. Release note: None Release justification: This change does not affect any production code. It adds files which are not called by any packages.
bc95e15
to
5b4b969
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits; giving LGTM, but please remove unneeded interface, and revert unnecessary refactors from this PR.
@nvanbenschoten : FYI: thanks to your investigations, @jayshrivastava made these changes that show significant improvements. |
This change refactors kvevent/blocking_buffer.go to use a chunked linked list instead of a regular linked list to reduce pointer usage. Note that the underlying sync.Pool, which is also a linked list, will use less pointers due to us pooling chunks instead of events. Release note: None Release justification: This change significantly improves performance by significantly reducing pressure on GC. Consequently, this significantly improves foreground SQL p99 latency. GC has been causing severe issues in production changefeeds. Merging this change in this release is worth it for its potential to reduce incedents.
5b4b969
to
5734c3d
Compare
bors r+ |
Build failed (retrying...): |
This is great! Nice experimentation @jayshrivastava.
I don't think I see where we're addressing #84709 in this PR. Doesn't the |
Build failed (retrying...): |
I think previous changes (e8e664c#diff-a2e21a39cea12e1823c4c6f7ce7e1513214a575ff049f204cf5633284cf8c6c9) replaced resolved events which were allocating a pointer. |
I think there might be a bit of confusion here. The concern isn't reducing heap allocations, it's about reducing the cost of GC by eliminating pointers that need to be traversed during the GC mark-sweep phase. So e8e664c#diff-a2e21a39cea12e1823c4c6f7ce7e1513214a575ff049f204cf5633284cf8c6c9 might have actually hurt, as the inlining replaced 1 pointer ( |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from 78b995a to blathers/backport-release-21.2-86421: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 21.2.x failed. See errors above. error creating merge commit from 78b995a to blathers/backport-release-22.1-86421: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 22.1.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
This is what's confusing to me too: because those 2 pointers needed to be deleted anyway because those were allocated |
Does every |
No, not every event has non-empty resolved span; Can't really make a claim that majority of events aren't carrying resolved We could try to basically break up event further: |
Looks like we need a manual backport? Let’s get that going if we haven’t already. |
@miretskiy and I are looking to test out the changes against TPC-E before backporting. It would be nice to see the impact of these changes to the same workload Nathan ran originally. |
@shermanCRL Just finished testing with TPC-E, with and without this change. Please see the appendix in this doc more info. Summary (with both a massive TPC-E load and a massive changefeed backfill running):
@miretskiy and I have more ideas regarding #84709. I think it makes the most sense to carry them out and backport everything at the same time. |
Nice! What’s the baseline SQL latency without changefeeds? |
40ms with only TPC-E running |
kvevent: refactor blocking buffer benchmark
This change updates the blocking buffer micro benchmark
in several ways:
buffer full
so the benchmark can analyze allocs per event
Release note: None
Release justification: This change updates a benchmark only.
kvevent: implement chunked buffer event queue
This change implements a simple chunked event queue.
The purpose of this queue is to be used by
kvevent.blockingBuffer in subsequent commits.
Release note: None
Release justification: This change does not affect
any production code. It adds files which are not
called by any packages.
kvevent: refactor memory buffer to chunked linked list
This change refactors kvevent/blocking_buffer.go to use
a chunked linked list instead of a regular linked list to
reduce pointer usage. Note that the underlying sync.Pool,
which is also a linked list, will use less pointers due to
us pooling chunks instead of events.
Release note: None
Release justification: This change significantly
improves performance by significantly reducing
pressure on GC. Consequently, this significantly
improves foreground SQL p99 latency. GC has
been causing severe issues in production changefeeds.
Merging this change in this release is worth it
for its potential to reduce incidents.
Results (micro)
These are the results of running the microbenchmark.
./dev bench pkg/ccl/changefeedccl/kvevent --filter=BenchmarkMemBuffer --count=10 --bench-mem --stream-output --test-args="--test.benchtime=45s" -- --nocache_test_results --test_verbose_timeout_warnings |& tee bench.txt
Results (Macro)
Full results are published here. In summary:
I analyzed performing by running TPC-C for 30 mins on a 15 node cluster with 10k warehouses. Before starting the workload, I started a changefeed on the
order_line
table (~200GB). I also set the following cluster settings to stress the buffer and pressure GC:changefeed.backfill.concurrent_scan_requests = 100;
changefeed.memory.per_changefeed_limit = '1073741824';
(~1GB)Then, I analyzed SQL latency from admin UI and GC performance using the output of
GODEBUG=gctrace=1.
These are the outcomes:Relevant Issues
Addresses: #84582
(for now...)