Skip to content

I0-I7: Incremental linking (do not start before P4 is green) #11

Open

Description

@zackees

Part of #2. Full spec: 09-INCREMENTAL.md. Blocked on #10 (decisions) and P4 (#8).

This is the product. It also has more documented failures behind it than any other area of linker engineering.

The decisive structural fact

HP-UX data on a 118 MB binary: changing 15× more objects cost only 48% more time — 11.3s for 2 objects, 16.7s for 30. Their explanation: "Regardless of the amount of code modified, the time spent on extracting information from the output file will always be the same." gold's null relink on Chrome was ~30s.

A file-persisted incremental linker has a fixed cost proportional to binary size, not change size. DESIGN.md's target — millisecond warm relink largely independent of binary size — is unachievable with on-disk state. The daemon is a precondition, not an optimization, and it is the one architectural choice that genuinely distinguishes reld from wild.

Phases

  • I0 preconditions, built during P2–P4: content-addressed identity, global section IDs, layout journaling, --verify, no-global-state/no-exit() (the two blockers that stalled lld-as-a-library), and reld log always on
  • I1 the fallback gate — a 22-trigger checklist in 6 groups. Two rules: a discovered fallback is slower than never trying (so cheap triggers are evaluated before any work), and every fallback is logged with its trigger number. Silent unexplained fallback destroyed every prior system's reputation
  • I2 daemon + warm full link, zero patching — the first shippable win. Novel combination available here: daemon + snapshot + build-system-supplied change set (gold shipped the flags; nobody combined all three)
  • I3 in-place patching, no growth. Slack 25% — Quong & Linton measured 24% ⇒ 97% in place; Zig uses 25%; gold's 10% was insufficient
  • I4 growth/movement via pure relocation re-patching. Zig tried forced-GOT, then a custom jump table, then dropped both. Start where they finished
  • I5 the sorted-table subsystem — .eh_frame_hdr/.pdata/__unwind_info. Cannot be padded or indirected around; must be rebuilt. This is what killed gold's C++ support and it is identical on all three formats
  • I6 debug info — 80% of the executable, and where everyone foundered
  • I7 the bookkeeping wall: in a real 37ms Zig update, linking was 170µs and 31ms was traversing the graph to discover it hadn't changed. Once patching works, bookkeeping dominates by ~180×

Acceptance

Reference is a full link of the same final inputs — run both, compare behaviour and symbol addresses, never bytes. Plus: seeded edit-sequence stress, a fixture per fallback trigger, 1,000-link drift runs, and speed reported against the do-nothing floor.

⚠️ Do not cite "11x faster" for Zig — the figure was publicly retracted by its author. Correct framing: 65ms vs a 62ms typecheck-only floor.

Activity

  1. added
    enhancement
    on Aug 1, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions