Skip to content

Commit 4ab1aec

Browse files
AdallomRoymatloob
authored andcommitted
cmd/go: modload should use a read-write lock to improve concurrency
This PR will be imported into Gerrit with the title and first comment (this text) used to generate the subject and body of the Gerrit change. Change-Id: I3f9bc8a2459059a924a04fa02794e258957819b5 GitHub-Last-Rev: 6ad6f6a GitHub-Pull-Request: #74311 Reviewed-on: https://go-review.googlesource.com/c/go/+/683215 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Ian Alexander <jitsu@google.com> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent e666972 commit 4ab1aec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cmd/go/internal/modload/init.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type MainModuleSet struct {
149149
// highest replaced version of each module path; empty string for wildcard-only replacements
150150
highestReplaced map[string]string
151151

152-
indexMu sync.Mutex
152+
indexMu sync.RWMutex
153153
indices map[module.Version]*modFileIndex
154154
}
155155

@@ -228,8 +228,8 @@ func (mms *MainModuleSet) GetSingleIndexOrNil() *modFileIndex {
228228
}
229229

230230
func (mms *MainModuleSet) Index(m module.Version) *modFileIndex {
231-
mms.indexMu.Lock()
232-
defer mms.indexMu.Unlock()
231+
mms.indexMu.RLock()
232+
defer mms.indexMu.RUnlock()
233233
return mms.indices[m]
234234
}
235235

0 commit comments

Comments
 (0)