-
Notifications
You must be signed in to change notification settings - Fork 182
test: track peak rss for CI state migration test #6037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRemoved internal peak-RSS memory-tracking code and CLI flag, deleted the MemStatsTracker module and monitoring re-exports, removed the memory-stats dependency, updated docs and changelog, and replaced internal tracking in tests and helper scripts with external measurement by prefixing invocations with Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant Forest as forest
participant MemTracker as MemStatsTracker
participant TimeTool as /usr/bin/time -v
rect #f0f9ff
Note over User,Forest: Old flow — internal peak RSS tracking
User->>Forest: start forest --track-peak-rss ...
Forest->>MemTracker: spawn tracker
MemTracker-->>MemTracker: sample memory periodically
MemTracker-->>Forest: emit peak on drop
end
rect #fff7f0
Note over User,TimeTool: New flow — external resource measurement
User->>TimeTool: /usr/bin/time -v forest ...
TimeTool->>Forest: exec forest
TimeTool-->>User: verbose resource report on exit
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
✨ Finishing Touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
scripts/tests/calibnet_migration_regression_tests.sh (3)
10-10: Make command composition safer using an array (optional)Using a string for a long command is brittle (word-splitting, future args with spaces). An array is safer.
Apply this diff for the definition:
- M I G R A T I O N _ T E S T ="$FOREST_PATH --chain calibnet --encrypt-keystore false --track-peak-rss --halt-after-import --height=-200 --no-gc --import-snapshot" + MIGRATION_TEST=( "$FOREST_PATH" --chain calibnet --encrypt-keystore false --track-peak-rss --halt-after-import --height=-200 --no-gc --import-snapshot )Then invoke with:
# replace: $MIGRATION_TEST "URL" "${MIGRATION_TEST[@]}" "URL"
10-10: Optional: gate the flag via env for local runsIf you want CI to always track RSS but keep local runs quiet, gate the flag via env without changing call sites.
Minimal change:
-MIGRATION_TEST="$FOREST_PATH --chain calibnet --encrypt-keystore false --track-peak-rss --halt-after-import --height=-200 --no-gc --import-snapshot" +MIGRATION_TEST="$FOREST_PATH --chain calibnet --encrypt-keystore false ${TRACK_PEAK_RSS:+--track-peak-rss} --halt-after-import --height=-200 --no-gc --import-snapshot"Usage:
- In CI: export TRACK_PEAK_RSS=1
- Locally (default): omit to skip the flag
10-10: Surface a one-line metric for CI consumption (nice-to-have)Consider extracting and emitting a single “Peak RSS” line per run to aid trend tracking in job logs.
Example wrapper (no behavior change to the test result):
# After each invocation: # ${MIGRATION_TEST[@]} "$URL" | tee /dev/stderr | rg -i 'Peak physical memory usage' || trueThis keeps full logs while surfacing the metric.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
scripts/tests/calibnet_migration_regression_tests.sh(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: hanabi1224
PR: ChainSafe/forest#5930
File: build.rs:64-77
Timestamp: 2025-08-13T09:43:20.301Z
Learning: hanabi1224 prefers hard compile-time errors in build scripts rather than runtime safeguards or collision detection, believing it's better to fail fast and fix root causes of issues like malformed snapshot names.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build forest binaries on Linux AMD64
- GitHub Check: tests-release
- GitHub Check: tests
🔇 Additional comments (1)
scripts/tests/calibnet_migration_regression_tests.sh (1)
10-10: LGTM: enabling peak RSS tracking for migration testsAdding
--track-peak-rsstoMIGRATION_TESTis straightforward and aligns with the PR goal.
|
|
||
| FOREST_PATH="forest" | ||
| MIGRATION_TEST="$FOREST_PATH --chain calibnet --encrypt-keystore false --halt-after-import --height=-200 --no-gc --import-snapshot" | ||
| MIGRATION_TEST="$FOREST_PATH --chain calibnet --encrypt-keystore false --track-peak-rss --halt-after-import --height=-200 --no-gc --import-snapshot" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify CLI flag availability to avoid CI breakage
Please confirm the forest binary in CI exposes --track-peak-rss; otherwise set -e will fail the job on unknown-flag errors.
Run from repo root:
🏁 Script executed:
#!/bin/bash
# Check the CLI defines the flag (clap/arg names, help text, etc.)
rg -nC3 -i --type=rust 'track-peak-rss|peak.*rss|--track-peak-rss'
# If the binary is available in PATH in CI, also inspect help output (non-fatal if missing):
command -v forest >/dev/null && forest --help | rg -n -i 'track-peak-rss|peak.*rss' || trueLength of output: 1484
Ensure CI uses an updated forest binary with --track-peak-rss support
The code’s CLI derive in cli_shared/cli/mod.rs already defines the track_peak_rss flag (kebab-case --track-peak-rss), but the forest binary on PATH (used in CI) does not advertise that flag in its --help output. Update your CI setup to point $FOREST_PATH at a build of forest that includes this flag (or add a version check) to prevent unknown-flag errors and pipeline failures.
🤖 Prompt for AI Agents
In scripts/tests/calibnet_migration_regression_tests.sh around line 10, the CI
invokes $FOREST_PATH with the --track-peak-rss flag which the binary on PATH in
CI may not support; update CI to point $FOREST_PATH at a build of forest that
includes the cli_shared/cli/mod.rs track_peak_rss flag (rebuild forest from the
current repo/commit and export its path), or add a pre-check in CI that runs
`$FOREST_PATH --help` (or `--version`) to assert support for `--track-peak-rss`
and fail with a clear message if absent so the pipeline doesn’t pass an unknown
flag to the binary.
Pull request was converted to draft
LesnyRumcajs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
scripts/tests/calibnet_db_migration.sh (3)
45-45: Stream time -v to a log file for later parsing (keeps console output too).This makes peak RSS easy to grep from CI artifacts.
-/usr/bin/time -v forest --chain calibnet --log-dir "$LOG_DIRECTORY" --halt-after-import --config "${CONFIG_FILE}" +/usr/bin/time -v forest --chain calibnet --log-dir "$LOG_DIRECTORY" --halt-after-import --config "${CONFIG_FILE}" 2> >(tee -a "$LOG_DIRECTORY/peak_rss_migration_import.log" >&2)
48-48: Do the same for the long-running sync phase.Captures the backgrounded run’s peak RSS reliably in logs.
-/usr/bin/time -v forest --chain calibnet --log-dir "$LOG_DIRECTORY" --save-token ./admin_token --config "${CONFIG_FILE}" & +/usr/bin/time -v forest --chain calibnet --log-dir "$LOG_DIRECTORY" --save-token ./admin_token --config "${CONFIG_FILE}" 2> >(tee -a "$LOG_DIRECTORY/peak_rss_migration_sync.log" >&2) &
45-48: Optional: add a fallback if /usr/bin/time is unavailable.CI is Linux, but a small guard improves portability.
Example outside this hunk:
time_wrap() { if command -v /usr/bin/time >/dev/null; then /usr/bin/time -v "$@"; else "$@"; fi; } # then replace: /usr/bin/time -v forest ... => time_wrap forest ...scripts/tests/harness.sh (1)
91-91: Capture time -v output to logs and keep console visibility.Eases automated parsing of peak RSS from CI logs.
- /usr/bin/time -v $FOREST_PATH --chain calibnet --encrypt-keystore false --log-dir "$LOG_DIRECTORY" & + /usr/bin/time -v "$FOREST_PATH" --chain calibnet --encrypt-keystore false --log-dir "$LOG_DIRECTORY" 2> >(tee -a "$LOG_DIRECTORY/peak_rss_node_run.log" >&2) &
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (11)
CHANGELOG.md(1 hunks)Cargo.toml(0 hunks)docs/docs/users/reference/cli.md(0 hunks)scripts/tests/calibnet_db_migration.sh(1 hunks)scripts/tests/calibnet_migration_regression_tests.sh(1 hunks)scripts/tests/harness.sh(1 hunks)src/cli_shared/cli/mod.rs(0 hunks)src/daemon/mod.rs(1 hunks)src/utils/mod.rs(0 hunks)src/utils/monitoring/mem_tracker.rs(0 hunks)src/utils/monitoring/mod.rs(0 hunks)
💤 Files with no reviewable changes (6)
- src/cli_shared/cli/mod.rs
- src/utils/mod.rs
- docs/docs/users/reference/cli.md
- src/utils/monitoring/mod.rs
- Cargo.toml
- src/utils/monitoring/mem_tracker.rs
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
- scripts/tests/calibnet_migration_regression_tests.sh
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: hanabi1224
PR: ChainSafe/forest#5930
File: build.rs:64-77
Timestamp: 2025-08-13T09:43:20.301Z
Learning: hanabi1224 prefers hard compile-time errors in build scripts rather than runtime safeguards or collision detection, believing it's better to fail fast and fix root causes of issues like malformed snapshot names.
📚 Learning: 2025-08-08T12:10:45.218Z
Learnt from: hanabi1224
PR: ChainSafe/forest#5867
File: src/ipld/util.rs:553-558
Timestamp: 2025-08-08T12:10:45.218Z
Learning: Forest project targets Rust stable >=1.89; features stabilized in 1.88 like let-chains are acceptable in this codebase.
Applied to files:
src/daemon/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build forest binaries on Linux AMD64
- GitHub Check: tests
- GitHub Check: tests-release
🔇 Additional comments (2)
src/daemon/mod.rs (2)
31-31: LGTM: imports updated after removing internal mem tracking.Consolidated utils imports; no lingering references here.
31-31: Cleanup verified – no leftover feature flags or memory tracker symbols
Repo-wide search found no instances of--track-peak-rss,MemStatsTracker, or monitoring modules;/usr/bin/time -vwrappers exist only in test scripts as intended.
…-migration-ci-tests
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Summary by CodeRabbit