Repository navigation
package-naming: cache std packages listing - #1809
Open
alexandear wants to merge 3 commits into
Open
alexandear wants to merge 3 commits into
alexandear wants to merge 3 commits into
Conversation
`package-naming` spawned a `go list std` subprocess on every `Configure` call when `check-collision-with-all-std` is enabled. The listing is now loaded once per process and shared by all rule instances, and it only requests package names instead of the full default load mode.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Package-level load failures may be cached permanently, and the new test does not verify cache behavior.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Caches standard-library package names to reduce repeated package-naming configuration overhead.
Changes:
- Adds a process-wide synchronized package-name cache.
- Uses
packages.NeedNameto reduce load cost. - Adds repeated-configuration coverage.
| File | Description |
|---|---|
rule/package_naming.go |
Implements cached standard-library loading. |
rule/package_naming_test.go |
Adds repeated configuration testing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
`packages.Load` can report per-package failures while returning a nil top-level error, so a partial standard library listing was cached for the lifetime of the process. Treat package errors as a load failure instead. Also configure separate rule instances in the test, so it exercises the process-wide cache rather than the per-instance early return.
alexandear
force-pushed
the
package-naming-cache-std
branch
from
September 25, 2026 12:42
74866c7 to
49dac86
Compare
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.


package-namingspawned ago list stdsubprocess on everyConfigurecall whencheck-collision-with-all-stdis enabled. The listing is now loaded once per process and shared by all rule instances, and it only requests package names instead of the full default load mode.Benchmarks
Measured on macOS machine with only
package-naming.check-collision-with-all-stdenabled.End-to-end revive run
GOCACHESource of the saving: load mode
packages.Loadof"std"in isolation (381 packages, 5 iterations, warm cache):NeedNameThe cache pays off only in processes that configure the rule more than once:
revivelib