Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interval/generic: avoid letting argument to FirstOverlap escape to heap
Related to cockroachdb#45276. Prior to this change, the argument provided to `iterator.FirstOverlap` was stored in the iterator. This caused the argument to escape to the heap (if the parameterized type was a pointer) and would force an allocation if the argument was not already on the heap. This was not the intention and was causing issues in cockroachdb#45276. This commit fixes the issue by no longer storing the argument in the iterator's `overlapScan` object. This allows escape analysis to determine that the argument does not escape, like it was already doing for `iterator.SeekGE` and `iterator.SeekLT`. ``` name old time/op new time/op delta BTreeIterFirstOverlap/count=16-16 400ns ± 1% 325ns ± 5% -18.75% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=128-16 661ns ± 0% 581ns ± 1% -12.02% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=1024-16 1.15µs ± 2% 1.07µs ± 2% -6.76% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=8192-16 1.84µs ± 2% 1.76µs ± 2% -4.38% (p=0.016 n=5+5) BTreeIterFirstOverlap/count=65536-16 2.62µs ± 2% 2.52µs ± 1% -4.07% (p=0.008 n=5+5) BTreeIterNextOverlap-16 11.1ns ± 2% 10.7ns ± 0% -3.95% (p=0.016 n=5+4) BTreeIterOverlapScan-16 34.2µs ± 1% 31.2µs ± 1% -8.78% (p=0.008 n=5+5) name old alloc/op new alloc/op delta BTreeIterFirstOverlap/count=16-16 96.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=128-16 96.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=1024-16 96.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=8192-16 96.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=65536-16 96.0B ± 0% 0.0B -100.00% (p=0.008 n=5+5) BTreeIterNextOverlap-16 0.00B 0.00B ~ (all equal) BTreeIterOverlapScan-16 144B ± 0% 48B ± 0% -66.67% (p=0.008 n=5+5) name old allocs/op new allocs/op delta BTreeIterFirstOverlap/count=16-16 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=128-16 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=1024-16 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=8192-16 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) BTreeIterFirstOverlap/count=65536-16 1.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5) BTreeIterNextOverlap-16 0.00 0.00 ~ (all equal) BTreeIterOverlapScan-16 6.40 ± 9% 5.00 ± 0% -21.88% (p=0.008 n=5+5) ```
- Loading branch information