-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
spanconfig: scale-test for 1M tables #78215
spanconfig: scale-test for 1M tables #78215
Conversation
We added ForEachOverlappingSpanConfig to the Store interface to be able to mock it out for testing. We can instead use a testing knob. A future commit will add test-only helpers on the concrete store implementation and add plumbing to access it through the concrete kvsubscriber type. This PR will let us do so without expanding the Store interface further. Release justification: low risk, high benefit Release note: None
8a3e6dc
to
cd6b990
Compare
Pure code-movement change. Release note: None Release justification: None
8640356
to
93bf765
Compare
Here are selected logs from one of these test runs (raw gist here). Few things to understand:
I220414 19:40:33.333954 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 80 finished epoch=0 (took 26.451988s); running total: 100000 tables in 26.451988s
I220414 19:40:36.468673 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 86 sqlwatcher received 100000 updates
I220414 19:41:04.151885 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 89 finished epoch=1 (took 30.81778s); running total: 200000 tables in 57.26992s
I220414 19:41:25.401317 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 94 sqltranslator translated 100000 records in 48.932576s
I220414 19:41:28.504736 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 95 incrementally reconciled: +100000 -0 entries in 3.103309s
I220414 19:41:28.692836 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 97 spanconfig-subscriber: established range feed cache
I220414 19:41:29.251784 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 98 sqlwatcher received 100000 updates
I220414 19:41:29.790269 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 99 spanconfig-subscriber: completed initial scan; flushed 100048 events
I220414 19:41:34.291031 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 100 finished epoch=2 (took 30.139075s); running total: 300000 tables in 1m27.409066s
I220414 19:42:03.261744 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 107 finished epoch=3 (took 28.97064s); running total: 400000 tables in 1m56.379781s
I220414 19:42:15.608217 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 114 sqltranslator translated 100000 records in 46.356368s
I220414 19:42:18.681697 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 115 incrementally reconciled: +100000 -0 entries in 3.07341s
I220414 19:42:18.891866 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 117 spanconfig-subscriber: established range feed cache
I220414 19:42:20.041115 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 118 sqlwatcher received 200000 updates
I220414 19:42:20.069966 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 119 spanconfig-subscriber: completed initial scan; flushed 200048 events
I220414 19:42:33.627004 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 120 finished epoch=4 (took 30.365189s); running total: 500000 tables in 2m26.74504s
I220414 19:43:03.752912 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 125 finished epoch=5 (took 30.125833s); running total: 600000 tables in 2m56.870947s
I220414 19:43:43.059044 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 135 finished epoch=6 (took 39.306052s); running total: 700000 tables in 3m36.177081s
I220414 19:44:06.163368 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 143 sqltranslator translated 200000 records in 1m46.122173s
I220414 19:44:12.341914 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 144 incrementally reconciled: +200000 -0 entries in 6.178454s
I220414 19:44:12.531552 264 kv/kvserver/rangefeed/budget.go:166 [n1,s1,r43/1:/Table/{47-50},raft] 146 trying to get allocation from already closed budget
I220414 19:44:12.708052 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 147 spanconfig-subscriber: established range feed cache
I220414 19:44:14.339386 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 149 sqlwatcher received 300000 updates
I220414 19:44:16.904133 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 150 spanconfig-subscriber: completed initial scan; flushed 400048 events
I220414 19:44:25.366817 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 155 finished epoch=7 (took 42.307692s); running total: 800000 tables in 4m18.484853s
I220414 19:45:05.371089 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 165 finished epoch=8 (took 40.004198s); running total: 900000 tables in 4m58.489124s
I220414 19:45:44.728048 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 178 finished epoch=9 (took 39.356894s); running total: 1000000 tables in 5m37.846084s
I220414 19:46:08.250326 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 209 sqltranslator translated 300000 records in 1m53.910851s
I220414 19:46:16.113606 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 213 incrementally reconciled: +300000 -0 entries in 7.863214s
I220414 19:46:16.641413 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 215 spanconfig-subscriber: established range feed cache
I220414 19:46:19.236393 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 217 sqlwatcher received 300000 updates
I220414 19:46:21.857409 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 219 spanconfig-subscriber: completed initial scan; flushed 700048 events
I220414 19:47:10.289037 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 241 sqltranslator translated 300000 records in 51.052571s
I220414 19:47:18.256947 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 244 incrementally reconciled: +300000 -0 entries in 7.96784s
I220414 19:47:19.286002 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 247 spanconfig-subscriber: established range feed cache
I220414 19:47:25.066720 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 250 spanconfig-subscriber: completed initial scan; flushed 1000048 events Just looking at individual components: # SQLTranslator (slow)
I220414 19:41:25.401317 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 94 sqltranslator translated 100000 records in 48.932576s
I220414 19:42:15.608217 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 114 sqltranslator translated 100000 records in 46.356368s
I220414 19:44:06.163368 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 143 sqltranslator translated 200000 records in 1m46.122173s
I220414 19:46:08.250326 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 209 sqltranslator translated 300000 records in 1m53.910851s
I220414 19:47:10.289037 551 spanconfig/spanconfigreconciler/reconciler.go:453 [n1,job=753319302814400513] 241 sqltranslator translated 300000 records in 51.052571s
# Reconciler + KVAccessor (fast)
I220414 19:41:28.504736 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 95 incrementally reconciled: +100000 -0 entries in 3.103309s
I220414 19:42:18.681697 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 115 incrementally reconciled: +100000 -0 entries in 3.07341s
I220414 19:44:12.341914 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 144 incrementally reconciled: +200000 -0 entries in 6.178454s
I220414 19:46:16.113606 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 213 incrementally reconciled: +300000 -0 entries in 7.863214s
I220414 19:47:18.256947 551 spanconfig/spanconfigreconciler/reconciler.go:487 [n1,job=753319302814400513] 244 incrementally reconciled: +300000 -0 entries in 7.96784s
# KVSubscriber (fast -- compare timestamps on successive lines)
I220414 19:41:28.692836 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 97 spanconfig-subscriber: established range feed cache
I220414 19:41:29.790269 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 99 spanconfig-subscriber: completed initial scan; flushed 100048 events
I220414 19:42:18.891866 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 117 spanconfig-subscriber: established range feed cache
I220414 19:42:20.069966 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 119 spanconfig-subscriber: completed initial scan; flushed 200048 events
I220414 19:44:12.708052 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 147 spanconfig-subscriber: established range feed cache
I220414 19:44:16.904133 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 150 spanconfig-subscriber: completed initial scan; flushed 400048 events
I220414 19:46:16.641413 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 215 spanconfig-subscriber: established range feed cache
I220414 19:46:21.857409 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 219 spanconfig-subscriber: completed initial scan; flushed 700048 events
I220414 19:47:19.286002 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:316 [n1] 247 spanconfig-subscriber: established range feed cache
I220414 19:47:25.066720 375 kv/kvclient/rangefeed/rangefeedcache/watcher.go:357 [n1] 250 spanconfig-subscriber: completed initial scan; flushed 1000048 events
# SQLWatcher (maybe slow? compare timestamps between when updates are received and when the corresponding # of tables were committed)
I220414 19:40:33.333954 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 80 finished epoch=0 (took 26.451988s); running total: 100000 tables in 26.451988s
I220414 19:40:36.468673 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 86 sqlwatcher received 100000 updates
I220414 19:41:04.151885 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 89 finished epoch=1 (took 30.81778s); running total: 200000 tables in 57.26992s
I220414 19:41:29.251784 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 98 sqlwatcher received 100000 updates
I220414 19:41:34.291031 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 100 finished epoch=2 (took 30.139075s); running total: 300000 tables in 1m27.409066s
I220414 19:42:03.261744 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 107 finished epoch=3 (took 28.97064s); running total: 400000 tables in 1m56.379781s
I220414 19:42:20.041115 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 118 sqlwatcher received 200000 updates
I220414 19:42:33.627004 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 120 finished epoch=4 (took 30.365189s); running total: 500000 tables in 2m26.74504s
I220414 19:43:03.752912 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 125 finished epoch=5 (took 30.125833s); running total: 600000 tables in 2m56.870947s
I220414 19:43:43.059044 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 135 finished epoch=6 (took 39.306052s); running total: 700000 tables in 3m36.177081s
I220414 19:44:14.339386 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 149 sqlwatcher received 300000 updates
I220414 19:44:25.366817 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 155 finished epoch=7 (took 42.307692s); running total: 800000 tables in 4m18.484853s
I220414 19:45:05.371089 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 165 finished epoch=8 (took 40.004198s); running total: 900000 tables in 4m58.489124s
I220414 19:45:44.728048 25 spanconfig_test/pkg/spanconfig/spanconfig_test.go:107 [-] 178 finished epoch=9 (took 39.356894s); running total: 1000000 tables in 5m37.846084s
I220414 19:46:19.236393 551 spanconfig/spanconfigreconciler/reconciler.go:405 [n1,job=753319302814400513] 217 sqlwatcher received 300000 updates |
I'm hoping to check this PR in, though with the test actually skipped given how long running it is. It's mostly a test-only change and knob tuning that I think would make for reasonable defaults. It also includes a few peephole optimizations around the sqlwatcher that shows up prominently in CPU profiles and this end-to-end test. For the additional logging, I'll hide behind a high verbosity flag once LGTM-ed. PTAL. |
Also open to ideas from @cockroachdb/sql-schema on how to speed up committing a high number of tables. I tried a few approaches (large strings, large txns, etc) and I found this to be the fastest. Given table creation alone takes up a non-trivial amount of time ( |
This PR adds an end-to-end scale test for the span configs infrastructure, demonstrating the ability to get up to 1M tables, with configs reconciled end-to-end. dev test pkg/spanconfig -f=TestScalability -v \ --show-logs --timeout=1000s --stream-output From test logs: finished epoch=9 (took 39.356894s); running total: 1000000 tables in 5m37.846084s ... end-to-end span config reconciliation (post-creation) for 1000048 tables took 1m40.496927s Release justification: test-only change Release note: None
93bf765
to
cc2fae5
Compare
Added an incremental reconciliation step to the test, and seeing what looks like a surprising perf profile in the kvaccessor when batching deletes (total = 100k entries, batch size of 10k):
Is there an easy way to get an EXPLAIN {,ANALYZE} trace out of internal queries like this? Issued through the internal executor in the example above. |
https://gist.github.com/irfansharif/5d00600de25b747f0c8348d598675e59 Here's the trace for the slow statement. I'm not sure I'm seeing where the latency spikes are coming from. Is it flow scheduling?
|
cc2fae5
to
9780ef9
Compare
A hacked in EXPLAIN statement suggests it’s due to us falling back to full table scans due to missing stats. In the test I tried an |
We never collect stats on system tables. |
9780ef9
to
e5b8d33
Compare
513bc23
to
85c3046
Compare
Filed #80123. After manually creating stats and some SQL code change to actually use it for
This problem goes away once using table stats; we'd no longer be doing full table scans when deleting span configs. It'd be nice to work on #80123 soon, and to also perhaps backport a minimal form to 22.1.x. Timing the reconciler + kvaccessor again with system table stats after altering RANGE DEFAULT:
It's still a bit slower than the initial reconciliation pass:
Where the additional time can be attributed to all the entries we have to delete (in the initial pass we blindly upsert). The end-to-end time post change to RANGE DEFAULT can still be attributed to the sql translator:
|
And some instrumentation around kvaccessor delete batches, which has a surprising perf profile: kvaccessor delete batch for 10000 entries took 21.935536s kvaccessor delete batch for 10000 entries took 19.687731s kvaccessor delete batch for 10000 entries took 17.420078s kvaccessor delete batch for 10000 entries took 15.049966s kvaccessor delete batch for 10000 entries took 12.770569s kvaccessor delete batch for 10000 entries took 10.492817s kvaccessor delete batch for 10000 entries took 8.351056s kvaccessor delete batch for 10000 entries took 6.053576s kvaccessor delete batch for 10000 entries took 3.740439s kvaccessor delete batch for 10000 entries took 1.473374s Release note: None
85c3046
to
9885727
Compare
#80189 is a possible optimization and in our run above, will make the incremental pass as fast as the initial one. |
I'm not going to have time to take this further. The results above were still useful and drove targeted optimizations+hinted at others. Perhaps once the schema folks are interested in advertising greater #s of tables, we can revive (or rewrite) a form of this test. |
This PR adds an end-to-end scale test for the span configs
infrastructure, demonstrating the ability to get up to 1M tables, with
configs reconciled end-to-end.
From test logs:
Release justification: test-only change
Release note: None