forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an
EventBus
subscriber for remote analysis caching events.
Currently, this listens to serialization events only. The test assertions are now made more exact with the new information. A future motivation is to hook this into more principled logging solutions (e.g. BEP) for capturing remote analysis caching events (# bytes/counts read/write, cache hit rate for cache reading builds). PiperOrigin-RevId: 673234500 Change-Id: Ie6395616f41019190aeda890a041ce8eb3878403
- Loading branch information
1 parent
7a9702b
commit e8e1bd3
Showing
9 changed files
with
124 additions
and
17 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
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
62 changes: 62 additions & 0 deletions
62
...evtools/build/lib/skyframe/serialization/analysis/RemoteAnalysisCachingEventListener.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,62 @@ | ||
// Copyright 2024 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.skyframe.serialization.analysis; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.google.common.collect.HashMultiset; | ||
import com.google.common.collect.Multiset; | ||
import com.google.common.eventbus.AllowConcurrentEvents; | ||
import com.google.common.eventbus.Subscribe; | ||
import com.google.devtools.build.lib.concurrent.ThreadSafety; | ||
import com.google.devtools.build.skyframe.SkyFunctionName; | ||
import com.google.devtools.build.skyframe.SkyKey; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** An {@link com.google.common.eventbus.EventBus} listener for remote analysis caching events. */ | ||
@ThreadSafety.ThreadSafe | ||
public class RemoteAnalysisCachingEventListener { | ||
|
||
/** | ||
* An event for when a Skyframe node has been serialized, but its associated write futures (i.e. | ||
* RPC latency) may not be done yet. | ||
*/ | ||
public record SerializedNodeEvent(SkyKey key) { | ||
public SerializedNodeEvent { | ||
checkNotNull(key); | ||
} | ||
} | ||
|
||
private final Set<SkyKey> serializedKeys = ConcurrentHashMap.newKeySet(); | ||
|
||
@Subscribe | ||
@AllowConcurrentEvents | ||
@SuppressWarnings("unused") | ||
public void onSerializationComplete(SerializedNodeEvent event) { | ||
serializedKeys.add(event.key()); | ||
} | ||
|
||
/** Returns the counts of {@link SkyFunctionName} from serialized nodes of this invocation. */ | ||
public Multiset<SkyFunctionName> getSkyfunctionCounts() { | ||
Multiset<SkyFunctionName> counts = HashMultiset.create(); | ||
serializedKeys.forEach(key -> counts.add(key.functionName())); | ||
return counts; | ||
} | ||
|
||
/** Returns the count of serialized nodes of this invocation. */ | ||
public int getSerializedKeysCount() { | ||
return serializedKeys.size(); | ||
} | ||
} |
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