Skip to content

gomodfs: cache file contents in WinFsp mode - #33

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

bradfitz merged 1 commit into
mainfrom
bradfitz/winfsp_contents_cache

Conversation

@bradfitz

@bradfitz bradfitz commented Oct 6, 2026

Copy link
Copy Markdown
Member

WinFsp mode fetched a file's contents from the store on the first read
of each open, and Windows doesn't keep a file's cached data once no
process has it open, so every go command fetched every file it read
again. In a Windows VM serving from a remote store, three identical
cached builds each fetched the same ~2,880 files.

Keep fetched contents in an LRU cache on FS keyed by module version and
path, bounded like the NFS contents cache by GetFileCacheSize (the
--mem-limit-mb flag, default 2 GiB). The NFS cache is keyed by NFS
handle, so WinFsp couldn't use it.

In that VM, fully cached go commands (median of 30, p < 1e-10):

go build tailscale.com/cmd/tailscale/cli: 2.23s -> 0.98s
go run github.com/tc-hib/go-winres:       1.73s -> 0.64s

The first command after mounting isn't helped, as everything is a miss
then. "go mod verify" of all 75 modules of the build passes over the
mount, as does a full build of tailscale.com/cmd/tailscale.

Updates tailscale/corp#24037

WinFsp mode fetched a file's contents from the store on the first read
of each open, and Windows doesn't keep a file's cached data once no
process has it open, so every go command fetched every file it read
again. In a Windows VM serving from a remote store, three identical
cached builds each fetched the same ~2,880 files.

Keep fetched contents in an LRU cache on FS keyed by module version and
path, bounded like the NFS contents cache by GetFileCacheSize (the
--mem-limit-mb flag, default 2 GiB). The NFS cache is keyed by NFS
handle, so WinFsp couldn't use it.

In that VM, fully cached go commands (median of 30, p < 1e-10):

	go build tailscale.com/cmd/tailscale/cli: 2.23s -> 0.98s
	go run github.com/tc-hib/go-winres:       1.73s -> 0.64s

The first command after mounting isn't helped, as everything is a miss
then. "go mod verify" of all 75 modules of the build passes over the
mount, as does a full build of tailscale.com/cmd/tailscale.

Updates tailscale/corp#24037

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@bradfitz
bradfitz merged commit 4d31752 into main Oct 6, 2026
7 checks passed
@bradfitz
bradfitz deleted the bradfitz/winfsp_contents_cache branch October 6, 2026 17:44
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