]> git.hungrycats.org Git - bees/commitdiff
config: log [state] keys at startup
authorZygo Blaxell <bees@furryterror.org>
Mon, 27 Apr 2026 04:15:26 +0000 (00:15 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:03:58 +0000 (00:03 -0400)
The [state] section parses 11 config keys at startup but logged
almost none of them.  state.persistent was only logged on the inert
fallback path (when paths.home was missing), and state.point.interval
already logged from its setter — every other state.* value was silent,
so an operator running with non-default writeback timing or fsync
discipline had no way to confirm what was actually in effect.

Push the BEESLOGINFO calls into setters where setters exist
(BeesHashTable::set_create / set_resize / set_writeback_fsync /
set_writeback_unreadahead / set_close_fsync / BeesRoots::
set_checkpoint_defer), matching the existing setter-side log on
BeesRoots::set_checkpoint_interval.  The hash table setters were
inline header bodies; move them to bees-hash.cc so the log call
doesn't bloat every translation unit that includes bees.h.

Log at the bees.cc call site for the values without setters:

  state.persistent              — unconditionally, before the
                                  in-memory-vs-file-backed branch
  state.hash.size               — pretty-rendered after the rounding
                                  to the 128 KiB extent boundary
  state.hash.writeback-time     — duration in seconds
  state.hash.writeback-rate-max — pretty-rendered raw config value
  effective writeback rate      — the computed
                                  min(size / time, rate-max) that
                                  set_flush_rate() actually receives

state.point.interval's existing setter log is preserved but
reformatted to the standard "key = value [section.key]" shape.

Assisted-by: Claude-Code:claude-opus-4-7
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-hash.cc
src/bees-roots.cc
src/bees.cc
src/bees.h

index 4ca2a13d209fbeca8a32b800458961fb2991230e..d193d7567859ebca46674d5684a59e660f2349a5 100644 (file)
@@ -939,6 +939,41 @@ BeesHashTable::set_flush_rate(double bps)
        m_flush_rate_limit.rate(bps);
 }
 
+void
+BeesHashTable::set_create(bool v)
+{
+       m_create = v;
+       BEESLOGINFO("state.create = " << (v ? "yes" : "no") << " [state.create]");
+}
+
+void
+BeesHashTable::set_resize(bool v)
+{
+       m_resize = v;
+       BEESLOGINFO("state.hash.resize = " << (v ? "yes" : "no") << " [state.hash.resize]");
+}
+
+void
+BeesHashTable::set_writeback_fsync(bool v)
+{
+       m_writeback_fsync = v;
+       BEESLOGINFO("state.hash.writeback-fsync = " << (v ? "yes" : "no") << " [state.hash.writeback-fsync]");
+}
+
+void
+BeesHashTable::set_writeback_unreadahead(bool v)
+{
+       m_writeback_unreadahead = v;
+       BEESLOGINFO("state.hash.writeback-unreadahead = " << (v ? "yes" : "no") << " [state.hash.writeback-unreadahead]");
+}
+
+void
+BeesHashTable::set_close_fsync(bool v)
+{
+       m_close_fsync = v;
+       BEESLOGINFO("state.hash.close-fsync = " << (v ? "yes" : "no") << " [state.hash.close-fsync]");
+}
+
 void
 BeesHashTable::resize_file(off_t new_size)
 {
index faf2a1f24748a04656d173a29dfccebc86255af7..de85a90338e1215999bf6131e0a1ade34cbd213c 100644 (file)
@@ -1526,7 +1526,6 @@ BeesRoots::set_checkpoint_interval(double seconds)
 void
 BeesRoots::set_persistent(bool v)
 {
-       BEESLOGINFO("state persistence = " << (v ? "yes" : "no") << " [state.persistent]");
        m_roots_persistent = v;
 }
 
index 91903146319dd9ecc8866fb41523b0d42e734ab0..a3352d2cbd94f10a55b846ac290117e15935cd35 100644 (file)
@@ -561,12 +561,14 @@ bees_main(int argc, char *argv[])
        // Set up persistent state (hash table and crawl checkpoints)
        {
                const bool persistent = bc->get_config().get("state.persistent", bees_parse_bool);
+               BEESLOGINFO("state.persistent = " << (persistent ? "yes" : "no") << " [state.persistent]");
                // Round up to the next hash table extent boundary (128 KiB).
                const auto hash_size_raw = static_cast<off_t>(bc->get_config().get("state.hash.size", [&](const string &s) {
                        return bees_parse_size(bc->get_config().subst(s));
                }));
                const auto hash_size = (hash_size_raw + BLOCK_SIZE_HASHTAB_EXTENT - 1)
                                       / BLOCK_SIZE_HASHTAB_EXTENT * BLOCK_SIZE_HASHTAB_EXTENT;
+               BEESLOGINFO("state.hash.size = " << pretty(hash_size) << " [state.hash.size]");
 
                if (!persistent) {
                        // Pure in-memory mode: allocate hash table in RAM, skip all file I/O.
@@ -583,9 +585,13 @@ bees_main(int argc, char *argv[])
                        ht->set_close_fsync(bc->get_config().get("state.hash.close-fsync", bees_parse_bool));
                        // Compute effective writeback rate: min(size / writeback-time, writeback-rate-max)
                        const double writeback_time = bc->get_config().get("state.hash.writeback-time", bees_parse_duration);
+                       BEESLOGINFO("state.hash.writeback-time = " << writeback_time << "s [state.hash.writeback-time]");
                        const double writeback_rate_max = static_cast<double>(bc->get_config().get("state.hash.writeback-rate-max", bees_parse_size));
+                       BEESLOGINFO("state.hash.writeback-rate-max = " << pretty(static_cast<uint64_t>(writeback_rate_max)) << " [state.hash.writeback-rate-max]");
                        const double computed_rate = writeback_time > 0 ? static_cast<double>(hash_size) / writeback_time : writeback_rate_max;
-                       ht->set_flush_rate(min(computed_rate, writeback_rate_max));
+                       const double effective_rate = min(computed_rate, writeback_rate_max);
+                       BEESLOGINFO("state.hash: effective writeback rate = " << pretty(static_cast<uint64_t>(effective_rate)) << "/s");
+                       ht->set_flush_rate(effective_rate);
                }
                bc->start_hash_writeback();
 
index b0afb55801fac393d93d4987a1ae96d94d2df56b..92fad8edac79affd5458494b593d923d0eca2a3d 100644 (file)
@@ -795,15 +795,15 @@ public:
        /// Set writeback rate in bytes per second.
        void set_flush_rate(double bps);
        /// If false, throw at startup when beeshash.dat is absent instead of creating it.
-       void set_create(bool v) { m_create = v; }
+       void set_create(bool v);
        /// If true, rebuild the on-disk table at state.hash.size on startup (reverse-LRU merge).
-       void set_resize(bool v) { m_resize = v; }
+       void set_resize(bool v);
        /// fsync after each extent write.
-       void set_writeback_fsync(bool v) { m_writeback_fsync = v; }
+       void set_writeback_fsync(bool v);
        /// Discard hash table pages from VFS page cache after each write.
-       void set_writeback_unreadahead(bool v) { m_writeback_unreadahead = v; }
+       void set_writeback_unreadahead(bool v);
        /// fsync the hash table on close (at bees termination only).
-       void set_close_fsync(bool v) { m_close_fsync = v; }
+       void set_close_fsync(bool v);
 
 private:
        string          m_filename;