Skip to content

Commit ba0a7c5

Browse files
michaltcommit-bot@chromium.org
authored andcommitted
Disable watching for files generated by Bazel
Apparently this is causing some performance issues, so we might want to disable this until we can benchmark and optimize it. Bug: 44484 Change-Id: I8a661b128cbc8fdd425e4d3516a7ac132e511a99 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176521 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: David Morgan <[email protected]>
1 parent d017b8e commit ba0a7c5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ import 'package:path/path.dart' as pathos;
3838
import 'package:watcher/watcher.dart';
3939
import 'package:yaml/yaml.dart';
4040

41+
/// Enables watching of files generated by Bazel.
42+
///
43+
/// TODO(michalt): This is a temporary flag that we use to disable this
44+
/// functionality due its performance issues. We plan to benchmark and optimize
45+
/// it and re-enable it everywhere.
46+
/// Not private to enable testing.
47+
var experimentalEnableBazelWatching = false;
48+
4149
/// An indication of which files have been added, changed, removed, or deleted.
4250
///
4351
/// No file should be added to the change set more than once, either with the
@@ -1560,6 +1568,7 @@ class ContextManagerImpl implements ContextManager {
15601568
///
15611569
/// Does nothing if the [driver] is not in a Bazel workspace.
15621570
void _watchBazelFilesIfNeeded(Folder folder, AnalysisDriver analysisDriver) {
1571+
if (!experimentalEnableBazelWatching) return;
15631572
var workspace = analysisDriver.analysisContext.workspace;
15641573
if (workspace is BazelWorkspace &&
15651574
!bazelSubscriptions.containsKey(folder)) {

pkg/analysis_server/test/analysis/bazel_changes_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:async';
66
import 'package:analysis_server/protocol/protocol.dart';
77
import 'package:analysis_server/protocol/protocol_constants.dart';
88
import 'package:analysis_server/protocol/protocol_generated.dart';
9+
import 'package:analysis_server/src/context_manager.dart';
910
import 'package:analyzer_plugin/protocol/protocol_common.dart';
1011
import 'package:test/test.dart';
1112
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -36,6 +37,8 @@ class BazelChangesTest extends AbstractAnalysisTest {
3637
void setUp() {
3738
super.setUp();
3839

40+
experimentalEnableBazelWatching = true;
41+
3942
projectPath = convertPath('/workspaceRoot/third_party/dart/project');
4043
testFile =
4144
convertPath('/workspaceRoot/third_party/dart/project/lib/test.dart');
@@ -50,6 +53,8 @@ class BazelChangesTest extends AbstractAnalysisTest {
5053
// file watchers.
5154
server.contextManager.setRoots([], []);
5255

56+
experimentalEnableBazelWatching = false;
57+
5358
super.tearDown();
5459
}
5560

0 commit comments

Comments
 (0)