diff options
| author | Michael Matloob <matloob@golang.org> | 2023-12-20 12:37:35 -0500 |
|---|---|---|
| committer | Michael Matloob <matloob@golang.org> | 2023-12-21 16:03:52 +0000 |
| commit | 254ae6f648897483d05a3d2f7d6c35e1b80f4357 (patch) | |
| tree | 9fd89261b010cedbd9eaceed790614cccba0c3f9 /cmd/pkgsite | |
| parent | 4356cead6cb7f398ddc8ea3e9bcbd2ce15c0b504 (diff) | |
| download | go-x-pkgsite-254ae6f648897483d05a3d2f7d6c35e1b80f4357.tar.xz | |
cmd/pkgsite,internal/fetch: improve startup experience
When a user tries to look at the documentation for a unit for the
first time, we process all the packages in the module. Kick off
goroutines to do that so that the modules' packages might be processed
by the time the user sees them. Also parallelize processing the
packages in the module. That brings processing std from about 8 seconds
to about 3 seconds.
Change-Id: I505979d682897d2d1e55ce9e123e3ff4d1fb0e70
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/551776
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'cmd/pkgsite')
| -rw-r--r-- | cmd/pkgsite/main.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/pkgsite/main.go b/cmd/pkgsite/main.go index 3c50ff5b..7e6bd12e 100644 --- a/cmd/pkgsite/main.go +++ b/cmd/pkgsite/main.go @@ -420,6 +420,12 @@ func newServer(getters []fetch.ModuleGetter, localModules []frontend.LocalModule staticFS = static.FS } + // Preload local modules to warm the cache. + for _, lm := range localModules { + go lds.GetUnitMeta(context.Background(), "", lm.ModulePath, fetch.LocalVersion) + } + go lds.GetUnitMeta(context.Background(), "", "std", fetch.LocalVersion) + server, err := frontend.NewServer(frontend.ServerConfig{ DataSourceGetter: func(context.Context) internal.DataSource { return lds }, TemplateFS: template.TrustedFSFromEmbed(static.FS), |
