Associate a saturating counter with every call site telling whether it's worthwhile to do small-range or not. If it's predicted not worthwhile, skip condrange and go straight to building the hash table; range can be calculated at low cost while doing hash table, so we get feedback on if we got this wrong. If it is predicted worthwhile, also cache an approximate lower bound (often just 0, or the time when an initial measurement was taken, or w/e); if it appears stable (how to quantify this?), speculatively start building the small-range table right away and bail out if the range estimate was wrong.
Backoff in condrange can probably skipped, simplifying and possibly speeding up slightly.
Associate a saturating counter with every call site telling whether it's worthwhile to do small-range or not. If it's predicted not worthwhile, skip condrange and go straight to building the hash table; range can be calculated at low cost while doing hash table, so we get feedback on if we got this wrong. If it is predicted worthwhile, also cache an approximate lower bound (often just 0, or the time when an initial measurement was taken, or w/e); if it appears stable (how to quantify this?), speculatively start building the small-range table right away and bail out if the range estimate was wrong.
Backoff in condrange can probably skipped, simplifying and possibly speeding up slightly.