]> Cypherpunks repositories - gostls13.git/commit
cmd/go: use package index for std in load.loadPackageData
authorRuss Cox <rsc@golang.org>
Tue, 5 Jul 2022 17:53:35 +0000 (13:53 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 11 Jul 2022 16:51:38 +0000 (16:51 +0000)
commitf956941b0f5a5a841827bd3e84401d32916bb73e
tree71ef01c5cdce843651fb8180e6c6bc683d11bfcb
parent59ab6f351a370a27458755dc69f4a837e55a05a6
cmd/go: use package index for std in load.loadPackageData

load.loadPackageData was only using an index for modules,
not for standard library packages. Other parts of the code were
using the index, so there was some benefit, but not as much
as you'd hope.

With the index disabled, the Script/work test takes 2.2s on my Mac.
With the index enabled before this CL, it took 2.0s.
With the index enabled after this CL, it takes 1.6s.

Before this CL, the Script/work test issued:

 429 IsDir
  19 IsDirWithGoFiles
   7 Lstat
9072 Open
 993 ReadDir
 256 Stat
   7 Walk
   3 indexModule
  24 openIndexModule
 525 openIndexPackage

After this CL, it issued:

  19 IsDirWithGoFiles
   7 Lstat
  60 Open
 606 ReadDir
 256 Stat
   7 Walk
   3 indexModule
  24 openIndexModule
 525 openIndexPackage

This speedup helps the Dragonfly builder, which has very slow
file I/O and is timing out since a recent indexing change.

Times for go test -run=Script/^work$ on the Dragonfly builder:

50s before indexing changes
31s full module indexing of std
46s per-package indexing of std

It cuts the time for go test -run=Script/^work$ from 44s to 20s.

For #53577.

Change-Id: I7189a77fc7fdf61de3ab3447efc4e84d1fc52c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/416134
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/fsys/fsys.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/modindex/read.go
src/cmd/go/internal/modindex/scan.go
src/cmd/go/testdata/script/index.txt [new file with mode: 0644]