@@ -12,7 +12,7 @@ Originally posted as Fast TotW #64 on October 21, 2022
1212
1313* By
[ Chris Kennelly
] ( mailto:[email protected] ) * 1414
15- Updated 2023-10-10
15+ Updated 2025-03-24
1616
1717Quicklink: [ abseil.io/fast/64] ( https://abseil.io/fast/64 )
1818
@@ -42,10 +42,10 @@ preconditions to unlock the best possible performance. We need to document and
4242test these sharp edges. Future debugging has an opportunity cost: When we spend
4343time tracking down and fixing bugs, we are not developing new optimizations. We
4444can use assertions for preconditions, especially in debug/sanitizer builds, to
45- double-check contracts and * enforce* them. Testing robots never sleep, while
46- humans are fallible. Randomized implementation behaviors provide a useful
47- bulwark against Hyrum's Law from creeping in to implicitly expand the contract
48- of an interface.
45+ double-check contracts and * enforce* them. Testing
46+ [ robots never sleep ] ( /fast/93 ) , while humans are fallible. Randomized
47+ implementation behaviors provide a useful bulwark against Hyrum's Law from
48+ creeping in to implicitly expand the contract of an interface.
4949
5050## Express intents
5151
@@ -124,11 +124,11 @@ memory.
124124
125125## Avoid unnecessarily strong guarantees
126126
127- There are situations where the benefits of duplicate APIs outweight the costs.
127+ There are situations where the benefits of duplicate APIs outweigh the costs.
128128
129129The Abseil hash containers
130130([ SwissMap] ( https://abseil.io/about/design/swisstables ) ) added new hashtable
131- implementations to the code base , which at first glance, appear redundant with
131+ implementations to the codebase , which at first glance, appear redundant with
132132the ones in the C++ standard library. This apparent duplication allowed us to
133133have a more efficient set of containers which match the standard library API,
134134but adhere to a weaker set of constraints.
@@ -140,6 +140,11 @@ to a node-based implementation that requires data indirections and constrains
140140performance. Given ` std::unordered_map ` 's widespread usage, it was not feasible
141141to relax these guarantees all at once.
142142
143+ Node-based containers necessitate implementation overheads, but they come with a
144+ direct benefit: They actively facilitate migration while allowing weaker
145+ containers to be available. Making a guarantee stronger without an accompanying
146+ benefit is undesirable.
147+
143148The migration was a replacement path for the legacy containers, not an
144149alternative. The superior performance characteristics meant that users could
145150"just use SwissMap" without tedious benchmarking on a case-by-case basis.
@@ -218,7 +223,7 @@ constrain future implementations by creating sharp performance edges.
218223 higher-level intent--transferring pointer ownership, "lending" a submessage
219224 to another one, etc.
220225
221- ### Concluding remarks
226+ ## Concluding remarks
222227
223228Good performance should be available by default, not an optional feature. While
224229[ feature flags and knobs can be useful for testing and initial rollout] ( /fast/52 ) ,
0 commit comments