Skip to content

[build] Refine thinLTO configuration - #8127

Open
fhanau wants to merge 2 commits into
mainfrom
felix/102726-rust-cfi
Open

fhanau wants to merge 2 commits into
mainfrom
felix/102726-rust-cfi

Conversation

@fhanau

@fhanau fhanau commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

We're changing how thinLTO works downstream by using the native thin_lto feature, which means that the cpu:2 tags will actually be counterproductive. Also add a custom feature to identify tests so we can set backend flags for them.

[build] Disable thinLTO for gen-compile-cache in downstream build

See downstream PR (to follow) for more context.

@fhanau
fhanau requested review from a team as code owners November 1, 2026 22:18

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of baaad4dd.

This review, of 0629eefc

💬 Approved with comments — Nothing here is unsafe to merge. The two findings are an INFO about inconsistent cpu:2 and feature handling across the test macros, and a QUESTION about dropping the high-cpu runner property.

Findings: 1 question · 1 info

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: ❓ 1 question · 1 info

The ThinLTO scheduling cleanup reaches only some targets, and dropping runner: high-cpu has no stated reason.

Recommendation: 💬 Optional Nits

  • [QUESTION] This removes exec_properties = {"runner": "high-cpu"} and cpu:4 from wd_cc_binary and wd_rust_binary, including the fully optimized linkopts_tool links. Is it intended that these links no longer request the high-CPU runner? (build/wd_rust_binary.bzl:137)
  • [INFO] Some linkopts_default targets still carry the cpu:2 tag the description calls counterproductive: kj_test, wd_rust_test, wd_cc_benchmark, wd_rust_proc_macro and jsg-bench. The wd_cc_benchmark and wd_rust_proc_macro test targets also don't get LINKOPTS_DEFAULT_FEATURES. The three test macros now handle this inconsistently. (build/kj_test.bzl:33)
View full review

cpu:2 and the feature are applied unevenly

The description says the cpu:2 tags are counterproductive once the native thin_lto feature is used. The tag is gone from the wd_rust_binary test target, but it is still set in these places:

  • build/kj_test.bzl:33, right below the line that adds LINKOPTS_DEFAULT_FEATURES
  • build/wd_rust_test.bzl:39
  • build/wd_cc_benchmark.bzl:31
  • build/wd_rust_proc_macro.bzl:49
  • src/rust/jsg-bench/BUILD.bazel:39

The test targets of wd_cc_benchmark and wd_rust_proc_macro also link linkopts_default, but they don't get LINKOPTS_DEFAULT_FEATURES. Downstream backend tuning won't reach them. If they are left out on purpose, a comment in build/linking.bzl would make that clear.

exec_properties = {"runner": "high-cpu"} removed

wd_cc_binary and wd_rust_binary no longer set the high-CPU runner property or the cpu:4 tag. That includes the linkopts_tool links, such as the workerd binary, which are fully optimized. This changes where those links are scheduled in remote-execution setups. The description only discusses cpu:2.


✅ All other checks passed

📝 Documentation: ✅ LGTM

The new comments in build/linking.bzl and src/rust/gen-compile-cache/BUILD.bazel describe the features as they are used, and the new features argument of wd_rust_binary is documented.


Reviewed commit: 0629eefc

@codecov-commenter

codecov-commenter commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.40%. Comparing base (e777644) to head (b4c6d04).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8127      +/-   ##
==========================================
+ Coverage   68.31%   68.40%   +0.08%     
==========================================
  Files         726      728       +2     
  Lines      189670   190456     +786     
  Branches    29672    29790     +118     
==========================================
+ Hits       129577   130280     +703     
- Misses      42719    42722       +3     
- Partials    17374    17454      +80     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fhanau
fhanau force-pushed the felix/102726-rust-cfi branch from 0629eef to baaad4d Compare November 1, 2026 23:20

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 4657ec80.

This review, of baaad4dd

💬 Approved with comments — Nothing here is unsafe to merge. The earlier note about uneven cpu:2 and feature handling is fixed. What's left is a QUESTION about dropping the high-CPU runner property and an INFO about how removing cpu:2 changes test packing on remote executors.

Findings: 1 question · 1 info

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: ❓ 1 question · 1 info

The earlier note about uneven cpu:2 and feature handling is fixed. The question about the high-CPU runner is still open, and there is one INFO about test scheduling.

Recommendation: 💬 Optional Nits

  • [QUESTION] This removes exec_properties = {"runner": "high-cpu"} and cpu:4 from wd_cc_binary and wd_rust_binary. That property applied to every action of the target, including the rustc compile and the fully optimized linkopts_tool links such as workerd. Is it intended that these targets no longer request the high-CPU runner? (build/wd_rust_binary.bzl:137)
  • [INFO] Removing cpu:2 also removes the test.slots = "1" property that test_exec_properties (build/bazelflare/exec_properties.bzl:17) gives to tests with a cpu: tag. Medium-size C++ and Rust tests can now share a four-vCPU executor, up to four at a time. The description doesn't mention this change in scheduling. (build/kj_test.bzl:33)
View full review

🔄 Since last review: 1 finding resolved, 1 preserved, 1 new

Fixed: uneven cpu:2 and feature handling. cpu:2 is gone from kj_test, wd_rust_test, wd_cc_benchmark, wd_rust_proc_macro and the wd_rust_binary test target. All of them now add LINKOPTS_DEFAULT_FEATURES. wd_rust_binary adds the feature only when tool is false, which matches its choice between linkopts_default and linkopts_tool. The one cpu:2 left is on the smoke-test sh_test in src/rust/jsg-bench/BUILD.bazel. That target doesn't link with linkopts_default, so it needs no change.

Still open: the high-CPU runner. See build/wd_rust_binary.bzl and build/wd_cc_binary.bzl. The removed exec_properties = {"runner": "high-cpu"} applied to every action of the target, not only the link. For wd_rust_binary that includes the rustc compile. Binaries built with linkopts_tool, such as workerd, also lose the cpu:4 tag. The description only discusses cpu:2.

Test packing on remote executors. test_exec_properties in build/bazelflare/exec_properties.bzl:17 gives test.slots = "1" to any test that has a cpu: tag. Without cpu:2, medium-size kj_test, wd_rust_test, proc-macro and rust_test targets can now share a four-vCPU executor, up to four at a time. Before, each test had an executor to itself. This may be the intended effect, but the description doesn't mention it.


✅ All other checks passed

📝 Documentation: ✅ LGTM

The new comments in build/linking.bzl and src/rust/gen-compile-cache/BUILD.bazel match how the features are used.


Reviewed commit: baaad4dd

@fhanau

fhanau commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Re. the LLM questions – those changes are deliberate, the high-CPU runner is no longer needed with the downstream changes.

@fhanau
fhanau force-pushed the felix/102726-rust-cfi branch from baaad4d to 4657ec8 Compare November 2, 2026 02:15

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of b4c6d04b.

This review, of 4657ec80

💬 Approved with comments — Nothing here is unsafe to merge. The earlier note about uneven cpu:2 and feature handling is fixed. What's left is a QUESTION about dropping the high-CPU runner property and an INFO about how removing cpu:2 changes test packing on remote executors.

Findings: 1 question · 1 info

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: ❓ 1 question · 1 info

The earlier note about uneven cpu:2 and feature handling is fixed. The question about the high-CPU runner is still open, and there is one INFO about test scheduling.

Recommendation: 💬 Optional Nits

  • [QUESTION] This removes exec_properties = {"runner": "high-cpu"} and cpu:4 from wd_cc_binary and wd_rust_binary. That property applied to every action of the target, including the rustc compile and the fully optimized linkopts_tool links such as workerd. Is it intended that these targets no longer request the high-CPU runner? (build/wd_rust_binary.bzl:137)
  • [INFO] Removing cpu:2 also removes the test.slots = "1" property that test_exec_properties (build/bazelflare/exec_properties.bzl:17) gives to tests with a cpu: tag. Medium-size C++ and Rust tests can now share a four-vCPU executor, up to four at a time. The description doesn't mention this change in scheduling. (build/kj_test.bzl:33)
View full review

🔄 Since last review: 1 finding resolved, 1 preserved, 1 new

Fixed: uneven cpu:2 and feature handling. cpu:2 is gone from kj_test, wd_rust_test, wd_cc_benchmark, wd_rust_proc_macro and the wd_rust_binary test target. All of them now add LINKOPTS_DEFAULT_FEATURES. wd_rust_binary adds the feature only when tool is false, which matches its choice between linkopts_default and linkopts_tool. The one cpu:2 left is on the smoke-test sh_test in src/rust/jsg-bench/BUILD.bazel. That target doesn't link with linkopts_default, so it needs no change.

Still open: the high-CPU runner. See build/wd_rust_binary.bzl and build/wd_cc_binary.bzl. The removed exec_properties = {"runner": "high-cpu"} applied to every action of the target, not only the link. For wd_rust_binary that includes the rustc compile. Binaries built with linkopts_tool, such as workerd, also lose the cpu:4 tag. The description only discusses cpu:2.

Test packing on remote executors. test_exec_properties in build/bazelflare/exec_properties.bzl:17 gives test.slots = "1" to any test that has a cpu: tag. Without cpu:2, medium-size kj_test, wd_rust_test, proc-macro and rust_test targets can now share a four-vCPU executor, up to four at a time. Before, each test had an executor to itself. This may be the intended effect, but the description doesn't mention it.


✅ All other checks passed

📝 Documentation: ✅ LGTM

The new comments in build/linking.bzl and src/rust/gen-compile-cache/BUILD.bazel match how the features are used.


Reviewed commit: 4657ec80 — same changes as baaad4dd, so this is that commit's review (no new review was run; line numbers are as of baaad4dd)

@fhanau

fhanau commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author
  • merge together with downstream PR

We're changing how thinLTO works downstream by using the native thin_lto
feature, which means that the `cpu:2` tags will actually be counterproductive.
Also add a custom feature to identify tests so we can set backend flags for
them.
This shortens the critical path when building workerd since we no longer need to
thinLTO-optimize V8 before we can use the compile cache
@fhanau
fhanau force-pushed the felix/102726-rust-cfi branch from 4657ec8 to b4c6d04 Compare November 2, 2026 22:33

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💬 Approved with comments — Nothing here is unsafe to merge. The earlier note about uneven cpu:2 and feature handling is fixed. What's left is a QUESTION about dropping the high-CPU runner property and an INFO about how removing cpu:2 changes test packing on remote executors.

Findings: 1 question · 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: ❓ 1 question · 1 info

The earlier note about uneven cpu:2 and feature handling is fixed. The question about the high-CPU runner is still open, and there is one INFO about test scheduling.

Recommendation: 💬 Optional Nits

  • [QUESTION] This removes exec_properties = {"runner": "high-cpu"} and cpu:4 from wd_cc_binary and wd_rust_binary. That property applied to every action of the target, including the rustc compile and the fully optimized linkopts_tool links such as workerd. Is it intended that these targets no longer request the high-CPU runner? (build/wd_rust_binary.bzl:137)
  • [INFO] Removing cpu:2 also removes the test.slots = "1" property that test_exec_properties (build/bazelflare/exec_properties.bzl:17) gives to tests with a cpu: tag. Medium-size C++ and Rust tests can now share a four-vCPU executor, up to four at a time. The description doesn't mention this change in scheduling. (build/kj_test.bzl:33)
View full review

🔄 Since last review: 1 finding resolved, 1 preserved, 1 new

Fixed: uneven cpu:2 and feature handling. cpu:2 is gone from kj_test, wd_rust_test, wd_cc_benchmark, wd_rust_proc_macro and the wd_rust_binary test target. All of them now add LINKOPTS_DEFAULT_FEATURES. wd_rust_binary adds the feature only when tool is false, which matches its choice between linkopts_default and linkopts_tool. The one cpu:2 left is on the smoke-test sh_test in src/rust/jsg-bench/BUILD.bazel. That target doesn't link with linkopts_default, so it needs no change.

Still open: the high-CPU runner. See build/wd_rust_binary.bzl and build/wd_cc_binary.bzl. The removed exec_properties = {"runner": "high-cpu"} applied to every action of the target, not only the link. For wd_rust_binary that includes the rustc compile. Binaries built with linkopts_tool, such as workerd, also lose the cpu:4 tag. The description only discusses cpu:2.

Test packing on remote executors. test_exec_properties in build/bazelflare/exec_properties.bzl:17 gives test.slots = "1" to any test that has a cpu: tag. Without cpu:2, medium-size kj_test, wd_rust_test, proc-macro and rust_test targets can now share a four-vCPU executor, up to four at a time. Before, each test had an executor to itself. This may be the intended effect, but the description doesn't mention it.


✅ All other checks passed

📝 Documentation: ✅ LGTM

The new comments in build/linking.bzl and src/rust/gen-compile-cache/BUILD.bazel match how the features are used.


Reviewed commit: b4c6d04b — same changes as baaad4dd, so this is that commit's review (no new review was run; line numbers are as of baaad4dd)

Comment thread build/kj_test.bzl
# Tag with cpu:2 since this target depends on linkopts_default.
tags = tags + ["cpu:2"],
tags = tags,
target_compatible_with = target_compatible_with,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ℹ️ INFO · Code Quality

Removing cpu:2 also removes the test.slots = "1" property that test_exec_properties (build/bazelflare/exec_properties.bzl:17) gives to tests with a cpu: tag. Medium-size C++ and Rust tests can now share a four-vCPU executor, up to four at a time. The description doesn't mention this change in scheduling.

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.

3 participants