Skip to content

Commit 3bef954

Browse files
robhoganfacebook-github-bot
authored andcommitted
Add unstable_preferTreeFS to use TreeFS without enabling symlinks
Summary: This allows the use of the new symlink-supporting prefix-tree `FileSystem` implementation, `TreeFS` *without* enabling symlinks. The main purpose of this is to allow like-for-like performance comparisons of operations at this level - in particular, startup involving assembling the tree, and resolution under the new `exists` implementation. Because `HasteFS` and `TreeFS` should have identical outputs on regular files, this setting is *not* a cache key component (unlike `resolver.unstable_enableSymlinks`). Reviewed By: motiz88 Differential Revision: D43539702 fbshipit-source-id: 92639845f42d6c7a3d626de9853c9c360b45367a
1 parent 69c8fc7 commit 3bef954

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap

+4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ Object {
169169
"interval": 30000,
170170
"timeout": 5000,
171171
},
172+
"unstable_preferTreeFS": false,
172173
"watchman": Object {
173174
"deferStates": Array [
174175
"hg.update",
@@ -347,6 +348,7 @@ Object {
347348
"interval": 30000,
348349
"timeout": 5000,
349350
},
351+
"unstable_preferTreeFS": false,
350352
"watchman": Object {
351353
"deferStates": Array [
352354
"hg.update",
@@ -525,6 +527,7 @@ Object {
525527
"interval": 30000,
526528
"timeout": 5000,
527529
},
530+
"unstable_preferTreeFS": false,
528531
"watchman": Object {
529532
"deferStates": Array [
530533
"hg.update",
@@ -703,6 +706,7 @@ Object {
703706
"interval": 30000,
704707
"timeout": 5000,
705708
},
709+
"unstable_preferTreeFS": false,
706710
"watchman": Object {
707711
"deferStates": Array [
708712
"hg.update",

packages/metro-config/src/configTypes.flow.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,16 @@ type SymbolicatorConfigT = {
187187

188188
type WatcherConfigT = {
189189
additionalExts: $ReadOnlyArray<string>,
190-
watchman: {
191-
deferStates: $ReadOnlyArray<string>,
192-
},
193190
healthCheck: {
194191
enabled: boolean,
195192
interval: number,
196193
timeout: number,
197194
filePrefix: string,
198195
},
196+
unstable_preferTreeFS: boolean,
197+
watchman: {
198+
deferStates: $ReadOnlyArray<string>,
199+
},
199200
};
200201

201202
export type InputConfigT = $Shape<{

packages/metro-config/src/defaults/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,16 @@ const getDefaultValues = (projectRoot: ?string): ConfigT => ({
138138
},
139139
watcher: {
140140
additionalExts,
141-
watchman: {
142-
deferStates: ['hg.update'],
143-
},
144141
healthCheck: {
145142
enabled: false,
146143
filePrefix: '.metro-health-check',
147144
interval: 30000,
148145
timeout: 5000,
149146
},
147+
unstable_preferTreeFS: false,
148+
watchman: {
149+
deferStates: ['hg.update'],
150+
},
150151
},
151152
cacheStores: [
152153
new FileStore({

packages/metro-file-map/src/index.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ export type InputOptions = $ReadOnly<{
9393
dependencyExtractor?: ?string,
9494
hasteImplModulePath?: ?string,
9595

96+
cacheManagerFactory?: ?CacheManagerFactory,
97+
console?: Console,
98+
healthCheck: HealthCheckOptions,
99+
maxWorkers: number,
96100
perfLoggerFactory?: ?PerfLoggerFactory,
97101
resetCache?: ?boolean,
98-
maxWorkers: number,
99102
throwOnModuleCollision?: ?boolean,
103+
unstable_preferTreeFS?: ?boolean,
100104
useWatchman?: ?boolean,
101-
watchmanDeferStates?: $ReadOnlyArray<string>,
102105
watch?: ?boolean,
103-
console?: Console,
104-
cacheManagerFactory?: ?CacheManagerFactory,
105-
106-
healthCheck: HealthCheckOptions,
106+
watchmanDeferStates?: $ReadOnlyArray<string>,
107107
}>;
108108

109109
type HealthCheckOptions = $ReadOnly<{
@@ -120,6 +120,7 @@ type InternalOptions = {
120120
resetCache: ?boolean,
121121
maxWorkers: number,
122122
throwOnModuleCollision: boolean,
123+
unstable_preferTreeFS: boolean,
123124
useWatchman: boolean,
124125
watch: boolean,
125126
watchmanDeferStates: $ReadOnlyArray<string>,
@@ -312,6 +313,7 @@ export default class HasteMap extends EventEmitter {
312313
perfLoggerFactory: options.perfLoggerFactory,
313314
resetCache: options.resetCache,
314315
throwOnModuleCollision: !!options.throwOnModuleCollision,
316+
unstable_preferTreeFS: !!options.unstable_preferTreeFS,
315317
useWatchman: options.useWatchman == null ? true : options.useWatchman,
316318
watch: !!options.watch,
317319
watchmanDeferStates: options.watchmanDeferStates ?? [],
@@ -359,7 +361,10 @@ export default class HasteMap extends EventEmitter {
359361
const rootDir = this._options.rootDir;
360362
const fileData = initialData.files;
361363
this._startupPerfLogger?.point('constructFileSystem_start');
362-
const FileSystem = this._options.enableSymlinks ? TreeFS : HasteFS;
364+
const useTreeFS =
365+
this._options.enableSymlinks || this._options.unstable_preferTreeFS;
366+
this._startupPerfLogger?.annotate({bool: {useTreeFS}});
367+
const FileSystem = useTreeFS ? TreeFS : HasteFS;
363368
const fileSystem = new FileSystem({
364369
files: fileData,
365370
rootDir,

packages/metro/src/node-haste/DependencyGraph/createHasteMap.js

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function createHasteMap(
9090
rootDir: config.projectRoot,
9191
roots: config.watchFolders,
9292
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
93+
unstable_preferTreeFS: config.watcher.unstable_preferTreeFS,
9394
useWatchman: config.resolver.useWatchman,
9495
watch: options?.watch == null ? !ci.isCI : options.watch,
9596
watchmanDeferStates: config.watcher.watchman.deferStates,

0 commit comments

Comments
 (0)