The maybe_has_expiring_keys latch only saves databases with ZERO TTL'd keys; a TTL-heavy database enters expire_cycle every 100ms just to peek the index and find nothing due. Since #549 the earliest deadline is O(log n) at the index head: expire_cycle_direct can return immediately when next_deadline > now and no lazy-expired queue is pending and the hash latch is down — making the sweep free for every database whose keys aren't due yet (compounds the #373 idle-CPU work).
Follow-on (separate decision): arm the shard timer at the head deadline instead of the fixed 100ms cadence, sharpening expiry precision and expired-notification timeliness from ≤100ms lag to near-exact.
The
maybe_has_expiring_keyslatch only saves databases with ZERO TTL'd keys; a TTL-heavy database entersexpire_cycleevery 100ms just to peek the index and find nothing due. Since #549 the earliest deadline is O(log n) at the index head:expire_cycle_directcan return immediately whennext_deadline > nowand no lazy-expired queue is pending and the hash latch is down — making the sweep free for every database whose keys aren't due yet (compounds the #373 idle-CPU work).Follow-on (separate decision): arm the shard timer at the head deadline instead of the fixed 100ms cadence, sharpening expiry precision and
expired-notification timeliness from ≤100ms lag to near-exact.