Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: BenchmarkMapDelete is non-linear and slow #21546
Note that the ns/op increases as the benchtime goes up. This indicates that the benchmark is not well-formed. Beyond that, it causes problems because (1) minor performance changes that trigger a change in the number of iterations appear to be significant performance changes and (2) when the number of iterations that fits in benchtime is on the edge it causes a bimodal ns/op distribution.
Note also that it takes 12s to run a 1s benchmark. Ouch.
IIRC, some other recently added map benchmarks share these problems. (They also should have been added to mapspeed_test.go instead of map_test.go.)
Looks like the initialization needs to be reworked. I'll take a stab at it today
I have a reworked benchmark which runs faster and is stable wrt increased benchtime
I'll send a CL shortly
Move the tophash checks after the equality/length checks. For fast32/fast64, since we've done a full equality check already, just check whether tophash is empty instead of checking tophash. This is cheaper and allows us to skip calculating tophash. These changes are modeled on the changes in CL 57590, which were polished based on benchmarking. Benchmarking directly is impeded by #21546. Change-Id: I0e17163028e34720310d1bf8f95c5ef42d223e00 Reviewed-on: https://go-review.googlesource.com/57611 Run-TryBot: Josh Bleecher Snyder <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Keith Randall <email@example.com>
When deleting entries from a map, only clear the key and value if they contain pointers. And use memclrHasPointers to do so. While we're here, specialize key clearing in mapdelete_faststr, and fix another missed usage of add in mapdelete. Benchmarking impeded by #21546. Change-Id: I3f6f924f738d6b899b722d6438e9e63f52359b84 Reviewed-on: https://go-review.googlesource.com/57630 Run-TryBot: Josh Bleecher Snyder <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Keith Randall <firstname.lastname@example.org>