Repository navigation
perf(modules): reuse a replaced local module's lock - #270
Merged
Merged
Conversation
A consumer that wraps one local native module and adds no requirements of its own reuses that module's complete protobuf.lock instead of resolving the remote graph again. Local sources stay live, each cached revision still passes its content hash, and a changed graph, mod update, historical snapshots or import-root hints fall back to resolution. The consumer's own lock is never written by this path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our client module wraps the server module through a local
replaceand adds no requirements of its own:Every
easyp mod tidythere resolved the server module's remote graph from scratch, although../../proto/protobuf.lockalready pins all of it. With this change the consumer reuses that lock:mod tidyin our client module went from 13.9 s to 0.55 s, and the lock it writes is byte-identical.The shortcut only applies when the consumer has exactly one replacement, requires that module, and adds nothing else. The replaced module must take its roots from metadata, have no replacements of its own, and every selected revision must be reachable from its requirements. Local sources stay live, each cached revision still goes through its content hash, and the consumer's own lock is never written by this path. A missing lock, a changed graph,
--refresh,mod update, historical snapshots and explicit import-root hints all fall back to ordinary resolution; the tests ininternal/modules/overlay_pins_test.gocover those cases..spec/config/dependency.mddescribes the rule next to the other overlay behaviour.Checks:
go test ./internal/modules/passes and golangci-lint 2.15.0 reports nothing.go test ./internal/api/fails inTestLintLinkMatrixExitCodesandTestLintStdoutGolden, and it fails the same way on main without this change.