Skip to content

Optimise dedupe to skip install when nothing to dedupe#6974

Open
jordanoverbye wants to merge 4 commits intoyarnpkg:masterfrom
jordanoverbye:joverbye-dedupe-optimisation
Open

Optimise dedupe to skip install when nothing to dedupe#6974
jordanoverbye wants to merge 4 commits intoyarnpkg:masterfrom
jordanoverbye:joverbye-dedupe-optimisation

Conversation

@jordanoverbye
Copy link
Copy Markdown

@jordanoverbye jordanoverbye commented Nov 11, 2025

What's the problem this PR addresses?

Currently the dedupe command always runs project.installWithNewReport() even when no packages need deduplication, causing unnecessary installs and lockfile updates.

How did you fix it?

Exit early if no packages need deduping. Only run project.installWithNewReport() when necessary.

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@jordanoverbye jordanoverbye force-pushed the joverbye-dedupe-optimisation branch from c674609 to 2577eed Compare November 11, 2025 07:09
@jordanoverbye jordanoverbye marked this pull request as ready for review November 11, 2025 07:21
@clemyan
Copy link
Copy Markdown
Member

clemyan commented Dec 19, 2025

Only @yarnpkg/cli and @yarnpkg/plugin-essentials should be released. Other packages should be marked as declined.

LGTM, but I'd like to have a second pair of eyes to look over it.

@jordanoverbye jordanoverbye force-pushed the joverbye-dedupe-optimisation branch from 2a34bf8 to 08a853a Compare January 5, 2026 00:24
@jordanoverbye
Copy link
Copy Markdown
Author

Thank you for the review @clemyan! I've just pushed a change to the versions file so only @yarnpkg/cli and @yarnpkg/plugin-essentials should now be released.

@jordanoverbye jordanoverbye force-pushed the joverbye-dedupe-optimisation branch from 2ba936d to 161675d Compare January 5, 2026 02:38
@clemyan clemyan requested a review from arcanis March 11, 2026 15:06
@arcanis
Copy link
Copy Markdown
Member

arcanis commented Apr 14, 2026

Hey ! One question:

causing unnecessary installs and lockfile updates

Which lockfile updates is it causing ? Are they really unnecessary ? Since the lockfile is supposed to be stable I'd assume that any lockfile update there would be triggered by something, and just skipping it could cause issues.

@jordanoverbye
Copy link
Copy Markdown
Author

Hey @arcanis,

The lockfile updates I was to referring to are the ones that happen when project.installWithNewReport() runs, even when there are zero packages to dedupe.

Currently, the dedupe command always calls project.installWithNewReport() at the end, regardless of whether any deduplication actually occurred. This means if no packages need deduping, we still run an an install. Depending on the --mode flag, this could be a full install or just a lockfile update

With this PR:

  • If there are no packages to dedupe, we exit early and skip the install entirely
  • If there are packages to dedupe, we proceed as normal with project.installWithNewReport()

So the "unnecessary" part refers specifically to the case where the dedupe operation found nothing to do - in that scenario, there's no reason to run an install or touch the lockfile at all. The lockfile should already be stable since we haven't made any changes.

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.

4 participants