]> Cypherpunks repositories - gostls13.git/commit
go/internal/gcimporter: load cached export data for packages individually
authorBryan C. Mills <bcmills@google.com>
Thu, 1 Dec 2022 18:39:39 +0000 (13:39 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 1 Dec 2022 22:04:03 +0000 (22:04 +0000)
commit6a70292d1cb3464e5b2c2c03341e5148730a1889
treed4f3d338b461bdd862b4e1efb81cdf95e46ee58e
parent0e8b6056c99daebcc3c571316a9551c9fab03a00
go/internal/gcimporter: load cached export data for packages individually

Previously, we were using internal/goroot.PkgfileMap to locate
cached export data. However, PkgfileMap regenerates export data
for the entire standard library, whereas gcimporter may only need
a single package.

Under the new approach, we load the export data (still using
'go list -export') for each GOROOT package individually, avoiding work
to rebuild export data for packages that are not needed.
This is a tradeoff: if most packages in GOROOT are actually needed, we
end up making many more calls to 'go list', and may build packages
sequentially instead of in parallel (but with lower latency to start
using the export data from the earlier packages).

On my workstation, starting from a clean cache for each run,
this reduces the wall time of
'go test go/internal/gcimporter -run=TestImportedTypes'
from 22s real time (2m10s user time) to 6s real (27s user),
and only increases 'go test go/internal/gcimporter' from
28s real (2m16s user) to 30s real (2m19s user).

Updates #56967.
Updates #47257.

Change-Id: I22556acdd9b1acc56533ed4c2728ea29b585c073
Reviewed-on: https://go-review.googlesource.com/c/go/+/454497
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
src/cmd/compile/internal/importer/gcimporter.go
src/go/internal/gcimporter/gcimporter.go
src/internal/goroot/importcfg.go
src/internal/testenv/testenv.go