Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use all the bits (
popcount
) in FindFirstNonFullAfterResize
and `P…
…repareInsertAfterSoo`. Motivation: the previous change (simplification of small table growth) caused quite a lot of tests to become flaky. In order to avoid that happening in the long run, we want to make order and relative order more randomized. Caveat: generally popcount has latency 3 and the change may add a bit of latency for the small table growth codepath. But there is a lot of other work to be done in parallel. Newly introduced `RelativeIterationOrderChangesByInstance` test verifies randomness in relative order for small tables. Before this change it was failing 5% of the time with 10K iterations. With new implementation it passes with 500 iterations. BM_SWISSMAP_InsertManyOrdered_Hot shows regression, but it is likely an artifact of the benchmark. Order in the benchmark is taken from the table that was filled without reserve. Now this order for small tables is more drastically different compared to order in reserved table. Macrobenchmarks are neutral. ``` name old cpu/op new cpu/op delta BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 4>/set_size:1/density:1 3.04ns ± 3% 3.04ns ± 3% ~ (p=0.598 n=34+34) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 4>/set_size:2/density:1 3.12ns ± 3% 3.12ns ± 3% ~ (p=0.981 n=35+35) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 4>/set_size:4/density:1 3.11ns ± 3% 3.11ns ± 3% ~ (p=0.888 n=35+35) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 4>/set_size:8/density:1 3.15ns ± 3% 3.16ns ± 3% ~ (p=0.778 n=35+35) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 64>/set_size:1/density:1 3.02ns ± 3% 3.01ns ± 3% ~ (p=0.322 n=34+35) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 64>/set_size:2/density:1 3.12ns ± 3% 3.11ns ± 4% ~ (p=0.860 n=35+35) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 64>/set_size:4/density:1 3.12ns ± 3% 3.12ns ± 3% ~ (p=0.895 n=35+34) BM_SWISSMAP_InsertMiss_Hot<::absl::flat_hash_set, 64>/set_size:8/density:1 3.17ns ± 2% 3.17ns ± 3% ~ (p=0.842 n=35+35) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 4>/set_size:1/density:1 3.34ns ± 3% 3.34ns ± 3% ~ (p=0.432 n=33+35) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 4>/set_size:2/density:1 3.30ns ± 3% 3.29ns ± 3% ~ (p=0.328 n=33+34) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 4>/set_size:4/density:1 3.30ns ± 3% 3.29ns ± 3% ~ (p=0.252 n=35+35) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 4>/set_size:8/density:1 3.30ns ± 4% 3.28ns ± 3% ~ (p=0.138 n=35+33) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 64>/set_size:1/density:1 3.40ns ± 2% 3.38ns ± 3% ~ (p=0.302 n=29+35) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 64>/set_size:2/density:1 3.46ns ± 3% 3.44ns ± 3% ~ (p=0.242 n=35+35) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 64>/set_size:4/density:1 3.46ns ± 3% 3.45ns ± 3% ~ (p=0.548 n=34+34) BM_SWISSMAP_InsertHit_Hot<::absl::flat_hash_set, 64>/set_size:8/density:1 3.45ns ± 3% 3.45ns ± 3% ~ (p=0.573 n=35+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 4>/set_size:1/density:1 13.6ns ± 3% 14.7ns ± 3% +8.35% (p=0.000 n=35+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 4>/set_size:2/density:1 12.3ns ± 3% 13.4ns ± 4% +8.92% (p=0.000 n=35+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 4>/set_size:4/density:1 12.3ns ± 3% 13.4ns ± 4% +8.92% (p=0.000 n=35+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 4>/set_size:8/density:1 11.7ns ± 4% 12.4ns ± 3% +5.47% (p=0.000 n=34+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 64>/set_size:1/density:1 13.4ns ± 3% 13.4ns ± 4% ~ (p=0.933 n=34+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 64>/set_size:2/density:1 12.2ns ± 3% 12.2ns ± 3% ~ (p=0.471 n=34+33) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 64>/set_size:4/density:1 12.2ns ± 2% 12.2ns ± 3% ~ (p=0.944 n=31+35) BM_SWISSMAP_InsertManyOrdered_Hot<::absl::flat_hash_set, 64>/set_size:8/density:1 11.6ns ± 2% 11.6ns ± 4% ~ (p=0.335 n=31+35) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 4>/set_size:1/density:1 18.8ns ± 3% 18.8ns ± 4% ~ (p=0.577 n=34+33) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 4>/set_size:2/density:1 14.6ns ± 3% 14.5ns ± 4% ~ (p=0.106 n=35+34) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 4>/set_size:4/density:1 14.5ns ± 3% 14.5ns ± 3% ~ (p=0.427 n=31+34) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 4>/set_size:8/density:1 12.8ns ± 3% 12.8ns ± 9% ~ (p=0.869 n=30+31) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 64>/set_size:1/density:1 18.8ns ± 2% 18.7ns ± 4% -0.76% (p=0.015 n=29+35) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 64>/set_size:2/density:1 14.5ns ± 3% 14.4ns ± 4% ~ (p=0.314 n=33+31) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 64>/set_size:4/density:1 14.5ns ± 3% 14.4ns ± 3% ~ (p=0.141 n=34+31) BM_SWISSMAP_InsertManyUnordered_Hot<::absl::flat_hash_set, 64>/set_size:8/density:1 12.7ns ± 2% 12.7ns ± 3% ~ (p=0.099 n=34+34) ``` PiperOrigin-RevId: 702758293 Change-Id: I0ec1cec37ddeafff70a43707385467c087fb424c
- Loading branch information