-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sure up handling of events and posts from sky functions.
This change addresses all of the oddities described in b/239458245 with fixes and/or documentation. `Event` and `Postable` now share a common interface `Reportable` which has a `storeForReplay` method which dictates the semantics of how they should be handled (documented in `SkyFunction.Environment` and tested in `ParallelEvaluatorTest`). Skyframe no longer distinguishes between events and posts - all `Reportable` instances are handled opaquely and stored together. `EventFilter` no longer acts as a per-event predicate - this logic was always the same if events were being stored at all, so it is moved to `Event#storeForReplay`. Some tests which trigger error events in a loop had to switch from `invalidatePackages()` to `initializeSkyframeExecutor()`. The latter additionally clears the emitted event state, which is now keyed on an individual event instead of the `TaggedEvents` list, and those test cases had multiple identical events which were getting cached between loop iterations with the new strategy. PiperOrigin-RevId: 463222076 Change-Id: Ib6e6acf29bc99e6744fae992166ad06d66ab5b37
- Loading branch information
1 parent
f706da8
commit 3f5edd8
Showing
27 changed files
with
578 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/google/devtools/build/lib/events/Reportable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2022 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.events; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** An event that can be reported to an {@link ExtendedEventHandler}. */ | ||
public interface Reportable { | ||
|
||
void reportTo(ExtendedEventHandler handler); | ||
|
||
/** | ||
* If this event supports tag-based output filtering, returns a new instance identical to this one | ||
* but with the given tag. Otherwise returns {@code this}. | ||
* | ||
* <p>Tags can be used to apply filtering to events. See {@link OutputFilter}. | ||
*/ | ||
Reportable withTag(@Nullable String tag); | ||
|
||
/** | ||
* If this event originated from {@link | ||
* com.google.devtools.build.skyframe.SkyFunction.Environment#reportEvent}, whether it should be | ||
* stored in the corresponding Skyframe node to be replayed on incremental builds when the node is | ||
* deemed up-to-date. | ||
* | ||
* <p>Events which are crucial to the correctness of the evaluation should return {@code true} so | ||
* that they are replayed when the {@link com.google.devtools.build.skyframe.SkyFunction} | ||
* invocation is cached. On the other hand, events that are merely informational (such as a | ||
* progress update) should return {@code false} to avoid taking up memory. | ||
* | ||
* <p>Evaluations may disable all event storage and replay by using a custom {@link | ||
* com.google.devtools.build.skyframe.EventFilter}, in which case this method is only used to | ||
* fulfill the semantics of {@link | ||
* com.google.devtools.build.skyframe.SkyFunction.Environment#reportEvent}. | ||
* | ||
* <p>This method is not relevant for events which do not originate from {@link | ||
* com.google.devtools.build.skyframe.SkyFunction} evaluation. | ||
*/ | ||
default boolean storeForReplay() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.