Skip to content

Commit

Permalink
Only add new shouldPropagate logic for Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Apr 23, 2024
1 parent 17d2671 commit d4ecb99
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ protected MemoizingEvaluator createEvaluator(
recordingDiffer,
progressReceiver,
inconsistencyReceiver,
trackIncrementalState ? DEFAULT_EVENT_FILTER_WITH_ACTIONS : EventFilter.NO_STORAGE,
trackIncrementalState
? (shouldStoreTransitivePackagesInLoadingAndAnalysis()
? DEFAULT_EVENT_FILTER_WITH_ACTIONS_AND_EXTERNAL_REPOS
: DEFAULT_EVENT_FILTER_WITH_ACTIONS)
: EventFilter.NO_STORAGE,
emittedEventState,
trackIncrementalState,
/* usePooledInterning= */ true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,12 +972,6 @@ public boolean storeEvents() {

@Override
public boolean shouldPropagate(SkyKey depKey, SkyKey primaryKey) {
// Bzlmod events do not need to be propagated to analysis nodes. They are propagated to
// the node for the main repo mapping, which is unconditionally requested in a separate
// Skyframe evaluation for every build, thus ensuring correct incremental behavior.
if (isBzlmodKey(depKey)) {
return isBzlmodKey(primaryKey);
}
// Do not propagate events from analysis phase nodes to execution phase nodes.
return isAnalysisPhaseActionLookupKey(primaryKey)
|| !isAnalysisPhaseActionLookupKey(depKey)
Expand All @@ -990,6 +984,29 @@ private static boolean isAnalysisPhaseActionLookupKey(SkyKey key) {
return key instanceof ActionLookupKey && !(key instanceof ActionTemplateExpansionKey);
}

/**
* A variant of {@link #DEFAULT_EVENT_FILTER_WITH_ACTIONS} that also handles Bzlmod events, which
* are only relevant for Bazel and its support for external repositories.
*/
public static final EventFilter DEFAULT_EVENT_FILTER_WITH_ACTIONS_AND_EXTERNAL_REPOS =
new EventFilter() {
@Override
public boolean storeEvents() {
return true;
}

@Override
public boolean shouldPropagate(SkyKey depKey, SkyKey primaryKey) {
// Bzlmod events do not need to be propagated to analysis nodes. They are propagated to
// the node for the main repo mapping, which is unconditionally requested in a separate
// Skyframe evaluation for every build, thus ensuring correct incremental behavior.
if (isBzlmodKey(depKey)) {
return isBzlmodKey(primaryKey);
}
return DEFAULT_EVENT_FILTER_WITH_ACTIONS.shouldPropagate(depKey, primaryKey);
}
};

private static boolean isBzlmodKey(SkyKey key) {
// The return value of Class#getPackageName() and string literals are always interned.
// https://github.com/openjdk/jdk/blob/3e185c70feef3febf75c58a5d4d394a4b772105f/src/java.base/share/classes/java/lang/Class.java#L1258
Expand Down Expand Up @@ -1144,7 +1161,7 @@ public Root getForcedSingleSourceRootIfNoExecrootSymlinkCreation() {
return null;
}

private boolean shouldStoreTransitivePackagesInLoadingAndAnalysis() {
protected boolean shouldStoreTransitivePackagesInLoadingAndAnalysis() {
// Transitive packages may be needed for either RepoMappingManifestAction or Skymeld with
// external repository support. They are never needed if external repositories are disabled. To
// avoid complexity from toggling this, just choose a setting for the lifetime of the server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void setup() throws Exception {
differencer,
EvaluationProgressReceiver.NULL,
GraphInconsistencyReceiver.THROWING,
SkyframeExecutor.DEFAULT_EVENT_FILTER_WITH_ACTIONS,
SkyframeExecutor.DEFAULT_EVENT_FILTER_WITH_ACTIONS_AND_EXTERNAL_REPOS,
new EmittedEventState(),
/* keepEdges= */ true,
/* usePooledInterning= */ true);
Expand Down

0 comments on commit d4ecb99

Please sign in to comment.