Skip to content

Commit

Permalink
Mark Abseil hardening assert in AssertSameContainer as slow.
Browse files Browse the repository at this point in the history
When Abseil hardening is enabled, this assertion's condition gets evaluated every time an iterator equality check is performed on iterators from a raw_hash_set.  This occurs very frequently when looping over the contents of sets, due to loop conditions like `it != end()`, and causes about 0.4% CPU overhead to some Google workloads.

PiperOrigin-RevId: 681560141
Change-Id: Ia0177cbef7cf67f9f0b6adf2cf55d9a2ed320d2d
  • Loading branch information
Abseil Team authored and copybara-github committed Oct 2, 2024
1 parent c6b2735 commit 5d34707
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion absl/container/internal/raw_hash_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ inline void AssertSameContainer(const ctrl_t* ctrl_a, const ctrl_t* ctrl_b,
"hashtable.");
fail_if(true, "Comparing non-end() iterators from different hashtables.");
} else {
ABSL_HARDENING_ASSERT(
ABSL_HARDENING_ASSERT_SLOW(
AreItersFromSameContainer(ctrl_a, ctrl_b, slot_a, slot_b) &&
"Invalid iterator comparison. The iterators may be from different "
"containers or the container might have rehashed or moved. Consider "
Expand Down

0 comments on commit 5d34707

Please sign in to comment.