Skip to content

perf(modules): reuse a replaced local module's lock - #270

Merged
ZergsLaw merged 1 commit into
easyp-tech:mainfrom
yaroher:feat/replacement-lock-reuse
Dec 4, 2026
Merged

ZergsLaw merged 1 commit into
easyp-tech:mainfrom
yaroher:feat/replacement-lock-reuse

Conversation

@yaroher

@yaroher yaroher commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Our client module wraps the server module through a local replace and adds no requirements of its own:

module github.com/naukograd-software/komeet/clients/proto
require github.com/naukograd-software/komeet/proto v0.0.0
replace github.com/naukograd-software/komeet/proto => ../../proto

Every easyp mod tidy there resolved the server module's remote graph from scratch, although ../../proto/protobuf.lock already pins all of it. With this change the consumer reuses that lock: mod tidy in 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 in internal/modules/overlay_pins_test.go cover those cases.

.spec/config/dependency.md describes 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 in TestLintLinkMatrixExitCodes and TestLintStdoutGolden, and it fails the same way on main without this change.

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.
@ZergsLaw
ZergsLaw merged commit 6bdfc29 into easyp-tech:main Dec 4, 2026
4 checks passed
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.

2 participants