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
37bfb14956
commit
0c2ed4c3e5
@ -8,7 +8,7 @@
|
||||
*/
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import {resolve, setFileSystem, CachedFileSystem, NodeJSFileSystem} from '../../src/ngtsc/file_system';
|
||||
import {resolve, setFileSystem, NodeJSFileSystem} from '../../src/ngtsc/file_system';
|
||||
import {ConsoleLogger} from './logging/console_logger';
|
||||
import {LogLevel} from './logging/logger';
|
||||
import {NgccOptions} from './ngcc_options';
|
||||
@ -105,7 +105,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
setFileSystem(new CachedFileSystem(new NodeJSFileSystem()));
|
||||
setFileSystem(new NodeJSFileSystem());
|
||||
|
||||
const baseSourcePath = resolve(options['s'] || './node_modules');
|
||||
const propertiesToConsider: string[] = options['p'];
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
import * as cluster from 'cluster';
|
||||
|
||||
import {CachedFileSystem, NodeJSFileSystem, setFileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {parseCommandLineOptions} from '../../command_line_options';
|
||||
import {ConsoleLogger} from '../../logging/console_logger';
|
||||
import {Logger, LogLevel} from '../../logging/logger';
|
||||
@ -28,8 +27,6 @@ if (require.main === module) {
|
||||
process.title = 'ngcc (worker)';
|
||||
|
||||
try {
|
||||
setFileSystem(new CachedFileSystem(new NodeJSFileSystem()));
|
||||
|
||||
const {
|
||||
createNewEntryPointFormats = false,
|
||||
logger = new ConsoleLogger(LogLevel.info),
|
||||
|
@ -5,10 +5,9 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {ChildProcess, ChildProcessByStdio, fork} from 'child_process';
|
||||
import {Readable, Writable} from 'stream';
|
||||
import {ChildProcess, fork} from 'child_process';
|
||||
|
||||
import {AbsoluteFsPath, CachedFileSystem, FileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {AbsoluteFsPath, FileSystem} from '../../../../src/ngtsc/file_system';
|
||||
import {Logger, LogLevel} from '../../logging/logger';
|
||||
import {getLockFilePath, LockFile} from '../lock_file';
|
||||
|
||||
@ -58,11 +57,6 @@ export class LockFileWithChildProcess implements LockFile {
|
||||
|
||||
read(): string {
|
||||
try {
|
||||
if (this.fs instanceof CachedFileSystem) {
|
||||
// The lock-file file is "volatile", it might be changed by an external process,
|
||||
// so we must not rely upon the cached value when reading it.
|
||||
this.fs.invalidateCaches(this.path);
|
||||
}
|
||||
return this.fs.readFile(this.path);
|
||||
} catch {
|
||||
return '{unknown}';
|
||||
|
Reference in New Issue
Block a user