Repository navigation
Description
Context
Reld has two plausible Linux engine directions: delegate to or fork mold, or continue optimizing the vendored Wild/Rust core. Exact Linux evidence now makes that choice concrete.
The merged reld tree has twice beaten mold on the unchanged captured full-LTO workload, but only narrowly:
| Exact run | reld full-LTO | mold full-LTO | reld lead |
|---|---|---|---|
| 32916339512 | 241.9 ms | 249.7 ms | 3.1% |
| 32918511923 | 232.4 ms | 237.1 ms | 2.0% |
The requested completion gate is a lead of at least 10% in the same exact-SHA Linux run. At the second run's mold time, reld must reach at most 213.4 ms, requiring roughly another 19 ms reduction.
Delegating to an unmodified mold cannot satisfy that gate on an identical captured invocation: it necessarily performs mold's link plus reld routing/process overhead. Forking mold would replace reld's established Rust/Wild engine with a separate roughly 35k-line C++ ELF implementation, discard the current format-neutral and incremental architecture, and make the recently landed writer/relocation work irrelevant. By contrast, reld is already a source fork of Wild, already leads mold, and retains direct ownership of the measured hot paths.
The exact current-tree phase trace for the 373,343,543-byte full-LTO output reports:
Write data to file: 92.99 ms;Flush and unmap output file: 80.13 ms;Layout: 20.36 ms;Compute build ID: 9.23 ms;- total traced link: 217.47 ms with
--no-fork.
Rust full LTO supplies two monolithic objects. Their relocation spans overlap in the outer Rayon schedule and consume 58.98 ms and 90.89 ms. The retained object census has 3.15 million debug relocations, including 2.47 million sorted RELA entries in .rela.debug_info.
The first sharding change in #81 parallelized those entries but retained the inherited Wild inner loop. For every relocation, apply_debug_relocation still decodes the symbol-table entry, determines its section, converts the input symbol index to a global ID, probes merged resolution, and may reconstruct a local-section resolution. Debug relocation streams reuse symbol targets heavily, making repeated target resolution the next bounded CPU cost.
Current upstream Wild also contains sparse OutputSectionPartMap changes for custom sections. Those patches are relevant to the 71,604-section full-LTO object, but the entire measured layout phase is only 20.36 ms, so they are a secondary port-and-measure candidate rather than the first bet.
Proposal
Continue with the Wild fork and optimize the native ELF full-LTO path in measured order:
- Add a focused RED repro/counter showing that a large sorted RELA debug stream resolves the same symbol target once per relocation today.
- Introduce a correctness-preserving debug-relocation target cache keyed by input symbol index. Resolve each referenced target once per monolithic object (or once per shard if measurement proves that cheaper), then reuse the cached resolved/local-section/merge-string/tombstone classification in the relocation loop.
- Keep addend-dependent merged-string handling and paired subtraction semantics explicit; cache only data that is invariant across relocations.
- Preserve the existing disjoint output sharding and aggregate relocation statistics. Invalid symbols and unsupported relocation kinds must retain contextual errors rather than becoming unchecked indexes.
- Measure target-cache construction separately from relocation application so a broad symbol table cannot hide a precompute regression.
- If the cache does not create the required end-to-end headroom, port current upstream Wild's sparse custom-section maps as an isolated second candidate and retain them only with exact phase evidence.
- Do not repeat the rejected splice, mmap-copy, whole-debug-section, or hash/write-overlap experiments unless new evidence changes their underlying constraints.
Acceptance criteria
- Commit RED evidence before implementation: a focused test/repro demonstrates repeated invariant symbol-target resolution for a large debug relocation stream.
- GREEN evidence proves each cacheable target is resolved once per cache scope and all relocations still write identical bytes.
- Focused tests cover merged/global resolution, local section symbols, merged strings with distinct addends, discarded/unloaded tombstones, missing symbols, paired subtraction at shard boundaries, and unsupported relocation kinds.
- The large sorted RELA path retains safe disjoint sharding; small, CREL, unsorted, overlap-unsafe, and out-of-bounds inputs retain their correct fallback.
- Phase evidence reports cache construction and monolithic relocation separately and demonstrates a material reduction in the dominant full-LTO relocation span.
- On the unchanged exact-SHA GitHub Linux benchmark,
reld_full_lto <= 0.90 * mold_full_ltoin the same round-robin run. - The benchmark still compiles and performs all Rust LTO preparation outside timing, replays only the captured final native link, verifies every output, reports startup separately without subtraction, and preserves exact-SHA/freshness/no-silent-N/A gates.
- no-LTO and ThinLTO do not regress by more than 2% against merged main in a paired comparison.
- Ordinary small-link latency does not regress by more than 2%.
- Linux unit/integration/self-hosting/Clippy gates pass; Windows and macOS correctness workflows remain green.
- The final PR includes RED, GREEN, phase, raw-sample, and exact hosted benchmark evidence.
Decisions
- Engine: continue the Wild fork. It is already faster than mold and exposes the hot path in reld's native language and architecture; an unmodified mold wrapper has no mechanism to beat its own reference invocation.
- First target: cache debug relocation targets. The 2.47-million-entry
.rela.debug_infostream repeats invariant symbol work inside the largest remaining CPU phase. - Secondary target: upstream Wild sparse custom-section maps. They are low-risk prior art for the 71,604-section object, but their ceiling is bounded by the measured 20.36 ms layout phase.
- Performance gate: 10% relative lead, not a fixed millisecond threshold. Hosted runner speed varies, so acceptance compares reld and mold in the same run.
- Benchmark identity stays frozen. Changing the workload, LTO modes, trial policy, output correctness oracle, or startup accounting would invalidate the crown comparison.
- Linux-only iteration, all-platform final validation. Use the scoped benchmark workflow during candidate work and reserve all-platform runner spend for the winning commit.
Open questions
- Does a shared precomputed vector or a per-shard lazy vector produce the lower total cost for the retained symbol-table cardinality? Select from the retained workload, not intuition.
- After symbol caching, is the next limiting resource relocation arithmetic, anonymous-buffer page traffic, or ext4 persistence? Use the new phase split before choosing the follow-up.
Related issues
- perf(elf): parallelize section population for monolithic full-LTO objects #81 established monolithic section preparation and intra-section debug relocation sharding.
- perf(elf): reduce full-output build-ID hashing cost #75 owns remaining fast build-ID compatibility work; the current hash phase is only 9.23 ms and is not this issue's first target.
- perf(fs): splice large buffered Linux outputs past mold #79 records the rejected splice persistence path and its hosted regression.
Activity
perf(elf): avoid redundant debug relocation decoding (#82)
zackees commentedon Aug 26, 2026
Winning candidate is in PR #83.
Hosted Linux evidence at exact SHA
e706c8d11ad6fc97c0cc906acdfdf107dadb6122: https://github.com/zackees/reld/actions/runs/32937802814Accepted changes:
Rejected during investigation:
The final all-platform dispatch is running here: https://github.com/zackees/reld/actions/runs/32938949262
perf(elf): cache adjacent debug symbol resolutions (#82)
zackees commentedon Aug 26, 2026
Final hosted Linux evidence at exact SHA
c23aaa4673a6d1bb66e17e5e27f199ed4b94ab18: run 32945841290 measured full-LTO reld at 0.2804s versus mold at 0.3333s. reld is 15.9% faster (84.1% of mold latency), clearing the 10% target with all five expected Linux linkers measured and no silent N/A. Raw startup was reported separately and not subtracted: reld 0.0019s. The final follow-up caches only adjacent debug-symbol resolutions per parallel shard; Linux core tests, doctests, Clippy with warnings denied, independent review, and all PR platform checks passed.perf(elf): extend the Wild fork to a full-LTO lead over mold (#83)