fix(ngcc): do not use cached file-system (#36687)
The cached file-system was implemented to speed up ngcc processing, but in reality most files are not accessed many times and there is no noticeable degradation in speed by removing it. Benchmarking `ngcc -l debug` for AIO on a local machine gave a range of 196-236 seconds with the cache and 197-224 seconds without the cache. Moreover, when running in parallel mode, ngcc has a separate file cache for each process. This results in excess memory usage. Notably the master process, which only does analysis of entry-points holds on to up to 500Mb for AIO when using the cache compared to only around 30Mb when not using the cache. Finally, the file-system cache being incorrectly primed with file contents before being processed has been the cause of a number of bugs. For example https://github.com/angular/angular-cli/issues/16860#issuecomment-614694269. PR Close #36687
This commit is contained in:

committed by
Matias Niemelä

parent
a22d4f6c98
commit
18be33a9d1
@ -8,7 +8,7 @@
|
||||
import {ChildProcess} from 'child_process';
|
||||
import * as process from 'process';
|
||||
|
||||
import {CachedFileSystem, FileSystem, getFileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {FileSystem, getFileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../../src/ngtsc/file_system/testing';
|
||||
import {getLockFilePath} from '../../../src/locking/lock_file';
|
||||
import {LockFileWithChildProcess} from '../../../src/locking/lock_file_with_child_process';
|
||||
@ -97,18 +97,6 @@ runInEachFileSystem(() => {
|
||||
const lockFile = new LockFileUnderTest(fs);
|
||||
expect(lockFile.read()).toEqual('{unknown}');
|
||||
});
|
||||
|
||||
it('should not read file from the cache, since the file may have been modified externally',
|
||||
() => {
|
||||
const rawFs = getFileSystem();
|
||||
const fs = new CachedFileSystem(rawFs);
|
||||
const lockFile = new LockFileUnderTest(fs);
|
||||
rawFs.writeFile(lockFile.path, '' + process.pid);
|
||||
expect(lockFile.read()).toEqual('' + process.pid);
|
||||
// We need to write to the rawFs to ensure that we don't update the cache at this point
|
||||
rawFs.writeFile(lockFile.path, '444');
|
||||
expect(lockFile.read()).toEqual('444');
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove()', () => {
|
||||
|
Reference in New Issue
Block a user