export triedb update counters as prometheus metrics - #3264
Merged
Merged
Conversation
maxkozlovsky
requested review from
Yb2411,
ariqchowdhury,
bhuan,
dhogaivannan,
dshulyak,
mhumeSF,
michael-yxchen,
omegablitz,
rtsaimonad and
xinyuan-dev
as code owners
September 15, 2026 20:38
maxkozlovsky
marked this pull request as draft
September 15, 2026 20:39
There was a problem hiding this comment.
🟡 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.
maxkozlovsky
force-pushed
the
max/triedb-stats-metrics
branch
from
September 15, 2026 21:34
b3432d0 to
c376f4f
Compare
Chen-Yifan
previously approved these changes
Sep 16, 2026
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
marked this pull request as ready for review
September 17, 2026 16:38
omegablitz
previously approved these changes
Sep 17, 2026
maxkozlovsky
dismissed stale reviews from omegablitz and Chen-Yifan
via
September 17, 2026 19:29
e579bda
maxkozlovsky
force-pushed
the
max/triedb-stats-metrics
branch
from
September 17, 2026 19:29
c376f4f to
e579bda
Compare
omegablitz
approved these changes
Sep 17, 2026
Chen-Yifan
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.