Skip to content

Commit 2f1d1bd

Browse files
Jean Lauliacfacebook-github-bot
authored andcommitted
packager: Module: remove too-many-misses codepath
Summary: This code is a bit sloppy, I need to rethink about it. So I prefer to remove it altogether for now. The problem with this is that it is disabling the global cache "put" operations at the same time, so the script supposed to update the cache actually doesn't do the job past the fist few hundred files. This defeats the purpose of the global cache. Reviewed By: cpojer Differential Revision: D4346927 fbshipit-source-id: 5b668e66b1909f53783772c613781753ac605546
1 parent 3998650 commit 2f1d1bd

File tree

1 file changed

+1
-20
lines changed
  • packager/react-packager/src/node-haste

1 file changed

+1
-20
lines changed

packager/react-packager/src/node-haste/Module.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ import type Cache from './Cache';
3131
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
3232
import type ModuleCache from './ModuleCache';
3333

34-
/**
35-
* If the global cache returns empty that many times, we give up using the
36-
* global cache for that instance. This speeds up the build.
37-
*/
38-
const GLOBAL_CACHE_MAX_MISSES = 250;
39-
4034
type ReadResult = {
4135
code: string,
4236
dependencies?: ?Array<string>,
@@ -85,7 +79,6 @@ class Module {
8579
_readPromises: Map<string, Promise<ReadResult>>;
8680

8781
static _globalCacheRetries: number;
88-
static _globalCacheMaxMisses: number;
8982

9083
constructor({
9184
file,
@@ -272,8 +265,7 @@ class Module {
272265
) {
273266
const globalCache = GlobalTransformCache.get();
274267
const noMoreRetries = Module._globalCacheRetries <= 0;
275-
const tooManyMisses = Module._globalCacheMaxMisses <= 0;
276-
if (globalCache == null || noMoreRetries || tooManyMisses) {
268+
if (globalCache == null || noMoreRetries) {
277269
this._transformCodeForCallback(cacheProps, callback);
278270
return;
279271
}
@@ -292,19 +284,9 @@ class Module {
292284
}
293285
}
294286
if (globalCachedResult == null) {
295-
--Module._globalCacheMaxMisses;
296-
if (Module._globalCacheMaxMisses === 0) {
297-
this._reporter.update({
298-
type: 'global_cache_disabled',
299-
reason: 'too_many_misses',
300-
});
301-
}
302287
this._transformAndStoreCodeGlobally(cacheProps, globalCache, callback);
303288
return;
304289
}
305-
if (Module._globalCacheMaxMisses < GLOBAL_CACHE_MAX_MISSES) {
306-
++Module._globalCacheMaxMisses;
307-
}
308290
callback(undefined, globalCachedResult);
309291
});
310292
}
@@ -404,7 +386,6 @@ class Module {
404386
}
405387

406388
Module._globalCacheRetries = 4;
407-
Module._globalCacheMaxMisses = GLOBAL_CACHE_MAX_MISSES;
408389

409390
// use weak map to speed up hash creation of known objects
410391
const knownHashes = new WeakMap();

0 commit comments

Comments
 (0)