Skip to content

Commit 8330f27

Browse files
committed
1 parent d48ed1b commit 8330f27

34 files changed

Lines changed: 429 additions & 19 deletions

base/cvd/build_external/build_external.MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ include("//build_external/mkbootimg:mkbootimg.MODULE.bazel")
4848
include("//build_external/ms-tpm-20-ref:ms-tpm-20-ref.MODULE.bazel")
4949
include("//build_external/mtools:mtools.MODULE.bazel")
5050
include("//build_external/opengl_headers:opengl_headers.MODULE.bazel")
51+
include("//build_external/perfetto:perfetto.MODULE.bazel")
5152
include("//build_external/pyyaml:pyyaml.MODULE.bazel")
5253
include("//build_external/re2:re2.MODULE.bazel")
5354
include("//build_external/rootcanal:rootcanal.MODULE.bazel")

base/cvd/build_external/perfetto/BUILD

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
perfetto_ext = use_extension("//build_external/perfetto:repositories.bzl", "perfetto_extension")
2+
use_repo(perfetto_ext, "perfetto")
3+
use_repo(perfetto_ext, "perfetto_cfg")
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
# https://github.com/google/perfetto/issues/2787 for Perfetto getting into the
4+
# Central Repository.
5+
def _perfetto_extension_impl(_):
6+
URL = "https://github.com/google/perfetto/archive/refs/tags/v54.0.tar.gz"
7+
http_archive(
8+
name = "perfetto",
9+
url = URL,
10+
strip_prefix = "perfetto-54.0",
11+
patch_cmds = [
12+
# Hack away all of the unused Android rules to avoid pulling in extra dependencies:
13+
"sed -i '/load(\"@rules_android/d' bazel/rules.bzl",
14+
"sed -i '/load(\"@perfetto\\/\\/bazel:run_ait_with_adb.bzl/d' bazel/rules.bzl",
15+
"sed -i 's| android_binary(\\*\\*kwargs)| return|g' bazel/rules.bzl",
16+
"sed -i 's| android_library(\\*\\*kwargs)| return|g' bazel/rules.bzl",
17+
"sed -i 's| android_instrumentation_test(\\*\\*kwargs)| return|g' bazel/rules.bzl",
18+
19+
# Fix loads for newer bazel version:
20+
"sed -i '1i load(\"@protobuf//bazel/common:proto_info.bzl\", \"ProtoInfo\")\\n' bazel/proto_gen.bzl",
21+
"sed -i '1i load(\"@protobuf//bazel:cc_proto_library.bzl\", \"cc_proto_library\")\\n' bazel/rules.bzl",
22+
"sed -i '1i load(\"@protobuf//bazel:proto_library.bzl\", \"proto_library\")\\n' bazel/rules.bzl",
23+
"sed -i '1i load(\"@protobuf//bazel:java_lite_proto_library.bzl\", \"java_lite_proto_library\")\\n' bazel/rules.bzl",
24+
"sed -i '1i load(\"@rules_cc//cc:cc_binary.bzl\", \"cc_binary\")\\n' bazel/rules.bzl",
25+
"sed -i '1i load(\"@rules_cc//cc:cc_library.bzl\", \"cc_library\")\\n' bazel/rules.bzl",
26+
"sed -i '1i load(\"@rules_python//python:defs.bzl\", \"py_binary\", \"py_library\")\\n' bazel/rules.bzl",
27+
"sed -i 's|native.cc_binary|cc_binary|g' bazel/rules.bzl",
28+
"sed -i 's|native.cc_library|cc_library|g' bazel/rules.bzl",
29+
"sed -i 's|native.cc_proto_library|cc_proto_library|g' bazel/rules.bzl",
30+
"sed -i 's|native.proto_library|proto_library|g' bazel/rules.bzl",
31+
"sed -i 's|native.py_binary|py_binary|g' bazel/rules.bzl",
32+
"sed -i 's|native.py_library|py_library|g' bazel/rules.bzl",
33+
"sed -i 's|native.java_lite_proto_library|java_lite_proto_library|g' bazel/rules.bzl",
34+
],
35+
)
36+
37+
# perfetto_cfg is a new_local_repository using a path relative to the top-level WORKSPACE file.
38+
# We replicate this with an http_archive using a bigger strip_prefix.
39+
http_archive(
40+
name = "perfetto_cfg",
41+
url = URL,
42+
strip_prefix = "perfetto-54.0/bazel/standalone",
43+
build_file_content = "# empty BUILD to make a bazel package",
44+
patch_cmds = [
45+
"sed -i 's|@com_google_protobuf|@protobuf|g' perfetto_cfg.bzl",
46+
],
47+
)
48+
49+
perfetto_extension = module_extension(
50+
implementation = _perfetto_extension_impl,
51+
)

base/cvd/cuttlefish/host/commands/assemble_cvd/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ cf_cc_binary(
7171
"//cuttlefish/host/libs/config/defaults",
7272
"//cuttlefish/host/libs/config/fastboot",
7373
"//cuttlefish/host/libs/feature:inject",
74+
"//cuttlefish/host/libs/tracing",
7475
"//cuttlefish/posix:symlink",
7576
"//cuttlefish/pretty:vector",
7677
"//libbase",
@@ -166,6 +167,7 @@ cf_cc_library(
166167
"//cuttlefish/common/libs/utils:subprocess",
167168
"//cuttlefish/common/libs/utils:subprocess_managed_stdio",
168169
"//cuttlefish/host/libs/config:config_utils",
170+
"//cuttlefish/host/libs/tracing",
169171
"//cuttlefish/posix:strerror",
170172
"//cuttlefish/result",
171173
"//libbase",
@@ -220,6 +222,7 @@ cf_cc_library(
220222
"//cuttlefish/host/libs/config:file_source",
221223
"//cuttlefish/host/libs/config:instance_nums",
222224
"//cuttlefish/host/libs/feature:inject",
225+
"//cuttlefish/host/libs/tracing",
223226
"//cuttlefish/result",
224227
"//libbase",
225228
"@abseil-cpp//absl/log",
@@ -237,6 +240,7 @@ cf_cc_library(
237240
"//cuttlefish/host/libs/config:vmm_mode",
238241
"//cuttlefish/host/libs/image_aggregator",
239242
"//cuttlefish/host/libs/image_aggregator:qcow2",
243+
"//cuttlefish/host/libs/tracing",
240244
"//cuttlefish/result",
241245
"//libbase",
242246
"@abseil-cpp//absl/log",
@@ -354,6 +358,7 @@ cf_cc_library(
354358
"//cuttlefish/host/libs/config:secure_hals",
355359
"//cuttlefish/host/libs/config:vmm_mode",
356360
"//cuttlefish/host/libs/config/defaults",
361+
"//cuttlefish/host/libs/tracing",
357362
"//cuttlefish/host/libs/vhal_proxy_server",
358363
"//cuttlefish/host/libs/vm_manager",
359364
"//cuttlefish/result",
@@ -402,6 +407,7 @@ cf_cc_library(
402407
"//cuttlefish/host/libs/config:config_utils",
403408
"//cuttlefish/host/libs/config:display",
404409
"//cuttlefish/host/libs/config:gpu_mode",
410+
"//cuttlefish/host/libs/tracing",
405411
"//cuttlefish/pretty",
406412
"//cuttlefish/pretty:optional",
407413
"//cuttlefish/pretty:string",
@@ -431,6 +437,7 @@ cf_cc_library(
431437
"//cuttlefish/host/libs/config:guest_hwui_renderer",
432438
"//cuttlefish/host/libs/config:guest_renderer_preload",
433439
"//cuttlefish/host/libs/config:vmm_mode",
440+
"//cuttlefish/host/libs/tracing",
434441
"//cuttlefish/result",
435442
"//libbase",
436443
"@abseil-cpp//absl/log",

base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "cuttlefish/host/libs/config/fetcher_configs.h"
7070
#include "cuttlefish/host/libs/config/log_string_to_dir.h"
7171
#include "cuttlefish/host/libs/feature/inject.h"
72+
#include "cuttlefish/host/libs/tracing/tracing.h"
7273
#include "cuttlefish/posix/symlink.h"
7374
#include "cuttlefish/pretty/vector.h"
7475

@@ -405,6 +406,8 @@ Result<const CuttlefishConfig*> InitFilesystemAndCreateConfig(
405406
CF_EXPECT(CleanPriorFiles(preserving, clean_dirs),
406407
"Failed to clean prior files");
407408

409+
CF_TRACE_EVENT("SetupDirectories");
410+
408411
std::string default_group = "cvdnetwork";
409412
const mode_t default_mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
410413

@@ -573,6 +576,9 @@ Result<int> AssembleCvdMain(int argc, char** argv) {
573576

574577
CF_EXPECT(CheckNoTTY());
575578

579+
auto scoped_trace_flusher = InitializeTracing();
580+
CF_TRACE_EVENT("AssembleCvd");
581+
576582
// Read everything that cvd_internal_start writes, but ignore it since
577583
// fetcher_config.json will be searched for in the system image directory.
578584
(void) CF_EXPECT(ReadInputFiles());
@@ -643,10 +649,12 @@ Result<int> AssembleCvdMain(int argc, char** argv) {
643649
"Failed to parse flags.");
644650

645651
if (help || !help_str.empty()) {
652+
CF_TRACE_EVENT_INSTANT("Help");
646653
LOG(WARNING) << "TODO(schuffelen): Implement `--help` for assemble_cvd.";
647654
LOG(WARNING) << "In the meantime, call `launch_cvd --help`";
648655
return 1;
649656
} else if (helpxml) {
657+
CF_TRACE_EVENT_INSTANT("Help");
650658
if (!FlagFeature::WriteGflagsHelpXml(flag_features, std::cout)) {
651659
LOG(ERROR) << "Failure in writing gflags helpxml output";
652660
}

base/cvd/cuttlefish/host/commands/assemble_cvd/clean.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cuttlefish/common/libs/utils/subprocess.h"
3232
#include "cuttlefish/common/libs/utils/subprocess_managed_stdio.h"
3333
#include "cuttlefish/host/libs/config/config_utils.h"
34+
#include "cuttlefish/host/libs/tracing/tracing.h"
3435
#include "cuttlefish/posix/strerror.h"
3536
#include "cuttlefish/result/result.h"
3637

@@ -137,6 +138,8 @@ Result<void> CleanPriorFiles(const std::vector<std::string>& paths,
137138

138139
Result<void> CleanPriorFiles(const std::set<std::string>& preserving,
139140
const std::vector<std::string>& clean_dirs) {
141+
CF_TRACE_EVENT("CleanPriorFiles");
142+
140143
std::vector<std::string> paths = {
141144
// The global link to the config file
142145
GetGlobalConfigFileLink(),

base/cvd/cuttlefish/host/commands/assemble_cvd/create_dynamic_disk_files.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "cuttlefish/host/libs/config/fetcher_config.h"
6060
#include "cuttlefish/host/libs/config/fetcher_configs.h"
6161
#include "cuttlefish/host/libs/config/file_source.h"
62+
#include "cuttlefish/host/libs/tracing/tracing.h"
6263
#include "cuttlefish/result/result.h"
6364

6465
namespace cuttlefish {
@@ -98,6 +99,7 @@ Result<void> CreateDynamicDiskFiles(
9899
const FetcherConfigs& fetcher_configs, const CuttlefishConfig& config,
99100
AndroidBuilds& android_builds, const BootImageFlag& boot_image,
100101
const SystemImageDirFlag& system_image_dirs) {
102+
CF_TRACE_EVENT("CreateDynamicDiskFiles");
101103
std::vector<std::vector<std::unique_ptr<ImageFile>>> image_files =
102104
InstanceImageFiles(config, boot_image);
103105
size_t instance_index = 0;

base/cvd/cuttlefish/host/commands/assemble_cvd/disk_builder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "cuttlefish/host/libs/config/vmm_mode.h"
2727
#include "cuttlefish/host/libs/image_aggregator/image_aggregator.h"
2828
#include "cuttlefish/host/libs/image_aggregator/qcow2.h"
29+
#include "cuttlefish/host/libs/tracing/tracing.h"
2930

3031
namespace cuttlefish {
3132

@@ -199,6 +200,8 @@ Result<bool> DiskBuilder::WillRebuildCompositeDisk() {
199200
}
200201

201202
Result<bool> DiskBuilder::BuildCompositeDiskIfNecessary() {
203+
CF_TRACE_EVENT("BuildCompositeDisk", "disk", composite_disk_path_);
204+
202205
if (!entire_disk_.empty()) {
203206
VLOG(0) << "No composite disk to build";
204207
return false;
@@ -228,6 +231,8 @@ Result<bool> DiskBuilder::BuildCompositeDiskIfNecessary() {
228231
}
229232

230233
Result<bool> DiskBuilder::BuildOverlayIfNecessary() {
234+
CF_TRACE_EVENT("BuildOverlayIfNcessary", "overlay", overlay_path_);
235+
231236
#ifdef __APPLE__
232237
return false;
233238
#else

base/cvd/cuttlefish/host/commands/assemble_cvd/flags.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#include "cuttlefish/host/libs/config/instance_nums.h"
9191
#include "cuttlefish/host/libs/config/secure_hals.h"
9292
#include "cuttlefish/host/libs/config/vmm_mode.h"
93+
#include "cuttlefish/host/libs/tracing/tracing.h"
9394
#include "cuttlefish/host/libs/vhal_proxy_server/vhal_proxy_server_eth_addr.h"
9495
#include "cuttlefish/host/libs/vm_manager/gem5_manager.h"
9596
#include "cuttlefish/host/libs/vm_manager/qemu_manager.h"
@@ -352,6 +353,8 @@ Result<CuttlefishConfig> InitializeCuttlefishConfiguration(
352353
const SystemImageDirFlag& system_image_dir,
353354
const VendorBootImageFlag& vendor_boot_image,
354355
const VmManagerFlag& vm_manager_flag, const Defaults& defaults) {
356+
CF_TRACE_EVENT("InitializeCuttlefishConfiguration");
357+
355358
CuttlefishConfig tmp_config_obj;
356359
// If a snapshot path is provided, do not read all flags to set up the config.
357360
// Instead, read the config that was saved at time of snapshot and restore

0 commit comments

Comments
 (0)