Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Bazel Build Event Stream support #811

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"allocative/allocative_derive",
# @oss-disable: "attic/uniplate",
# @oss-disable: "attic/uniplate_derive",
"app/bazel_event_publisher_proto",
"app/buck2",
"app/buck2_action_impl",
"app/buck2_action_impl_tests",
Expand Down Expand Up @@ -35,6 +36,7 @@ members = [
"app/buck2_event_observer",
"app/buck2_events",
"app/buck2_event_log",
"app/buck2_event_publisher_proto",
"app/buck2_execute",
"app/buck2_execute_impl",
"app/buck2_external_cells",
Expand Down Expand Up @@ -129,6 +131,7 @@ async-compression = { version = "0.4.1", features = ["tokio", "gzip", "zstd"] }
async-condvar-fair = { version = "1.0", features = ["parking_lot_0_11", "tokio"] }
async-recursion = "1.0"
async-scoped = { version = "0.9", features = ["use-tokio"] }
async-stream = "0.3.6"
async-trait = "0.1.24"
atomic = "0.5.1"
backtrace = "0.3.51"
Expand Down Expand Up @@ -335,6 +338,8 @@ starlark_syntax = { version = "0.12.0", path = "starlark-rust/starlark_syntax" }
static_interner = { path = "shed/static_interner" }
three_billion_instructions = { path = "shed/three_billion_instructions" }

bazel_event_publisher_proto = { path = "app/bazel_event_publisher_proto" }

buck2_action_impl = { path = "app/buck2_action_impl" }
buck2_action_metadata_proto = { path = "app/buck2_action_metadata_proto" }
buck2_analysis = { path = "app/buck2_analysis" }
Expand Down Expand Up @@ -372,6 +377,7 @@ buck2_error = { path = "app/buck2_error" }
buck2_error_derive = { path = "app/buck2_error_derive" }
buck2_event_log = { path = "app/buck2_event_log" }
buck2_event_observer = { path = "app/buck2_event_observer" }
buck2_event_publisher_proto = { path = "app/buck2_event_publisher_proto" }
buck2_events = { path = "app/buck2_events" }
buck2_execute = { path = "app/buck2_execute" }
buck2_execute_impl = { path = "app/buck2_execute_impl" }
Expand Down
15 changes: 15 additions & 0 deletions app/bazel_event_publisher_proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "bazel_event_publisher_proto"

edition = "2021"
license = { workspace = true }
repository = { workspace = true }
version = "0.1.0"

[dependencies]
prost = { workspace = true }
prost-types = { workspace = true }
tonic = { workspace = true }

[build-dependencies]
buck2_protoc_dev = { workspace = true }
37 changes: 37 additions & 0 deletions app/bazel_event_publisher_proto/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/

use std::env;
use std::io;
use std::path::PathBuf;

fn main() -> io::Result<()> {
let proto_files = &[
"proto/action_cache.proto",
"proto/build_event_stream.proto",
"proto/command_line.proto",
"proto/failure_details.proto",
"proto/invocation_policy.proto",
"proto/option_filters.proto",
"proto/package_load_metrics.proto",
"proto/strategy_policy.proto",
"proto/google/api/annotations.proto",
"proto/google/api/client.proto",
"proto/google/api/field_behavior.proto",
"proto/google/api/http.proto",
"proto/google/api/launch_stage.proto",
"proto/google/devtools/build/v1/build_events.proto",
"proto/google/devtools/build/v1/build_status.proto",
"proto/google/devtools/build/v1/publish_build_event.proto",
];

buck2_protoc_dev::configure()
.setup_protoc()
.compile(proto_files, &["./proto/"])
}
63 changes: 63 additions & 0 deletions app/bazel_event_publisher_proto/proto/action_cache.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2017 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.

syntax = "proto3";

package blaze;

option java_package = "com.google.devtools.build.lib.actions.cache";
option java_outer_classname = "Protos";

// Information about the action cache behavior during a single build.
message ActionCacheStatistics {
// Size of the action cache in bytes.
//
// This is computed by the code that persists the action cache to disk and
// represents the size of the written files, which has no direct relation to
// the number of entries in the cache.
uint64 size_in_bytes = 1;

// Time it took to save the action cache to disk.
uint64 save_time_in_ms = 2;

// Reasons for not finding an action in the cache.
enum MissReason {
DIFFERENT_ACTION_KEY = 0;
DIFFERENT_DEPS = 1;
DIFFERENT_ENVIRONMENT = 2;
DIFFERENT_FILES = 3;
CORRUPTED_CACHE_ENTRY = 4;
NOT_CACHED = 5;
UNCONDITIONAL_EXECUTION = 6;
}

// Detailed information for a particular miss reason.
message MissDetail {
MissReason reason = 1;
int32 count = 2;
}

// Cache counters.
int32 hits = 3;
int32 misses = 4;

// Breakdown of the cache misses based on the reasons behind them.
repeated MissDetail miss_details = 5;

// Time it took to load the action cache from disk. Reported as 0 if the
// action cache has not been loaded in this invocation.
uint64 load_time_in_ms = 6;

// NEXT TAG: 7
}
Loading