Skip to content

bench: quick-link / thin-LTO / full-LTO sections over the frozen corpus (link only, no compile in the loop) #56

Closed

Description

@zackees

Summary

Extend the frozen link-corpus benchmark (#55) with three link modes so we get excellent coverage of the real dev-vs-release link spectrum:

As with #55, producing the inputs (compilation) must not be part of the benchmark — build once per platform per mode, freeze the inputs and the captured final link command, and the benchmark times only the link invocation replayed per iteration.

Motivation

reld's story spans the fast dev link and (via the polylinker, #30) routing LTO links to a capable engine. Benchmarking all three modes on the same corpus (Bevy, #55) gives a single, comparable picture:

  • quick-link isolates conventional linking speed (the dev-loop case reld optimizes).
  • thin-LTO / full-LTO cover the heavier links where the linker's LTO plugin does whole-program work — the case reld routes to lld today, and the one users hit for release-ish builds.

Three sections × the linker set (link.exe / lld-link / rust-lld / mold / reld, as available) = broad, apples-to-apples coverage.

Important scoping note (what is and isn't timed)

  • Never time compilation. All object/bitcode inputs are produced once in a prep step and frozen. Iterations replay only the final link command.
  • quick-link times pure linking: objects → linker → executable.
  • thin-LTO / full-LTO inherently do LLVM whole-program optimization + codegen inside the link step (the linker's LTO plugin). That plugin work is part of the link invocation and is therefore legitimately in-scope for those two modes — the point of the LTO sections is to measure exactly that. The frozen inputs for these modes are the bitcode-bearing .rlibs/objects; compilation up to bitcode is still prep, not measured.

This is the key difference from #55's quick-link profile, which deliberately sets lto = false to keep bitcode-WPO-codegen out of the measurement.

How to build each corpus mode

Per platform, build Bevy (same pinned version as #55) once in each mode and capture the exact final link with rustc --print link-args:

# quick-link (as in #55)
[profile.linkbench-quick]
inherits = "dev"
opt-level = 0
debug = 2
incremental = false
lto = false
codegen-units = 256

# thin-LTO
[profile.linkbench-thin]
inherits = "release"
lto = "thin"
debug = 2
incremental = false
# codegen-units left at the release default; thin-LTO manages its own partitioning

# full-LTO
[profile.linkbench-fat]
inherits = "release"
lto = "fat"
debug = 2
incremental = false
codegen-units = 1
cargo build  --profile <mode>
cargo rustc --profile <mode> -- --print link-args   # capture per mode, per platform

Freeze the referenced inputs + normalized link command per (mode, platform), then replay per iteration with the linker swapped (hyperfine --prepare 'rm -f app' './link-<mode>-<linker>.sh').

Proposal

  1. Generalize the bench: frozen Bevy link corpus — compile once per platform, replay the link every iteration #55 corpus prep to build + capture three modes (quick / thin / fat) per platform, each frozen independently (keyed on Bevy version + platform + mode).
  2. reld-bench gains a mode selector so it can replay any of the three frozen link commands N times per linker and report per-mode, per-linker medians as separate sections.
  3. For LTO modes, ensure the frozen corpus includes the bitcode-bearing rlibs and the plugin flags from the captured command, so the LTO codegen happens at link time exactly as in a real build.
  4. Corpus refresh stays explicit (Bevy version bump); mold's LTO/.rlib handling scoped to Linux (per bench: frozen Bevy link corpus — compile once per platform, replay the link every iteration #55).

Open questions

Acceptance criteria

  • The benchmark reports three sections — quick-link, thin-LTO, full-LTO — over the same Bevy corpus, per platform, per linker.
  • Inputs for all three modes are built once and frozen; no compilation happens inside the measured link loop (quick-link times pure linking; LTO modes time the link incl. its plugin codegen, with bitcode inputs pre-frozen).
  • Per-mode final link commands are captured via rustc --print link-args and replayed unchanged against frozen inputs.
  • reld's LTO-link behavior is reported honestly (routed series or n/a) rather than silently skipped.
  • RED -> GREEN: benchmark currently has only a non-LTO link path; after this it replays frozen thin-LTO and full-LTO links with zero in-loop compilation.

Cross-reference

Activity

  1. zackees commented on Aug 7, 2026

    @zackees
    CollaboratorAuthor

    Tracked under meta #57 (frozen linker-object benchmark assets — storage/publishing/consumption + manifest.json).

  2. zackees commented on Aug 24, 2026

    @zackees
    CollaboratorAuthor

    Superseded by #70 and delivered in #71. The shipped benchmark covers exactly no-LTO, ThinLTO, and full-LTO over the same small cross-platform Rust workload, captures each real final link after out-of-loop compilation, verifies every output, and publishes strict no-N/A results with concrete engine metadata. The Bevy-specific corpus and permissive N/A direction in this proposal were intentionally replaced by the adopted design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions