Skip to content

Boot snapshot byte-copies the 180 MB store on every launch — use an APFS clone (COPYFILE_FICLONE) #637

Closed

Description

@currentbits

Found in perf research round 31b (2026-08-21).

On every successful load, the store constructor synchronously snapshots the freshly-read main file to .bak:

With the store at 180 MB (growing ~18 MB/day, see #225) that is 180 MB read + 180 MB written to disk on every launch, on top of the synchronous 180 MB readFileSync + JSON.parse that precedes it. It directly stretches time-to-first-paint and adds a boot-time SSD write that scales with store size.

One-line fix: pass the copy-on-write flag —

fs.copyFileSync(this.filePath, bakPath, fs.constants.COPYFILE_FICLONE);

COPYFILE_FICLONE makes an instant APFS clone (zero bytes of data copied) and silently falls back to a normal copy on filesystems without reflink support, so no platform branching is needed (do NOT use FICLONE_FORCE, which errors instead of falling back). The existing try/catch already tolerates failure.

Sharding the store (#225) shrinks the payload too, but this is independent and free today. The same flag is worth auditing at other big-file copy sites (e.g. worktree scaffolding).

Activity

  1. added
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 21, 2026
  2. currentbits commented on Aug 21, 2026

    @currentbits
    OwnerAuthor

    Landed on main as 755f0a2 (local, not yet pushed): Store._load() now snapshots with fs.constants.COPYFILE_FICLONE — instant CoW clone on APFS, silent fallback to a real copy elsewhere. The 180 MB byte-copy is gone from the boot chain.

  3. added
    plan:done
    and removed
    plan:doing
    on Aug 21, 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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions