8000 Run cache: skip the runtime-beam copy on a cache hit · Issue #662 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Run cache: skip the runtime-beam copy on a cache hit #662

Open

Description

@akoskovacs

On a run-cache hit, the toolchain still copies every prebuilt runtime beam (141 .beam files, 1.5 MB, about 16 ms) into the output directory before restoring the cached program.

Why it can't simply be skipped

tryLoadRunCacheFrom (src/driver/toolchain.cxx) checks for a hit and restores in one call: it validates manifest.txt and, as a side effect, copies every cached .beam into outputDir. The restore has to land after the prebuilt copy. Otherwise a stale prebuilt copy of a stdlib module the program merged from source (Kex.URI, … via resolveBeamDeps) wins, which is the #27 env.query shape.

Doing this means splitting the check from the restore: validate the manifest and file presence first, then restore after the copy decision. Even then, a hit can't skip the copy wholesale. Execution still needs kex_prelude.beam and the other runtime beams, so only the same-named subset the restore is about to overwrite can be skipped.

Measured (no code written)

Only Kex.* stdlib modules (76 files, 552 KB) can collide. 3 of 644 specs merge an opt-in module from source, one module each. With a generous upper bound of 5 merged modules, that is about 5/141 of the copy: about 0.6 ms on the hit path, 0 ms for programs that merge no stdlib source.

Deferred: a ceiling of about 1 ms doesn't justify check/restore surgery next to a kex#27-shaped hazard. Revisit if the copy set or the cost changes.

Activity

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

    CLIEnhancementNew feature or requestPerformanceRun time, build time or memory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0