Skip to content

perf(daemon): arm the processed-map prune timer only while it has entries - #28

Merged
leinardi merged 1 commit into
masterfrom
perf/lazy-prune-timer
Sep 27, 2026
Merged

leinardi merged 1 commit into
masterfrom
perf/lazy-prune-timer

Conversation

@leinardi

Copy link
Copy Markdown
Owner

Summary

The coordinator pruned its processed map on a 60 s ticker for the daemon's whole life. The map only gets entries during a pass (startup, SIGHUP, systemd reload, reconnect), and they expire processedTTL (60 s) later. So on a quiet node the daemon woke every minute to scan an empty map.

The prune timer is now a one-shot time.After, armed by armPrune only while the map has entries, and kept (not restarted) once armed. After a pass it fires once or twice, then stays off until the next pass.

The saving is small: about 1 of the daemon's ~16 wakeups per minute at idle, measured on a production node. The daemon now only wakes at idle for its own lifecycle sweep, the Go runtime and incoming events.

  • Tests: the new TestCoordinator_PruneArmedOnlyWithEntries covers four cases:
    • no timer is armed for an empty map;
    • a timer is armed once an entry exists;
    • an armed timer is kept;
    • no timer is re-armed after a prune empties the map.
  • Docs: docs/architecture.md notes that the timer is armed only while needed.
  • Release: perf bumps no version by itself; it ships with the next release (1.0.1, via fix(processor): log symlinks leading outside /dev at debug unless allowed #27).

Pull request checklist

  • I am targeting the master branch
  • I have rebased this branch on top of the destination branch
  • I have executed make check locally before creating the commit and it has run successfully
  • I have performed a self-review of my own code
  • There are no WIP commits in this PR

Type of changes

  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Refactoring
  • 📜 Docs
  • 🧰 CI / tooling / infra
  • Other (describe in Summary): performance, fewer idle wakeups

…ries

The prune ran on a 60s ticker for the daemon's whole life, though the
processed map only gets entries during a pass and they expire 60s later.
On a quiet node that woke the daemon every minute to scan an empty map.
Arm a one-shot timer only while the map has entries: it fires once or
twice after a pass and then stays off.
@leinardi
leinardi merged commit 3ca45b8 into master Sep 27, 2026
9 checks passed
@leinardi
leinardi deleted the perf/lazy-prune-timer branch September 27, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant