Use shared FileContentOverlay in AnalysisContextCollection to ensure content sharing.

This improves performance, and it looks that this might be the issue
that causes Golem to timeout today.

Change-Id: I7a71fb3f6829f55205d8f7fc028245d529501389
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-02-23 06:03:29 +00:00 committed by commit-bot@chromium.org
parent 2e3d1c2bcd
commit 98c83633a2
2 changed files with 5 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/context_builder.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
import 'package:cli_util/cli_util.dart';
@ -50,6 +51,7 @@ class AnalysisContextCollectionImpl implements AnalysisContextCollection {
includedPaths: includedPaths,
excludedPaths: excludedPaths,
);
var fileContentOverlay = FileContentOverlay();
for (var root in roots) {
var contextBuilder = ContextBuilderImpl(
resourceProvider: this.resourceProvider,
@ -60,6 +62,7 @@ class AnalysisContextCollectionImpl implements AnalysisContextCollection {
declaredVariables: DeclaredVariables.fromMap(declaredVariables ?? {}),
drainStreams: drainStreams,
enableIndex: enableIndex,
fileContentOverlay: fileContentOverlay,
performanceLog: performanceLog,
retainDataForTesting: retainDataForTesting,
sdkPath: sdkPath,

View file

@ -43,6 +43,7 @@ class ContextBuilderImpl implements ContextBuilder {
DeclaredVariables? declaredVariables,
bool drainStreams = true,
bool enableIndex = false,
FileContentOverlay? fileContentOverlay,
List<String>? librarySummaryPaths,
PerformanceLog? performanceLog,
bool retainDataForTesting = false,
@ -54,7 +55,7 @@ class ContextBuilderImpl implements ContextBuilder {
ArgumentError.checkNotNull(sdkPath, 'sdkPath');
byteStore ??= MemoryByteStore();
var fileContentOverlay = FileContentOverlay();
fileContentOverlay ??= FileContentOverlay();
performanceLog ??= PerformanceLog(StringBuffer());
DartSdkManager sdkManager = DartSdkManager(sdkPath);