Skip to content

Implement incremental resolution: invalidate graph edges on changes to resolver-observed paths - #2289

Draft
robhogan wants to merge 1 commit into
pr2291from
pr2289
Draft

robhogan wants to merge 1 commit into
pr2291from
pr2289

Conversation

@robhogan

@robhogan robhogan commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

With resolver.unstable_incrementalResolution on, resolutions have recorded what they observed since #1949, with the plan to consume those observations to invalidate resolution. This adds the consumer.

Graph keeps what each module's resolutions observed (carried on ModuleData), and DeltaCalculator turns each batch of changes into the modules to revisit, before it filters to modules already in the graph. Modules holding an unresolved optional dependency are revisited on any addition or removal, or package.json change. Graph resets on symlink and (with package exports on) package.json changes, and clearing the resolution cache on every change, are unchanged.

Performance

The priority here is correct, end-to-end behaviour - it's neither fast nor memory efficient, but that's not a concern while it's flagged off. We'll optimise as follow-ups before stabilising the flag, but I'm leaving optimisations out at this stage to avoid bloating these already large PRs.

That said, with this first version, enabling incremental resolution adds ~35% to pure resolution time (recording alone, as since #1949, adds ~20%) and ~6-7x the resolution cache's heap. I'd expect both to be small in the context of a real build, but haven't measured that, or the scan on each change.

(For the record: reducing the ingested paths so that we don't store every extension candidate, and deferring ingestion until after a build, are planned.)

Changelog

 - **[Experimental]**: `resolver.unstable_incrementalResolution` is now implemented end-to-end

Test plan

New unit tests for the index, Graph and DeltaCalculator, and watch-mode integration tests against a real file map that check the next delta after creating a more specific platform file, installing a nearer package, creating the file a failed optional require wanted, and changing a package's main (directly, through a symlinked workspace, and to fix a failed optional require).

@robhogan
robhogan added this pull request to stack #2293 November 25, 2026 16:17
@robhogan robhogan changed the title Incremental resolution: Revisit modules a change invalidates Implement incremental resolution: invalidate graph edges on changes to resolver-observed paths Nov 25, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 25, 2026
@robhogan
robhogan removed this pull request from stack #2293 November 25, 2026 17:18
@robhogan
robhogan changed the base branch from main to pr2291 November 25, 2026 17:24
@robhogan
robhogan added this pull request to stack #2296 November 25, 2026 17:42
@robhogan
robhogan removed this pull request from stack #2296 November 26, 2026 15:35
@robhogan
robhogan added this pull request to stack #2303 November 26, 2026 15:42
…o resolver-observed paths

With `resolver.unstable_incrementalResolution` on, resolutions have recorded what they observed since #1949, with the plan to consume those observations to invalidate resolution. This adds the consumer.

`Graph` keeps what each module's resolutions observed (carried on `ModuleData`), and `DeltaCalculator` turns each batch of changes into the modules to revisit, before it filters to modules already in the graph. Modules holding an unresolved optional dependency are revisited on any addition or removal, or `package.json` change. Graph resets on symlink and (with package exports on) `package.json` changes, and clearing the resolution cache on every change, are unchanged.

## Performance

The priority here is correct, end-to-end behaviour - it's neither fast nor memory efficient, but that's not a concern while it's flagged off. We'll optimise as follow-ups before stabilising the flag, but I'm leaving optimisations out at this stage to avoid bloating these already large PRs.

That said, with this first version, enabling incremental resolution adds ~35% to pure resolution time (recording alone, as since #1949, adds ~20%) and ~6-7x the resolution cache's heap. I'd expect both to be small in the context of a real build, but haven't measured that, or the scan on each change.

(For the record: reducing the ingested paths so that we don't store every extension candidate, and deferring ingestion until after a build, are planned.)

## Changelog
```
 - **[Experimental]**: `resolver.unstable_incrementalResolution` is now implemented end-to-end
```

## Test plan
New unit tests for the index, `Graph` and `DeltaCalculator`, and watch-mode integration tests against a real file map that check the next delta after creating a more specific platform file, installing a nearer package, creating the file a failed optional `require` wanted, and changing a package's `main` (directly, through a symlinked workspace, and to fix a failed optional `require`).

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

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant