Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage,kv: faster intent resolution over a key range
When all the intents on a range are known to be separated, as indicated by MCCStats, and a ResolveIntentRangeRequest needs to be processed (for a transaction that did enough writes that we did not track individual intent keys), we avoid iterating over MVCC key-value pairs to find those intents, and instead iterate over the separated lock table key space. A new iterForKeyVersions interface is introduced which provides a narrow iterator interface to be used by mvccResolveWriteIntent that resolves individual intents. This interface is only for iterating over a single key, and is implemented by the usual MVCCIterator and by the new separatedIntentAndVersionIter. The latter serves both as a way to find intents over a range and for individual intent resolution, in an optimized manner. There are new benchmarks which vary the sparseness (sparseness of N means that 1 of every N key has an intent that is for the txn for which intent resolution is being performed) and whether the remaining N-1 keys have an intent from a different transaction (other-txn-intents=true) or not (the former results in the cost of at least parsing the MVCCMetadata to compare txn IDs). Full results are below. Two things to note are: - The percent-flushed={0,50} sometimes show a regression. These are atypical cases where the SingleDelete to remove the intent has not been flushed so the intent Set and SingleDelete are both alive. This would be a pathalogical case when the LSM is unhealthy. Even then the regression is < 170%. - The percent-flushed=100 cases are the typical one. Once sparseness increases to 100 or 1000 we see speed gains close to 100x, as indicated by the following: IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=100-16 235µs ± 2% 58µs ± 3% -75.52% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=100-16 154µs ± 2% 2µs ± 4% -98.72% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=100-16 137µs ± 1% 1µs ± 2% -99.07% (p=0.008 n=5+5) Full results: name old time/op new time/op delta IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=0-16 450µs ± 5% 234µs ± 2% -48.07% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=50-16 294µs ± 3% 101µs ± 4% -65.49% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=100-16 235µs ± 2% 58µs ± 3% -75.52% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=0-16 494µs ± 7% 218µs ± 6% -55.84% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=50-16 251µs ± 2% 57µs ± 3% -77.29% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=100-16 154µs ± 2% 2µs ± 4% -98.72% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=0-16 343µs ± 5% 236µs ± 2% -31.28% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=50-16 240µs ± 1% 74µs ± 2% -69.02% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=100-16 203µs ± 1% 30µs ± 1% -84.97% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=0-16 516µs ± 4% 274µs ±13% -46.91% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=50-16 256µs ± 2% 57µs ± 1% -77.67% (p=0.016 n=4+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=100-16 137µs ± 1% 1µs ± 2% -99.07% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=0-16 325µs ± 2% 237µs ± 1% -26.98% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=50-16 232µs ± 4% 72µs ± 1% -68.89% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=100-16 199µs ± 1% 30µs ± 0% -84.87% (p=0.016 n=5+4) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=0-16 2.08ms ± 1% 2.68ms ± 8% +28.57% (p=0.016 n=4+5) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=50-16 592µs ± 4% 596µs ± 7% ~ (p=1.000 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=100-16 242µs ± 2% 59µs ± 3% -75.73% (p=0.016 n=4+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=0-16 3.04ms ± 5% 2.60ms ± 3% -14.59% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=50-16 840µs ± 4% 539µs ± 3% -35.87% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=100-16 163µs ± 6% 2µs ± 6% -98.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=0-16 936µs ±38% 2497µs ±12% +166.83% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=50-16 281µs ±12% 551µs ± 2% +95.64% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=100-16 209µs ±13% 31µs ± 9% -84.95% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1000/other-txn-intents=false/percent-flushed=0-16 3.04ms ± 6% 2.55ms ± 0% ~ (p=0.333 n=5+1) name old alloc/op new alloc/op delta IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=0-16 12.8kB ± 0% 13.0kB ± 0% +0.92% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=50-16 12.8kB ± 0% 13.0kB ± 0% +0.94% (p=0.016 n=5+4) IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=100-16 12.9kB ± 0% 13.0kB ± 0% +0.59% (p=0.016 n=5+4) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=0-16 1.75kB ± 0% 0.29kB ± 0% ~ (p=0.079 n=4+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=50-16 1.75kB ± 0% 0.29kB ± 0% -83.18% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=100-16 1.75kB ± 0% 0.29kB ± 0% -83.22% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=0-16 12.8kB ± 0% 11.4kB ± 0% -11.37% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=50-16 12.8kB ± 0% 11.4kB ± 0% ~ (p=0.079 n=4+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=100-16 12.8kB ± 0% 11.4kB ± 0% -11.41% (p=0.000 n=5+4) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=0-16 1.66kB ± 0% 0.17kB ± 0% -89.61% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=50-16 1.66kB ± 0% 0.17kB ± 0% -89.61% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=100-16 1.66kB ± 0% 0.17kB ± 0% -89.63% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=0-16 12.8kB ± 0% 11.4kB ± 0% -11.50% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=50-16 12.8kB ± 0% 11.4kB ± 0% ~ (p=0.079 n=4+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=100-16 12.8kB ± 0% 11.4kB ± 0% -11.53% (p=0.029 n=4+4) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=0-16 12.8kB ± 0% 13.0kB ± 0% +0.95% (p=0.016 n=5+4) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=50-16 12.8kB ± 0% 13.0kB ± 0% +0.95% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=100-16 12.9kB ± 0% 13.0kB ± 0% +0.54% (p=0.016 n=5+4) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=0-16 1.75kB ± 0% 0.29kB ± 0% -83.14% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=50-16 1.75kB ± 0% 0.29kB ± 0% -83.19% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=100-16 1.75kB ± 0% 0.29kB ± 0% -83.22% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=0-16 12.8kB ± 0% 11.4kB ± 0% -11.37% (p=0.000 n=5+4) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=50-16 12.8kB ± 0% 11.4kB ± 0% -11.37% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=100-16 12.8kB ± 0% 11.4kB ± 0% -11.41% (p=0.000 n=5+4) IntentRangeResolution/separated=true/versions=100/sparseness=1000/other-txn-intents=false/percent-flushed=0-16 1.66kB ± 0% 0.17kB ± 0% -89.56% (p=0.000 n=5+1) name old allocs/op new allocs/op delta IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=0-16 401 ± 0% 404 ± 0% +0.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=50-16 401 ± 0% 404 ± 0% +0.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1/other-txn-intents=false/percent-flushed=100-16 401 ± 0% 404 ± 0% +0.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=0-16 104 ± 0% 8 ± 0% -92.31% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=50-16 104 ± 0% 8 ± 0% -92.31% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=false/percent-flushed=100-16 104 ± 0% 8 ± 0% -92.31% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=0-16 401 ± 0% 305 ± 0% -23.94% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=50-16 401 ± 0% 305 ± 0% -23.94% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=100/other-txn-intents=true/percent-flushed=100-16 401 ± 0% 305 ± 0% -23.94% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=0-16 102 ± 0% 3 ± 0% -97.06% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=50-16 102 ± 0% 3 ± 0% -97.06% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=false/percent-flushed=100-16 102 ± 0% 3 ± 0% -97.06% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=0-16 401 ± 0% 303 ± 0% -24.44% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=50-16 401 ± 0% 303 ± 0% -24.44% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=10/sparseness=1000/other-txn-intents=true/percent-flushed=100-16 401 ± 0% 303 ± 0% -24.44% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=0-16 401 ± 0% 404 ± 0% +0.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=50-16 401 ± 0% 404 ± 0% +0.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1/other-txn-intents=false/percent-flushed=100-16 401 ± 0% 404 ± 0% +0.75% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=0-16 104 ± 0% 8 ± 0% -92.31% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=50-16 104 ± 0% 8 ± 0% -92.31% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=false/percent-flushed=100-16 104 ± 0% 8 ± 0% -92.31% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=0-16 401 ± 0% 305 ± 0% -23.94% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=50-16 401 ± 0% 305 ± 0% -23.94% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=100/other-txn-intents=true/percent-flushed=100-16 401 ± 0% 305 ± 0% -23.94% (p=0.008 n=5+5) IntentRangeResolution/separated=true/versions=100/sparseness=1000/other-txn-intents=false/percent-flushed=0-16 102 ± 0% 3 ± 0% -97.06% (p=0.000 n=5+1) Release note (performance improvement): Intent resolution for transactions that write many intents such that we track intent ranges, for the purpose of intent resolution, is much faster (potentially 100x) when using the separated lock table.
- Loading branch information