chore(jans-cedarling): improve wasm optimization build flags#14202
Conversation
Move size-oriented release settings (opt-level = "z", lto = "fat", etc.) from workspace [profile.release] into a per-directory config-based profile under bindings/cedarling_wasm/.cargo/config.toml, so WASM builds stay size-optimized while native builds get speed optimization (opt-level = 3). Signed-off-by: Oleh Bozhok <6554798+olehbozhok@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughCargo release profile was simplified at the workspace root; a crate-scoped ChangesWASM Compiler Optimization Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@jans-cedarling/bindings/cedarling_wasm/.cargo/config.toml`:
- Around line 20-24: Update the top-of-file comment in
bindings/cedarling_wasm/.cargo/config.toml (lines referencing the profile
behavior) to remove the stale claim that the workspace sets opt-level = 3 and
instead state that Cargo overlays .cargo/config.toml onto the workspace profile
and this file sets opt-level = "z" for the release profile; also mention that
debug-assertions and overflow-checks are inherited from the workspace Cargo.toml
and that wasm-pack build --release uses Cargo’s profile handling so the local
.cargo/config.toml will be honored when building from this directory.
In `@jans-cedarling/Cargo.toml`:
- Around line 36-43: The comment notes a mismatch between the prose and the
actual [profile.release] keys: add an explicit opt-level entry to the release
profile to make native behavior unambiguous. Update the [profile.release] block
in Cargo.toml by adding opt-level = 3 (or alternatively revise the surrounding
comment to refer to Cargo’s default opt-level) so that the release profile in
this file explicitly documents the optimization level rather than implying it.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b35cacda-9ffc-4bc8-a495-a1ad154e679a
📒 Files selected for processing (3)
jans-cedarling/Cargo.tomljans-cedarling/bindings/cedarling_wasm/.cargo/config.tomljans-cedarling/bindings/cedarling_wasm/Cargo.toml
Remove incorrect claim that workspace sets opt-level=3; workspace only sets debug-assertions and overflow-checks. Clarify overlay semantics, that opt-level="z" applies under wasm-pack, and that wasm-pack build --release honors local .cargo/config.toml. Signed-off-by: Oleh Bozhok <6554798+olehbozhok@users.noreply.github.com>
Move size-oriented release settings (opt-level = "z", lto = "fat", etc.) from workspace [profile.release] into a per-directory config-based profile under bindings/cedarling_wasm/.cargo/config.toml, so WASM builds stay size-optimized while native builds get speed optimization (opt-level = 3).
Prepare
Description
Target issue
closes #14200
Implementation Details
Problem
The workspace [profile.release] in jans-cedarling/Cargo.toml used opt-level = "z", codegen-units = 1, and no LTO — all size-oriented settings. This applied to all release builds regardless of target, meaning native binding builds (Java, Python, Go, Uniffi) were unintentionally size-optimized instead of speed-optimized.
Solution
Split release profiles:
Why not custom profile + wasm-pack --profile
wasm-pack 0.14 ignores wasm-opt metadata for custom profile names, breaking --enable-* features.
Why config-based profile instead of [profile.*] in member Cargo.toml
Cargo silently ignores [profile.*] in non-root workspace members. Config-based profiles (.cargo/config.toml) are honored and merge over workspace root settings.
Test and Document the changes
Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with
docs:to indicate documentation changes or if the below checklist is not selected.Summary by CodeRabbit