Skip to content

chore(jans-cedarling): improve wasm optimization build flags#14202

Merged
haileyesus2433 merged 2 commits into
mainfrom
jans-cedarling-14200
Jun 3, 2026
Merged

chore(jans-cedarling): improve wasm optimization build flags#14202
haileyesus2433 merged 2 commits into
mainfrom
jans-cedarling-14200

Conversation

@olehbozhok

@olehbozhok olehbozhok commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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:

  • jans-cedarling/Cargo.toml: restored default opt-level = 3 for native speed. Removed codegen-units = 1.
  • bindings/cedarling_wasm/.cargo/config.toml (new): config-based [profile.release] overriding opt-level = "z", lto = "fat", codegen-units = 1, strip = true. Cargo applies this only when building from the cedarling_wasm directory (i.e. under wasm-pack).
  • bindings/cedarling_wasm/Cargo.toml: moved wasm-opt flags to -Oz (aggressive size) and added required feature flags (bulk-memory, nontrapping-float-to-int, sign-ext, mutable-globals, multivalue) so fat-LTO output passes wasm-opt validation.
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

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

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.

  • I confirm that there is no impact on the docs due to the code changes in this PR.

Summary by CodeRabbit

  • Chores
    • Refined build configurations to separate native speed-optimized releases from WebAssembly size-optimized releases, improving WASM package size and build outputs.
  • Documentation
    • Added clarifying comments explaining which release profiles apply for workspace vs WASM crate builds.

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>
@olehbozhok olehbozhok self-assigned this Jun 3, 2026
@olehbozhok olehbozhok requested review from duttarnab and haileyesus2433 and removed request for haileyesus2433 June 3, 2026 15:51
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: caa46a66-b28c-440f-b85b-08b8c1eec02d

📥 Commits

Reviewing files that changed from the base of the PR and between 1d761a3 and 48eaa86.

📒 Files selected for processing (1)
  • jans-cedarling/bindings/cedarling_wasm/.cargo/config.toml

📝 Walkthrough

Walkthrough

Cargo release profile was simplified at the workspace root; a crate-scoped .cargo/config.toml was added for bindings/cedarling_wasm to apply size/LTO/strip settings, and the crate's wasm-opt args were updated to -Oz plus required feature flags for LTO output.

Changes

WASM Compiler Optimization Fix

Layer / File(s) Summary
Workspace profile rationalization
jans-cedarling/Cargo.toml
Root [profile.release] is simplified to only debug-assertions = false, with comments documenting native vs WASM optimization intent.
WASM-specific optimization implementation
jans-cedarling/bindings/cedarling_wasm/.cargo/config.toml, jans-cedarling/bindings/cedarling_wasm/Cargo.toml
Adds .cargo/config.toml scoped to the WASM crate applying opt-level = "z", lto = "fat", codegen-units = 1, and strip = true. Updates package.metadata.wasm-pack.profile.release.wasm-opt to -Oz and enables feature flags (--enable-reference-types, --enable-bulk-memory, --enable-nontrapping-float-to-int, --enable-sign-ext, --enable-mutable-globals, --enable-multivalue).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

Suggested labels

kind-feature, comp-jans-cedarling

Suggested reviewers

  • dagregi
  • haileyesus2433
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: improving WASM optimization build flags through profile and config reorganization.
Description check ✅ Passed The PR description follows the template with all required sections completed: preparation checklist marked, target issue linked (#14200), implementation details provided with problem/solution analysis, and docs impact confirmed.
Linked Issues check ✅ Passed The PR fully addresses issue #14200 requirements: moves LTO and strip to a config-based profile in .cargo/config.toml, updates wasm-opt flags to -Oz with required feature enables, and restores speed-oriented native builds (opt-level=3).
Out of Scope Changes check ✅ Passed All changes are in scope: workspace profile adjustments, new WASM-specific config file, and WASM Cargo.toml updates directly support the stated goal of fixing optimizer flag application without removing features.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jans-cedarling-14200

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.

@mo-auto

mo-auto commented Jun 3, 2026

Copy link
Copy Markdown
Member

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@olehbozhok olehbozhok requested review from dagregi and removed request for duttarnab June 3, 2026 15:52
@coderabbitai coderabbitai Bot added kind-feature Issue or PR is a new feature request comp-jans-cedarling Touching folder /jans-cedarling labels Jun 3, 2026
@olehbozhok olehbozhok changed the title feat(jans-cedarling): improve wasm optimization build flags chore(jans-cedarling): improve wasm optimization build flags Jun 3, 2026
@mo-auto mo-auto added the kind-dependencies Pull requests that update a dependency file label Jun 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between cf125e2 and 1d761a3.

📒 Files selected for processing (3)
  • jans-cedarling/Cargo.toml
  • jans-cedarling/bindings/cedarling_wasm/.cargo/config.toml
  • jans-cedarling/bindings/cedarling_wasm/Cargo.toml

Comment thread jans-cedarling/bindings/cedarling_wasm/.cargo/config.toml
Comment thread jans-cedarling/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>
@haileyesus2433 haileyesus2433 merged commit 3dc4c49 into main Jun 3, 2026
3 checks passed
@haileyesus2433 haileyesus2433 deleted the jans-cedarling-14200 branch June 3, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-jans-cedarling Touching folder /jans-cedarling kind-dependencies Pull requests that update a dependency file kind-feature Issue or PR is a new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(jans-cedarling): improve wasm optimization build flags

4 participants