Commit 5d347078 by Abseil Team Committed by Copybara-Service

Mark Abseil hardening assert in AssertSameContainer as slow.

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
parent c6b27359
...@@ -1753,7 +1753,7 @@ inline void AssertSameContainer(const ctrl_t* ctrl_a, const ctrl_t* ctrl_b, ...@@ -1753,7 +1753,7 @@ inline void AssertSameContainer(const ctrl_t* ctrl_a, const ctrl_t* ctrl_b,
"hashtable."); "hashtable.");
fail_if(true, "Comparing non-end() iterators from different hashtables."); fail_if(true, "Comparing non-end() iterators from different hashtables.");
} else { } else {
ABSL_HARDENING_ASSERT( ABSL_HARDENING_ASSERT_SLOW(
AreItersFromSameContainer(ctrl_a, ctrl_b, slot_a, slot_b) && AreItersFromSameContainer(ctrl_a, ctrl_b, slot_a, slot_b) &&
"Invalid iterator comparison. The iterators may be from different " "Invalid iterator comparison. The iterators may be from different "
"containers or the container might have rehashed or moved. Consider " "containers or the container might have rehashed or moved. Consider "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment