Commit Graph
1 Commits
Author SHA1 Message Date
yetone 15066f84f6 appdir: a folder and file name are joined once, not on every read
appdir.Config and Cache, catalog.CachePath and LivePath, settings.Path,
provider.Path and the logins path each ran filepath.Join on every call,
and they are called on every read of a cached file, many times a request.
Those joins were 70 MB of the 1.4 GB twenty window polls allocated.
appdir.Join and JoinFile keep each (dir, name, ext) they joined, up to
4096 of them, so a path named again is the same string. A changed HOME
or folder is a different key, so a test's sandbox still gets its own
path.

TestFoldersJoinedOnce and TestLivePathNamedOnce: 0 allocations a call.
Broken by hand on mote (the files before this change) they are red at 1
allocation a call, and 3 for LivePath.

Run on mote at this tree (on d714c4216): gofmt clean; vet ok on darwin,
windows and linux (appdir, catalog, settings, provider); go build ok;
appdir, catalog, settings (49s), provider (187s), agent (324s) and
gateway (1244s) ok.

At the pushed head (on 019bfc951, which adds provider.Held): vet of
appdir, catalog, settings, provider and gui ok, go build ok, appdir,
catalog and gui's TestAccountLabelsBuildTheAgentsOnce ok.
2026-11-01 03:52:46 +08:00