Repository navigation
Description
Problem
Exact hosted Linux benchmarking on commit 3e3b309f showed that the splice-based output experiment does not close the full-LTO gap:
| Linker | full-LTO median |
|---|---|
| mold | 302.2 ms |
| reld | 384.4 ms |
The hosted trace attributes about 163 ms to Write data and about 101 ms to output flush. Splice regressed hosted flush versus the prior mmap path, so transport is not the next optimization to keep.
Profiling the retained full-LTO link input identified the configuration-specific bottleneck: Rust full-LTO produces a monolithic object with 71,604 sections. A single files=1 write group dominates the write phase, serially copying and padding tens of thousands of independent section payloads before relocations. This explains why no-LTO and ThinLTO remain fast while full-LTO trails mold.
Proposed change
Refactor ELF object writing into two stages:
- Allocate each output section range serially so output layout and buffer ownership remain deterministic.
- Populate the disjoint ranges (raw section copy, relaxation compaction, and padding) in parallel with Rayon.
- Apply relocations, RELR state transitions, frame data, and table writes sequentially in the existing section order.
Revert the hosted-regressing splice output experiment rather than combining it with this change. Consider parallel chunked fast-build-ID hashing only after section population is measured.
Correctness requirements
- No change to ELF section layout, relocation order, RELR runs, table-writing order, compressed-debug handling, or partial-link REL/RELA handling.
- Every benchmark output must execute successfully.
- Linux, macOS, and Windows linker-mode suites remain green.
- Add focused tests for the staged population behavior and retain RED-to-GREEN evidence.
Performance acceptance
On the exact hosted Linux benchmark workload:
- reld full-LTO median is faster than mold in the same run;
- no-LTO and ThinLTO do not regress by more than 2%;
- phase traces demonstrate the reduction in
Write data; - benchmark freshness, exact-SHA, engine metadata, and no-silent-N/A gates remain enforced.
Evidence
Hosted workflow: https://github.com/zackees/reld/actions/runs/32897398720
This issue supersedes the splice direction in #79 based on hosted-run evidence.
Activity
perf(elf): parallelize full-LTO output preparation (#81)
zackees commentedon Aug 25, 2026
Exact hosted Linux run 32904556642 validates the first two stages but does not yet meet the acceptance target:
The benchmark and all output-mode gates passed. The next implementation step under this issue is to replace the remaining serial
write_allof the completed 373 MiB buffer with bounded, disjoint parallel positional writes on Linux regular files, retaining the serial fallback elsewhere. This targets the now-dominant flush without reintroducing the splice regression.perf(fs): flush large buffered outputs in parallel (#81)
perf(fs): scope parallel flush to measured ext4 window (#81)
zackees commentedon Aug 25, 2026
Hosted run 32907661178 shows positional writes are insufficient: flush improved only from 90.2 ms to 81.6 ms, while full-LTO reld was 289.2 ms versus mold at 255.8 ms.
The next transport iteration keeps the completed anonymous buffer but maps the already-sized output file only at finish and performs one parallel, linear bulk copy into that mapping. This differs from direct mmap output: the linker still avoids tens of thousands of file-backed random page faults during section writes, while finish avoids roughly 90 positional-write syscalls and lets four workers fault/copy contiguous ranges. The current positional-write path remains a fallback if the finish-time mapping fails.
perf(fs): bulk-copy buffered outputs through mmap (#81)
zackees commentedon Aug 25, 2026
Hosted run 32909879928 rejects the finish-time mmap copy: full-LTO flush rose to 124.8 ms and the 10% baseline gate failed. That experiment is reverted.
The next change targets linker work inside the remaining write phase. Loaded debug sections already own disjoint output slices, and
relocate_debug_sectionwrites only that slice while reading immutable object/layout state; unlike regular loaded sections, it does not mutateTableWriter, RELR state, or dynamic relocation tables. Debug relocation will therefore move into the existing parallel population stage, while all order-sensitive loaded-section relocation remains serial.perf(elf): relocate debug sections in parallel (#81)
zackees commentedon Aug 26, 2026
Hosted Linux run 32912035980 rejects parallel debug relocation as the next optimization: full-LTO reld was 327.7 ms versus mold at 295.3 ms (32.4 ms behind), and the current write phase remained 153.4 ms. The candidate is being reverted.
The next step is measurement instrumentation inside the monolithic-object write, separating section-range allocation, parallel population, order-sensitive loaded relocation, and symbol/table emission. That phase split will identify which remaining linker work is large enough to beat mold without another output-transport guess.
perf(elf): trace monolithic object write phases (#81)
zackees commentedon Aug 26, 2026
Hosted phase run 32913909272 identifies the next optimization precisely. In full-LTO, the two monolithic objects spend 147.0 ms in relocation (17.65 + 129.39 ms), versus 22.1 ms in parallel population, 2.0 ms in allocation, and 5.4 ms in symbol emission. The retained object census shows 3.15 million debug relocations, with about 2.47 million concentrated in
.rela.debug_info.Implementation will shard large, sorted RELA debug relocation streams within a section across disjoint output byte ranges. It will carry the previous relocation into each shard for paired-relocation semantics and fall back to the existing serial path for small, CREL, unsorted, or overlap-unsafe inputs.
perf(elf): shard monolithic debug relocations (#81)
zackees commentedon Aug 26, 2026
Acceptance target reached on exact hosted Linux run 32916339512 at commit
0fc685cc: full-LTO reld is 241.9 ms versus mold at 249.7 ms, a 7.8 ms (3.1%) win. The run passed output execution and benchmark gates.The measured mechanism matches the hypothesis: monolithic relocation fell from 147.0 ms in the instrumented serial run to 66.5 ms (7.13 + 59.38 ms), Write data fell from 165.5 ms to 97.3 ms, and the default mode improved 26.8% over the exact issue baseline. Windows and macOS jobs remain running for cross-platform validation.
zackees commentedon Aug 26, 2026
Final validation is complete. The all-platform exact-source run https://github.com/zackees/reld/actions/runs/32916339512 passed Linux, Windows, macOS, executable verification, coverage, metadata, and graph rendering. Linux full-LTO reld was 241.9 ms versus mold at 249.7 ms; macOS bridge validation also completed successfully, and Windows bridge validation passed.
After that result, benchmark dispatch was scoped to avoid unrelated runner spend. Commit
1b9c875eadds automaticperf/linux/**,perf/windows/**,perf/macos/**, andperf/all/**branch scopes plus an explicit dispatch selector defaulting to Linux. Exact-current-SHA run https://github.com/zackees/reld/actions/runs/32918511923 expanded onlyGenerate x86_64-linux benchmark, skipped Windows, macOS, aggregation, and freshness, passed every Linux benchmark gate, and retained the full-LTO win: reld 232.4 ms versus mold 237.1 ms.perf(elf): parallelize full-LTO section population (#80)