Skip to content

Reuse checked Rust slice constants before LLVM optimization - #22

Open
charliermarsh wants to merge 1 commit into
charlie/checked-preoptimizer-objects-guardedfrom
charlie/llvm-cache-preoptimizer-slice-constants
Open

charliermarsh wants to merge 1 commit into
charlie/checked-preoptimizer-objects-guardedfrom
charlie/llvm-cache-preoptimizer-slice-constants

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The complete −31 SDK used 66.22% fewer instructions on the warm uv edit and 8.90% fewer instructions on the warm Ruff edit. The control was the same release candidate before the LLVM cache stack. Each run counted Cargo, the compilers and the final linker.

Rustc sometimes leaves a detached two-field slice constant in the LLVM context. The optimizer can observe its address and operand use-list position even when ordinary bitcode omits it. We record those inputs for supported terminal slices. If an unrepresented user could affect a result, LLVM runs the optimizer normally.

An isolated comparison against rustc #397’s original LLVM revision admitted 120 additional codegen units before optimization and used 27.89% fewer instructions on the warm uv edit across eight pairs. Measured uv edit

The eight warm pairs and the independent replay used LLVM 381ca8e2fb66 and 95a2277ca998. On a separate rebuild with empty LLVM stores, they used 2,261,502,476,995 and 2,261,235,213,019 instructions, respectively (0.012% fewer, one pair). Each wrote 382 native objects with zero hits. The change wrote 129 additional early-index records, totaling 17,544 bytes. The current base 578e066665b3 and head fba5a6233165 contain the same change by Git patch ID after the stack rebase.

On the current public base 578e066665b3 and head fba5a6233165, one fresh pair on that same warm edit used 1,167,953,990,674 → 864,354,455,979 instructions, 25.994% fewer for the complete cargo +ohm build --locked --offline --profile fast-build -p uv --bin uv. Early hits rose from 226 to 344. Both sides compiled 40 units and produced identical bytes in all 4,075 machine objects, all 40 measured metadata files and the linked uv executable. Five CLI probes also matched. Ordinary native runs recorded multiple uv_configuration metadata encodings with the same public hash and six decoded views. Each rebased empty-store control wrote 377 objects with zero hits.

Complete edit Warm instruction reduction Empty store Store bypassed First-fill difference
uv workspace metadata 66.22% fewer instructions 1,872,961,872,481 1,792,109,192,099 4.51% more
Ruff parser 8.90% fewer instructions 15,439,775,958 14,087,268,942 9.60% more

The warm results report the median reduction across two pairs. Each first-fill result compares one empty store with a bypassed store on the same compiler and pre-edit target. The Ruff build script recorded Git revision data in native builds and omitted it under the instruction counter. Every reported pair had matching inputs. Qualified SDK

@charliermarsh
charliermarsh force-pushed the charlie/llvm-cache-preoptimizer-slice-constants branch from 95a2277 to fba5a62 Compare November 10, 2026 14:24
@charliermarsh
charliermarsh marked this pull request as ready for review November 10, 2026 14:24
@charliermarsh
charliermarsh added this pull request to stack #20 November 10, 2026 14:28
charliermarsh added a commit to astral-experiments/ohm that referenced this pull request Nov 10, 2026
## Summary

Ohm 1.99.0-31 lets optimized Rust libraries reuse a checked LLVM object
before optimization. LLVM can also reuse an object after bounded source
edits when every observed line has an unambiguous destination. These
paths target incremental O1 builds on x86-64 Linux. [LLVM
stack](astral-experiments/ohm-llvm#22) · [Rust
compiler
change](astral-experiments/ohm-rust#397)

Rustc preserves caller locations across worktrees, indexes consecutive
procedural-macro spans directly, and retains the joined span of
type-relative struct paths. Clippy uses those paths when checking
patterns and expressions. [Rust span
changes](astral-experiments/ohm-rust#400) ·
[Clippy
companion](astral-experiments/ohm-rust-clippy#83)

Cargo documents libraries with names up to 242 bytes and retains active
shared builds whose compiler or driver path contains non-UTF-8 bytes.
Its checked-in lockfile also matches dependency resolution in a
read-only checkout. [Cargo
stack](astral-experiments/ohm-cargo#530)
@charliermarsh
charliermarsh force-pushed the charlie/llvm-cache-preoptimizer-slice-constants branch from fba5a62 to 7b63e0a Compare November 17, 2026 05:36
@charliermarsh
charliermarsh removed this pull request from stack #20 November 17, 2026 05:37
@charliermarsh
charliermarsh added this pull request to stack #33 November 17, 2026 05:37
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