Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: cached fs utils with shared trees #15294

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4d666ab
perf: cached fs utils
patak-dev Dec 7, 2023
aac3690
chore: merge main
patak-dev Dec 7, 2023
524a52a
fix: temporal guard for custom watchers
patak-dev Dec 7, 2023
c929f96
feat: add experimental server.fs.cacheChecks
patak-dev Dec 7, 2023
2fbf00a
feat: also enable fsUtils in createResolver
patak-dev Dec 7, 2023
2f25f9e
chore: update types
patak-dev Dec 7, 2023
a343c66
feat: optimize on add file or directory
patak-dev Dec 7, 2023
89df6d5
feat: optimize tryResolveRealFileWithExtensions
patak-dev Dec 8, 2023
d3d45fc
feat: avoid double normalizePath calls
patak-dev Dec 8, 2023
8ea355e
chore: update
patak-dev Dec 8, 2023
df42d68
chore: remove watch null and custom ignored guard
patak-dev Dec 8, 2023
93572c8
chore: lint
patak-dev Dec 8, 2023
c3d504b
chore: merge main
patak-dev Dec 8, 2023
cfb8693
feat: shared dirent caches
patak-dev Dec 8, 2023
42f689f
fix: only register valid active configs
patak-dev Dec 8, 2023
cc9c8e9
chore: merge main
patak-dev Jan 25, 2024
0104871
chore: update
patak-dev Jan 25, 2024
ab5bc15
chore: update
patak-dev Jan 25, 2024
93d0815
chore: merge main
patak-dev Jan 26, 2024
4b37e14
chore: merge main
patak-dev Jan 26, 2024
1ba78ab
fix: connectRootCacheToActiveRoots
patak-dev Jan 26, 2024
9aef77d
fix: use workspace root
patak-dev Jan 26, 2024
37dcc60
chore: simplify
patak-dev Jan 27, 2024
b3768f1
chore: test
patak-dev Jan 27, 2024
4c409f1
chore: enable back
patak-dev Jan 27, 2024
e11de80
fix: add file to cache servers sharing a root
patak-dev Jan 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: enable back
  • Loading branch information
patak-dev committed Jan 27, 2024
commit 4c409f1b5391af4f3c0c1a210b2db3b6f45e3b4d
18 changes: 4 additions & 14 deletions packages/vite/src/node/fsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ export function getFsUtils(config: ResolvedConfig): FsUtils {
fsUtils = commonFsUtils
} else {
fsUtils = createCachedFsUtils(config)
if (!fsUtils) {
fsUtils = commonFsUtils
} else {
addActiveResolvedConfig(config, fsUtils)
}
addActiveResolvedConfig(config, fsUtils)
}
cachedFsUtilsMap.set(config, fsUtils)
}
Expand Down Expand Up @@ -146,8 +142,7 @@ interface CachedFsUtilsMeta {
}
const cachedFsUtilsMeta = new WeakMap<ResolvedConfig, CachedFsUtilsMeta>()

function createSharedRootCache(root: string): DirentCache | undefined {
/* commented to test ecosystem CI
function createSharedRootCache(root: string): DirentCache {
for (const otherConfigRef of activeResolvedConfigs) {
const otherConfig = otherConfigRef?.deref()
if (otherConfig) {
patak-dev marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -160,7 +155,6 @@ function createSharedRootCache(root: string): DirentCache | undefined {
}
}
}
*/

debug?.(`FsUtils for ${root} started as an new root cache`)
return { type: 'directory' as DirentCacheType } // dirents will be computed lazily
Expand All @@ -172,16 +166,12 @@ function pathUntilPart(root: string, parts: string[], i: number): string {
return p
}

function createCachedFsUtils(config: ResolvedConfig): FsUtils | undefined {
function createCachedFsUtils(config: ResolvedConfig): FsUtils {
const root = normalizePath(searchForWorkspaceRoot(config.root))
const rootDirPath = `${root}/`
const rootCache = createSharedRootCache(root)
if (!rootCache) {
return
}
cachedFsUtilsMeta.set(config, { root, rootCache })

const rootDirPath = `${root}/`

const getDirentCacheSync = (parts: string[]): DirentCache | undefined => {
let direntCache: DirentCache = rootCache
for (let i = 0; i < parts.length; i++) {
Expand Down
Loading