Skip to content

export triedb update counters as prometheus metrics - #3264

Merged
maxkozlovsky merged 2 commits into
masterfrom
max/triedb-stats-metrics
Sep 17, 2026
Merged

maxkozlovsky merged 2 commits into
masterfrom
max/triedb-stats-metrics

Conversation

@maxkozlovsky

Copy link
Copy Markdown
Contributor

execution writeable db publishes its stats in a shared memory area. Add code to read shared memory in monad-node and publish statistics as prometheus metrics. The file name is an argument to both monad-node and monad, both processes must agree on the name. Update debian scripts to pass the file name argument.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

monad-execution-genesis.service still omits --db-stats-file, leaving metrics unavailable in that configuration.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Triedb shared-memory update-counter metrics to monad-node, with CLI wiring and Debian service configuration.

Changes:

  • Adds Triedb statistics readers and Prometheus gauges.
  • Wires the sidecar path through CLI and node state.
  • Updates services and workspace cleanup.
File summaries
File Summary
monad-triedb-utils/src/lib.rs Re-exports Triedb statistics APIs.
monad-node/src/state.rs Stores the optional sidecar path.
monad-node/src/metrics.rs Defines and records update metrics.
monad-node/src/main.rs Reads sidecar statistics periodically.
monad-node/src/cli.rs Adds the sidecar path argument.
debian/usr/lib/systemd/system/monad-execution.service Updates execution service sidecar configuration.
debian/usr/lib/systemd/system/monad-bft.service Configures the matching node sidecar path.
debian/opt/monad/scripts/reset-workspace.sh Removes stale sidecar data.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread debian/usr/lib/systemd/system/monad-execution.service
@maxkozlovsky
maxkozlovsky force-pushed the max/triedb-stats-metrics branch from b3432d0 to c376f4f Compare September 15, 2026 21:34
Chen-Yifan
Chen-Yifan previously approved these changes Sep 16, 2026
maxkozlovsky and others added 2 commits September 16, 2026 18:36
Publish the trie update and compaction counters execution writes into its
statistics sidecar as seven gauges, refreshed on the ticker that already
refreshes the disk-usage gauges. --triedb-stats-path names the sidecar; a node
started without it exports none of them.

The counters cannot come from the triedb handle monad-node already holds:
that handle is read-only and never upserts, so every counter reachable through
it reads zero. Execution publishes them instead, which is what the submodule
bump adds.

Execution creates the sidecar when it opens its db, which can be after this
node starts, so a configured node registers the gauges up front and reopens
the file on every refresh. Registering them once the file appears would not
work: monad-node registers its gauge set once, when NodePrometheusMetrics is
built, and nothing re-registers afterwards. Reopening rather than holding the
mapping also keeps a replaced file from being read as a live one, and a
refresh that finds no sample leaves the gauges at their last values and warns
only once the misses persist.

Gauge names say which direction a copy went rather than which ring triedb
attributes it to internally, so compacted_bytes_fast_to_slow is what triedb
records as compacted_bytes_in_fast.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
--db-stats-file and --triedb-stats-path are both off by default, so a packaged
node exports no triedb update counters until the units name a path. Put it with
the other exec<->node rendezvous files in /home/monad/monad-bft: monad-node
already creates the three sockets there, both units run as monad:monad, and no
sweep in clear-old-artifacts.sh reaches it. A workspace reset clears it
alongside those sockets, closing the window where monad-node could read a file
left by the previous chain before execution takes it over and zeroes it.

Deliberately not a tmpfs under /run: a systemd RuntimeDirectory is removed when
its unit stops, so an execution restart would unlink the file under monad-node,
whose mapping would then report the last pre-restart values forever. Execution's
--help does suggest a tmpfs, and /dev/shm would satisfy that without the
unlink, but keeping the file with its siblings costs only a periodically
written 4 KiB page.

The execution unit carries a comment naming the other flag: these are the only
two values in the package that must match each other, and drift between them is
silent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@maxkozlovsky
maxkozlovsky marked this pull request as ready for review September 17, 2026 16:38
omegablitz
omegablitz previously approved these changes Sep 17, 2026
@maxkozlovsky
maxkozlovsky dismissed stale reviews from omegablitz and Chen-Yifan via e579bda September 17, 2026 19:29
@maxkozlovsky
maxkozlovsky force-pushed the max/triedb-stats-metrics branch from c376f4f to e579bda Compare September 17, 2026 19:29
@maxkozlovsky
maxkozlovsky added this pull request to the merge queue Sep 17, 2026
Merged via the queue into master with commit 543adae Sep 17, 2026
15 of 16 checks passed
@maxkozlovsky
maxkozlovsky deleted the max/triedb-stats-metrics branch September 17, 2026 20:24
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.

4 participants