]> git.hungrycats.org Git - bees/commitdiff
hash: drop the stale lazy-fetch note from push_front_in_range
authorZygo Blaxell <bees@furryterror.org>
Sun, 23 Aug 2026 18:53:52 +0000 (14:53 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:03:58 +0000 (00:03 -0400)
The comment justified calling push_front_in_range() directly by saying
it avoids "the live mmap's lazy-fetch path (which would read from the
*old* m_fd into the *new* mapping and corrupt it)".  There is no such
path any more.  prepare() loads the whole table before any worker can
look one up, so nothing in BeesHashTable reads from the file on access;
grep finds no fetch of any kind in bees-hash.cc.

State what the function actually skips.  push_front_hash_addr() wraps
two things around the bucket mutation, and resize_into_mapping() wants
neither: the per-extent lock, which is pointless single-threaded at
startup, and set_extent_dirty_locked(), which would mark every extent
of a table it is about to write out itself and leave the writeback
thread to rewrite all of it.

Assisted-by: Claude-Code:claude-opus-5
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees.h

index cb50d162e5973819b9025e7affd6f4c7880911ed..4364299075ebab531882c3c498658939fe10c423 100644 (file)
@@ -917,12 +917,13 @@ private:
        /// present in the bucket (in which case the bucket may still have
        /// been mutated to move @p mv to the front).
        ///
-       /// This is the lock-free, fetch-free core of push_front_hash_addr.
-       /// resize_into_mapping() calls it directly to populate the new-size
-       /// mapping without dragging in the live mmap's lazy-fetch path (which
-       /// would read from the *old* m_fd into the *new* mapping and corrupt
-       /// it) or its per-extent locking (single-threaded at startup, no
-       /// locking required).
+       /// This is the bare bucket mutation, without the two things
+       /// push_front_hash_addr() wraps around it: the per-extent lock and
+       /// marking the extent dirty.  resize_into_mapping() wants neither.
+       /// It runs single-threaded at startup, so there is nothing to lock
+       /// against, and it is filling a mapping it is about to write out
+       /// itself — marking every extent dirty would leave the writeback
+       /// thread to rewrite the whole table it just persisted.
        static bool push_front_in_range(Cell *begin, Cell *end, const Cell &mv);
 
        void writeback_loop();