Skip to content

fix(cache): fingerprint only whether files a task probes exist - #869

Open
lifeiscontent wants to merge 2 commits into
voidzero-dev:mainfrom
lifeiscontent:fix/existence-probes
Open

lifeiscontent wants to merge 2 commits into
voidzero-dev:mainfrom
lifeiscontent:fix/existence-probes

Conversation

@lifeiscontent

Copy link
Copy Markdown
Contributor

Motivation

Vite's searchForWorkspaceRoot calls fs.existsSync on pnpm-workspace.yaml and lerna.json in every ancestor directory. fspy recorded access as a read, so the probe made the file's content an input. Editing an unrelated line of pnpm-workspace.yaml, such as an unused catalog entry, missed the cache of every task that loads a Vite config. In a 199-task monorepo one such edit left 1 cache hit out of 184 tasks.

Changes

  • fspy reports access, faccessat and faccessat2 (preload and seccomp) and NtQueryAttributesFile (Windows) as a new Probe access. stat calls and NtQueryFullAttributesFile stay reads, since their callers can use the size or modification time.
  • A path a task only probes is fingerprinted by whether it exists: a new FileExists for a file, Folder(None) for a directory, NotFound otherwise. A task that also reads the path, in any process, tracks its content, so a catalog lint still misses when the file changes.
  • Creating or removing a probed file is still a cache miss, since that can change the workspace root Vite selects.
  • The cache schema version goes to 19, since older builds can't decode FileExists.
  • Trade-off: on Windows, Node's fs.existsSync stats an existing file after GetFileAttributesW to detect broken symlinks, and that stat is a read, so the file stays a content input there. Fixing that depends on how stat-like metadata reads are classified, which this PR leaves as is.

Fixes #860

Vite's `searchForWorkspaceRoot` calls `fs.existsSync` on
`pnpm-workspace.yaml` and `lerna.json` in every ancestor directory. fspy
recorded `access` as a read, so the probe made the file's content an
input, and editing an unrelated line of `pnpm-workspace.yaml` missed the
cache of every task that loads a Vite config.

- fspy reports `access`, `faccessat` and `faccessat2` (preload and
  seccomp) and `NtQueryAttributesFile` (Windows) as a new `Probe` access.
  `stat` calls and `NtQueryFullAttributesFile` stay reads, since their
  callers can use the size or modification time.
- A path a task only probes is fingerprinted by whether it exists: a new
  `FileExists` for a file, `Folder(None)` for a directory, `NotFound`
  otherwise. A task that also reads the path tracks its content.
- The cache schema version goes to 19, since older builds can't decode
  `FileExists`.

On Windows, Node's `fs.existsSync` stats an existing file after
`GetFileAttributesW` to detect broken symlinks, and that stat is a read,
so the file stays a content input there.

Fixes voidzero-dev#860

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Existence probes of pnpm-workspace.yaml become content inputs, so any manifest edit misses every task

1 participant