Skip to content

gomodfs, store/remotestore: fetch less over the network in WinFsp mode - #32

Merged
bradfitz merged 1 commit into
mainfrom
bradfitz/remotestore_fewer_fetches
Oct 6, 2026
Merged

bradfitz merged 1 commit into
mainfrom
bradfitz/remotestore_fewer_fetches

Conversation

@bradfitz

@bradfitz bradfitz commented Oct 6, 2026

Copy link
Copy Markdown
Member

Two changes that cut HTTP requests from a WinFsp mount to its remote
store:

Cache metadata files (.info, .mod and .ziphash) in remotestore.Store.
They never change for a module version, but every stat and open of one
fetched it from the server again, and the go command reads hundreds of
them per invocation, mostly one at a time while loading the module
graph. Over 8 cached go commands, that was about 13,600 requests at
about 1ms each. Like modmaps, they're cached for the life of the Store,
with concurrent fetches merged. Misses aren't cached.

Fetch a file's contents on its first read rather than when it's opened.
Windows opens files for many things that don't read them, including
every os.Stat, and each open downloaded the whole file. Opens now get
the size and type from the store's (cached) modmap, so an HTTP error
fails the first read instead of the open.

In a Windows VM with the module cache and Tailscale Go toolchain served
from a remote store, fully cached go commands (median of 30, p < 1e-10):

go build tailscale.com/cmd/tailscale/cli: 4.90s -> 2.21s
go run github.com/tc-hib/go-winres:       2.59s -> 1.58s

and the first command after mounting goes from 5.73s to 3.10s and from
2.50s to 1.26s. (On NTFS, both take under 0.3s.) "go mod verify" of all
75 modules of the build still passes over the mount.

Updates tailscale/corp#24037

Two changes that cut HTTP requests from a WinFsp mount to its remote
store:

Cache metadata files (.info, .mod and .ziphash) in remotestore.Store.
They never change for a module version, but every stat and open of one
fetched it from the server again, and the go command reads hundreds of
them per invocation, mostly one at a time while loading the module
graph. Over 8 cached go commands, that was about 13,600 requests at
about 1ms each. Like modmaps, they're cached for the life of the Store,
with concurrent fetches merged. Misses aren't cached.

Fetch a file's contents on its first read rather than when it's opened.
Windows opens files for many things that don't read them, including
every os.Stat, and each open downloaded the whole file. Opens now get
the size and type from the store's (cached) modmap, so an HTTP error
fails the first read instead of the open.

In a Windows VM with the module cache and Tailscale Go toolchain served
from a remote store, fully cached go commands (median of 30, p < 1e-10):

	go build tailscale.com/cmd/tailscale/cli: 4.90s -> 2.21s
	go run github.com/tc-hib/go-winres:       2.59s -> 1.58s

and the first command after mounting goes from 5.73s to 3.10s and from
2.50s to 1.26s. (On NTFS, both take under 0.3s.) "go mod verify" of all
75 modules of the build still passes over the mount.

Updates tailscale/corp#24037

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@bradfitz
bradfitz merged commit cfc4a82 into main Oct 6, 2026
7 checks passed
@bradfitz
bradfitz deleted the bradfitz/remotestore_fewer_fetches branch October 6, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant