Skip to content

ci: Apply a consistent Cargo profile - #5133

Merged
abdnh merged 27 commits into
mainfrom
ci-rust-compile
Aug 12, 2026
Merged

ci: Apply a consistent Cargo profile#5133
abdnh merged 27 commits into
mainfrom
ci-rust-compile

Conversation

@abdnh

@abdnh abdnh commented Jul 9, 2026

Copy link
Copy Markdown
Member

Linked issue

Related: #5102 (comment)

Summary / motivation

This adds a new Cargo profile (ci) for use in all Rust build commands on CI. The goal is to reduce unnecessary recompilation of the same crates in dev/release profiles.

Steps to reproduce (before)

View the logs of the last CI run on main and notice that some crates are getting compiled with the release profile, e.g. compilation ends with "Finished release profile [optimized]".

How to test (after)

View the logs of the last CI run in this PR and confirm all Rust compilation commands end with "Finished ci profile [unoptimized]", indicating that only a single profile is being used.

Checklist (minimum)

  • I ran ./ninja check or an equivalent relevant check locally.
  • I added or updated tests when the change is non-trivial or behavior changed.

Scope

  • This PR is focused on one change (no unrelated edits).

"1" => Self::Release,
"2" => Self::ReleaseWithLto,
_ => Self::Debug,
_ => match std::env::var("CI").unwrap_or_default().as_str() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We set RELEASE=2 in the release workflow so this has no effect there.

@abdnh
abdnh marked this pull request as ready for review July 9, 2026 11:42
@abdnh
abdnh requested a review from iamllama July 9, 2026 11:43

@iamllama iamllama 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.

Changes LGTM, but i'm seeing the opposite on ubuntu: ~68s for ./check on main vs ~96s for CI=true ./check on the pr branch 🤔

@fernandolins

Copy link
Copy Markdown
Contributor

Yeah, I agree with @iamllama. The changes LGTM, but I cannot confirm that they demonstrably reduce time. Is there any way you can demonstrate an improvement with these changes?

@abdnh abdnh moved this from Backlog to In progress in Anki Projects Jul 15, 2026
@abdnh abdnh added check:macos Run macOS checks for a PR check:windows Run windows checks for a PR labels Jul 15, 2026
@abdnh abdnh added the check:linux Run Linux ARM checks for a PR label Aug 4, 2026
@abdnh

abdnh commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

@iamllama

but i'm seeing the opposite on ubuntu: ~68s for ./check on main vs ~96s for CI=true ./check on the pr branch 🤔

Do you see a meaningful difference if you set opt-level = 1 for the ci profile? Appears to be slower on CI:

@abdnh

abdnh commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

I don't see consistent differences between this PR and main however (https://github.com/ankitects/anki/actions/runs/30923778268) and I'm not sure that's possible to confirm considering how unreliable GitHub runners are.

Applying a single compilation profile though appears to work for the purpose of reducing recompilation. We could set opt-level = 1 later if it turns out tests are getting slower.

@abdnh
abdnh requested review from fernandolins and iamllama August 4, 2026 17:31
@abdnh abdnh changed the title ci: Disable Rust compile optimizations ci: Apply a consistent Cargo profile Aug 7, 2026
@iamllama

iamllama commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Do you see a meaningful difference if you set opt-level = 1 for the ci profile? Appears to be slower on CI:

It's definitely slower for me as well when run locally

For easier time comparison
@Luc-Mcgrady

Copy link
Copy Markdown
Contributor

Does incremental compilation not get used in subsequent tests? I thought it would because of actions/cache/restore but I haven't seen it practice.

@abdnh

abdnh commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Does incremental compilation not get used in subsequent tests?

It looks like it's common to disable it on CI: dtolnay/rust-toolchain#26

I thought it would because of actions/cache/restore but I haven't seen it practice.

Yeah I think something is not working here - the last run recompiled some stuff despite the commit only touching ci.yml. Maybe we should use the Swatinem/rust-cache action: #5134 (comment)

I'll revert the change for now until that's figured out.

@Luc-Mcgrady Luc-Mcgrady 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.

LGTM

@abdnh
abdnh merged commit 3c9b1da into main Aug 12, 2026
9 of 10 checks passed
@abdnh
abdnh deleted the ci-rust-compile branch August 12, 2026 07:17
@github-project-automation github-project-automation Bot moved this from In progress to Done in Anki Projects Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

check:linux Run Linux ARM checks for a PR check:macos Run macOS checks for a PR check:windows Run windows checks for a PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants