Skip to content

cmd/go: modload should use a read-write lock to improve concurrency #74311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cmd/go/internal/modload/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type MainModuleSet struct {
// highest replaced version of each module path; empty string for wildcard-only replacements
highestReplaced map[string]string

indexMu sync.Mutex
indexMu sync.RWMutex
indices map[module.Version]*modFileIndex
}

Expand Down Expand Up @@ -228,8 +228,8 @@ func (mms *MainModuleSet) GetSingleIndexOrNil() *modFileIndex {
}

func (mms *MainModuleSet) Index(m module.Version) *modFileIndex {
mms.indexMu.Lock()
defer mms.indexMu.Unlock()
mms.indexMu.RLock()
defer mms.indexMu.RUnlock()
return mms.indices[m]
}

Expand Down