mirror of https://github.com/status-im/metro.git
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
This commit is contained in:
parent
379daeb0d1
commit
79e12e59bd
react-packager/src/node-haste
|
@ -31,12 +31,6 @@ import type Cache from './Cache';
|
||||||
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
|
import type DependencyGraphHelpers from './DependencyGraph/DependencyGraphHelpers';
|
||||||
import type ModuleCache from './ModuleCache';
|
import type ModuleCache from './ModuleCache';
|
||||||
|
|
||||||
/**
|
|
||||||
* If the global cache returns empty that many times, we give up using the
|
|
||||||
* global cache for that instance. This speeds up the build.
|
|
||||||
*/
|
|
||||||
const GLOBAL_CACHE_MAX_MISSES = 250;
|
|
||||||
|
|
||||||
type ReadResult = {
|
type ReadResult = {
|
||||||
code: string,
|
code: string,
|
||||||
dependencies?: ?Array<string>,
|
dependencies?: ?Array<string>,
|
||||||
|
@ -85,7 +79,6 @@ class Module {
|
||||||
_readPromises: Map<string, Promise<ReadResult>>;
|
_readPromises: Map<string, Promise<ReadResult>>;
|
||||||
|
|
||||||
static _globalCacheRetries: number;
|
static _globalCacheRetries: number;
|
||||||
static _globalCacheMaxMisses: number;
|
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
file,
|
file,
|
||||||
|
@ -272,8 +265,7 @@ class Module {
|
||||||
) {
|
) {
|
||||||
const globalCache = GlobalTransformCache.get();
|
const globalCache = GlobalTransformCache.get();
|
||||||
const noMoreRetries = Module._globalCacheRetries <= 0;
|
const noMoreRetries = Module._globalCacheRetries <= 0;
|
||||||
const tooManyMisses = Module._globalCacheMaxMisses <= 0;
|
if (globalCache == null || noMoreRetries) {
|
||||||
if (globalCache == null || noMoreRetries || tooManyMisses) {
|
|
||||||
this._transformCodeForCallback(cacheProps, callback);
|
this._transformCodeForCallback(cacheProps, callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -292,19 +284,9 @@ class Module {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (globalCachedResult == null) {
|
if (globalCachedResult == null) {
|
||||||
--Module._globalCacheMaxMisses;
|
|
||||||
if (Module._globalCacheMaxMisses === 0) {
|
|
||||||
this._reporter.update({
|
|
||||||
type: 'global_cache_disabled',
|
|
||||||
reason: 'too_many_misses',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this._transformAndStoreCodeGlobally(cacheProps, globalCache, callback);
|
this._transformAndStoreCodeGlobally(cacheProps, globalCache, callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Module._globalCacheMaxMisses < GLOBAL_CACHE_MAX_MISSES) {
|
|
||||||
++Module._globalCacheMaxMisses;
|
|
||||||
}
|
|
||||||
callback(undefined, globalCachedResult);
|
callback(undefined, globalCachedResult);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -404,7 +386,6 @@ class Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
Module._globalCacheRetries = 4;
|
Module._globalCacheRetries = 4;
|
||||||
Module._globalCacheMaxMisses = GLOBAL_CACHE_MAX_MISSES;
|
|
||||||
|
|
||||||
// use weak map to speed up hash creation of known objects
|
// use weak map to speed up hash creation of known objects
|
||||||
const knownHashes = new WeakMap();
|
const knownHashes = new WeakMap();
|
||||||
|
|
Loading…
Reference in New Issue