Skip to content

chore: port build profile gradient from tempo#102

Closed
panos-xyz wants to merge 4 commits intomainfrom
chore/port-tempo-build-profiles
Closed

chore: port build profile gradient from tempo#102
panos-xyz wants to merge 4 commits intomainfrom
chore/port-tempo-build-profiles

Conversation

@panos-xyz
Copy link
Copy Markdown
Contributor

@panos-xyz panos-xyz commented Apr 23, 2026

Summary

morph-reth's root Cargo.toml previously defined no [profile.*] overrides, so release builds fell back to Cargo defaults (lto = off) — worse than even upstream reth's own release. This PR mirrors the profile shape used by the sibling tempo project and aligns the Dockerfile, release workflow, and EC2 deploy Makefile so that every shipped artifact uses an intentional profile.

Commit-by-commit:

  1. chore(evm): silence clippy unnecessary_sort_by in curie.rs test — pre-existing clippy 1.95 error on main that blocks the CI lint job. Cherry-picked from the dev branch. Independent fix, kept first so the rest of the PR can pass lint.
  2. chore(cargo): port build profile gradient from tempo — adds dev / hivetests / release / profiling / bench / maxperf with the exact settings tempo uses. No changes to [workspace.lints] (already matches tempo).
  3. chore(docker): default BUILD_PROFILE to profiling — production Docker images now default to profiling (release + line-table symbols) so they remain flame-graphable. Override with --build-arg BUILD_PROFILE=maxperf or release.
  4. ci(release): parameterize cargo profile; default tag-push to maxperf — release workflow no longer hardcodes target/.../release/. Push-tag triggers use maxperf for peak throughput; workflow_dispatch exposes a profile input (default profiling). MakefileEc2.mk default also flips to profiling to match the Dockerfile, so S3-deployed EC2 binaries stay flame-graphable in prod.

Profile choice matrix (after this PR)

Artifact Profile Reason
make build (local dev) release (unchanged) Fast link, good iteration loop
Docker images (ghcr.io/.../morph-reth) profiling Flame-graphable prod; near-zero runtime cost vs release
S3-deployed EC2 binaries (MakefileEc2.mk) profiling Consistency with Docker for prod debugging
GitHub Release tarballs (tag push) maxperf Peak throughput for public consumers
GitHub Release tarballs (manual dispatch) profiling (user-selectable) Flame-graphable debug artifacts

Test plan

  • cargo metadata parses with new profile section
  • cargo fmt --all -- --check passes
  • cargo clippy --all --all-targets -- -D warnings passes (curie fix lands first)
  • cargo check --profile profiling --bin morph-reth builds cleanly
  • CI lint / test / build workflows green on the PR
  • Dry-run release via workflow_dispatch with default profile=profiling produces a valid tarball
  • Follow-up: also verify a maxperf dispatch run once ready to cut a tag

Non-goals / deliberately skipped

  • Lints section is untouched. [workspace.lints] already matches tempo; no changes.
  • Makefile default PROFILE ?= release is unchanged. Daily make build / make test / make lint behave identically to today. Only the release pipeline and EC2 deploy override the default.
  • Did not port upstream paradigmxyz/reth's clippy nursery (too aggressive for this codebase; ~120 findings without much benefit).

Summary by CodeRabbit

  • Chores
    • Updated build configuration with new Cargo profiles supporting different optimization levels and debugging requirements.
    • Changed default build profile from release to profiling for improved debuggability in production environments while maintaining performance.
    • Added configurable build profile selection for Docker and release workflows.

Clippy 1.95 reports `storage.sort_by(|(a, _), (b, _)| a.cmp(b))` as
a `clippy::unnecessary_sort_by` (prefer `sort_by_key`) in the
`apply_curie_hard_fork` test. The fix is the clippy-suggested rewrite.

No behavioural change; only the test's sort comparator is reshaped.
morph-reth's root Cargo.toml previously defined no [profile.*] overrides,
so release builds fell back to Cargo defaults (lto=off). Adopt the same
profile shape used by the sibling `tempo` project:

- profile.dev:      line-tables-only debug, unpacked split-debuginfo.
- profile.hivetests: opt-level=3 + lto=thin, inherits test (debug_assert on).
- profile.release:   opt-level=3, lto=thin, strip=symbols, codegen-units=16.
- profile.profiling: release + line-table debug + strip=none + incremental
                     — production binaries that still flamegraph cleanly.
- profile.bench:     inherits profiling.
- profile.maxperf:   release + lto=fat + codegen-units=1 for peak throughput
                     (expect a noticeably longer link stage).
Match the tempo project's convention: production container images default
to the `profiling` profile, which is release-grade (opt-level=3, lto=thin,
codegen-units=16) but keeps line-table debug symbols and skips stripping.
That preserves flame graphs and backtraces in prod at near-zero runtime
cost.

Override with `--build-arg BUILD_PROFILE=maxperf` for peak throughput
(fat LTO + codegen-units=1, much slower link) or `BUILD_PROFILE=release`
for the stripped/symbolless variant.
Previously the release workflow hardcoded `target/<target>/release/` when
packaging tarballs, which coupled it to the Makefile's `release` default
and silently broke if either was overridden.

Changes:
- Add a `profile` workflow_dispatch input (default `profiling`, with
  `maxperf` and `release` as alternatives). Push-tag triggers keep
  defaulting to `maxperf` for peak throughput on public releases.
- Resolve the profile in a dedicated step and thread it through both
  `make build-<target>` (via PROFILE=) and the subsequent `cp` path
  (using the computed `profile_dir`, which handles Cargo's dev→debug
  naming quirk).
- Update `MakefileEc2.mk` default PROFILE to `profiling` so S3-deployed
  EC2 binaries match the Dockerfile default — shipped prod artifacts
  keep line-table symbols for flame graphs.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

This PR introduces multiple customizable Cargo build profiles (profiling, bench, maxperf, etc.) in Cargo.toml with specific optimization, debug info, and LTO settings. CI/CD workflows and container/build defaults are updated to use the new profiling profile as the default, while supporting manual profile selection via GitHub Actions workflow dispatch.

Changes

Cohort / File(s) Summary
Build Profile Configuration
Cargo.toml
Adds six custom Cargo build profiles: dev (split debuginfo), hivetests (test + release opts), release (optimized, stripped), profiling (release + line-table debug), bench (inherits profiling), and maxperf (release + fat LTO).
CI/CD Release Workflow
.github/workflows/release.yml
Introduces selectable Cargo profile input for manual workflow runs (defaults to profiling); tag pushes default to maxperf. Profile is resolved and passed to build and packaging steps with profile-specific target directory logic.
Container and Build Defaults
Dockerfile, MakefileEc2.mk
Updates default build profile from release to profiling in both files; adds documentation explaining line-table symbol preservation for production debugging and flame-graphing.
Test Refinement
crates/evm/src/block/curie.rs
Simplifies test sorting logic by replacing manual comparator with sort_by_key on slot values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • chengwenxi
  • anylots

Poem

🐰 Profiles multiplied with care so fine,
From profiling to maxperf they align,
Line tables dance in production's light,
While CI flows choose the perfect might!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'chore: port build profile gradient from tempo' accurately summarizes the main change: porting build profiles from the tempo project. The term 'gradient' in the title refers to the multiple build profiles (dev, hivetests, release, profiling, bench, maxperf) being ported together.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/port-tempo-build-profiles

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Cargo.toml`:
- Around line 46-52: The comment above the [profile.dev] section is stale—update
the text to explain that this active profile reduces debug info and that
developers who need full debugger support should override it locally (for
example by removing or changing debug = "line-tables-only" or setting
split-debuginfo) rather than “uncommenting”; modify the comment near the
[profile.dev] header in Cargo.toml to clearly state it is an active local
override that can be changed for full debugger fidelity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c93792a-bdb4-4de5-9356-7f14ffefaef2

📥 Commits

Reviewing files that changed from the base of the PR and between faec4c8 and 7e0f1cb.

📒 Files selected for processing (5)
  • .github/workflows/release.yml
  • Cargo.toml
  • Dockerfile
  • MakefileEc2.mk
  • crates/evm/src/block/curie.rs

Comment thread Cargo.toml
Comment on lines +46 to +52
# Speed up compilation time for dev builds by reducing emitted debug info.
# NOTE: Debuggers may provide less useful information with this setting.
# Uncomment this section if you're using a debugger.
[profile.dev]
# https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html
debug = "line-tables-only"
split-debuginfo = "unpacked"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Update the stale debugger comment.

Line 48 says to “Uncomment this section”, but [profile.dev] is already active. Reword it to describe the local override needed for full debugger support.

Suggested wording
 # Speed up compilation time for dev builds by reducing emitted debug info.
 # NOTE: Debuggers may provide less useful information with this setting.
-# Uncomment this section if you're using a debugger.
+# Use `debug = "full"` locally if you need full variable-level debugger support.
 [profile.dev]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Speed up compilation time for dev builds by reducing emitted debug info.
# NOTE: Debuggers may provide less useful information with this setting.
# Uncomment this section if you're using a debugger.
[profile.dev]
# https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html
debug = "line-tables-only"
split-debuginfo = "unpacked"
# Speed up compilation time for dev builds by reducing emitted debug info.
# NOTE: Debuggers may provide less useful information with this setting.
# Use `debug = "full"` locally if you need full variable-level debugger support.
[profile.dev]
# https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html
debug = "line-tables-only"
split-debuginfo = "unpacked"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Cargo.toml` around lines 46 - 52, The comment above the [profile.dev] section
is stale—update the text to explain that this active profile reduces debug info
and that developers who need full debugger support should override it locally
(for example by removing or changing debug = "line-tables-only" or setting
split-debuginfo) rather than “uncommenting”; modify the comment near the
[profile.dev] header in Cargo.toml to clearly state it is an active local
override that can be changed for full debugger fidelity.

@panos-xyz
Copy link
Copy Markdown
Contributor Author

Superseded — see forthcoming replacement PR that bundles the Docker/EC2 maxperf switch directly into the profile port.

@panos-xyz panos-xyz closed this Apr 24, 2026
@panos-xyz panos-xyz deleted the chore/port-tempo-build-profiles branch April 24, 2026 02: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