Repository navigation
Conversation
87f9e5a to
72f97a1
Compare
|
To benchmark, I just created a 200 package repo with some nestjs dependencies that would enable building a simple hello world http server and then I did a |
|
I had the same idea about 2 years ago (main...patricktree:pnpm:feat/lockfile-per-workspace-project), and still think this would be great.
|
9cbefcf to
f19c361
Compare
|
Sorry for the noise earlier, the CI passes on my fork. I https://github.com/nhomble/pnpm/actions/runs/24415887094 there was a separate change needed for a different dependency that I figured would deserve its own changeset so I didn't cherry pick into this pr: f1cf4db#diff-18ae0a0fab29a7db7aded913fd05f30a2c8f6c104fadae86c9d217091709794cR410 |
|
Is it preferred to wait until there's agreement on the changeset or should I preemptively resolve the conflict and wait for CI to be reran @zkochan? I'm happy to do whatever helps out. |
Add `lockfileStorage: split` setting that stores per-package lockfiles while using the fast shared resolution path. ``` sharedWorkspaceLockfile: false lockfileStorage: split ```
f19c361 to
c9bc09d
Compare
|
@zkochan I apologize for jumping straight into a solution. Maybe we can use this MR thread or the linked issues to discuss/groom other strategies for 100+ package monorepos dealing with conflicting lockfiles. I can definitely sympathize any apprehension to adding a whole new lockfile style. If there is an alternative, I'm more than happy to try it. |
|
I think you can already make the existing install with dedicated lockfiles fast by enabling the global virtual store: https://pnpm.io/11.x/settings#enableglobalvirtualstore I personally don't understand why it is useful to have dedicated lockfiles. |
I apologize for misunderstanding. For the global virtual stores,
I don't know how this will help me with slow installs in my CI environment (if I turn off shared lockfile). At least in practice,
has only been proposed in my team as a way to reduce the number of conflicts in the central lockfile. When new projects are added or dependencies are just added a subset of projects, we are hoping for less conflicts to happen in the distributed lockfiles. |
|
Don't you think the amount of conflicts will actually grow as now the same conflicts will happen in multiple files instead of just one file? |
Conflicts with the pnpm-lock files seem pretty binary to me because in a conflict, I've seen it recommended (I'll try to find and link) that the clearest resolution path is just to let What does change with the many files is that local changes to a pnpm package have a smaller chance of conflicting with another team's package change. Some examples:
These examples shouldn't cause conflicts since they're isolated to a specific lockfile. Where I can agree is when we do changes in the If there are better strategies for this process, I would be happy to adapt. Finally, maybe you could teach me more about the original intent of the configuration to disable a root lockfile. I thought this was the problem you were trying to solve, but if I am misunderstanding the use of this feature I could try something else. FWIW we did consider the branch per lockfile mode, the multi step process to prune and merge the branch lockfiles on trunk was not appealing. |
It was just the very first implementation of multi-package support. I believe it was easier to implement it this way (in 2016). But then people started using it and now it is hard to remove. I personally don't see a point in multiple lockfiles.
so this is only conflicts in the "importers" section. If you update a transitive dependency in one project the same update will happen in multiple other lockfiles increasing the area for conflicts. So maybe you will reduce one type of conflicts but won't eliminate conflicts. |
|
The context on the initial implementation is helpful. Beyond just the conflicts, it's probably unwise then for any project to stick to a feature you would prefer gets deprecated.
For sure... if it's ok, maybe we take a step back from this implementation and consider this more of a discussion (I'd be happy to migrate to another github issue if that's preferred for SEO). Are there any other preferred strategies for this conflict problem? |
|
I am not sure because the current lockfile format is the result of several iterations already that were aimed at reducing the number of conflicts. And |
Yep, I noticed that pnpm resolver project as well. The issue in my case is that we are using gitlab saas so it doesn't matter what I configure locally if gitlab treats the mr as conflicted. Before I migrate to the linked issue, are you thinking there's no point to improve the performance of the distributed lockfile then going forward for pnpm (such that I should close this pr)? |
|
The problem that you try to solve with conflicts in the importers section would be solved best by moving direct resolutions of dependencies into separate lockfiles. Like this Lines 3078 to 3085 in 4bf61ba deps/compliance/license-resolver/pnpm-lock-importer.yaml. But then we add a lot of additional file system operations to read all those additional files. I am not sure it makes sense. Maybe with AI we can come up with a solution that eliminates diffs, I don't know.
|
|
thanks for the ref! I'll check it out.
this specifically seemed to be the insight in this changeset with the distributed lockfile. Actually reading all of the files once and merging into a single in-memory representation was a lot more efficient than doing the operations on a per file basis |
|
i am closing it for now. We can discuss it in a discussion if needed |
Add
lockfileStorage: splitsetting that stores per-package lockfiles while using the fast shared resolution path. Before resolution, per-package lockfiles are merged into a temporary unified lockfile. After resolution via mutateModules(), the result is split back into per-package files using filterLockfileByImporters + pruneSharedLockfile.This avoids the ~10x performance penalty of shared-workspace-lockfile=false (which runs N independent install cycles) while still providing per-package lockfiles that reduce git merge conflicts and improve CI cache granularity in large monorepos.
Includes a .pnpm-split-in-progress sentinel file for crash recovery.
AI Usage:
Out of transparency, I did use opus 4.6 to help me do the analysis and prepare the code change, but the pain points I mentioned in #8334 are real and I'd be happy to report back the results.
Refs:
shared-workspace-lockfile=falsewell supported and as fast asshared-workspace-lockfile=true#8334