From 908f5badcd458de8db88afeb6904fb94edace04c Mon Sep 17 00:00:00 2001 From: jcking Date: Fri, 5 Dec 2025 14:19:20 -0800 Subject: [PATCH 1/6] Internal change PiperOrigin-RevId: 840871948 --- src/quipper/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quipper/BUILD b/src/quipper/BUILD index 4e03ad3..6286ea4 100644 --- a/src/quipper/BUILD +++ b/src/quipper/BUILD @@ -82,7 +82,7 @@ cc_library( ":perf_parser_options_cc_proto", ":perf_stat_cc_proto", ":base", - "@com_google_protobuf//:protobuf", + "@com_google_protobuf//", ], ) From c89ed1d2a990b1625ae7064ee6897f82c6b059d0 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 21 Jan 2026 12:41:54 -0800 Subject: [PATCH 2/6] Internal change PiperOrigin-RevId: 859219669 --- ci/linux_clang-latest_libcxx_bazel.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/linux_clang-latest_libcxx_bazel.sh b/ci/linux_clang-latest_libcxx_bazel.sh index 293db74..83ad7e0 100755 --- a/ci/linux_clang-latest_libcxx_bazel.sh +++ b/ci/linux_clang-latest_libcxx_bazel.sh @@ -9,6 +9,8 @@ set -euox pipefail if [ -z "${PDC_ROOT:-}" ]; then PDC_ROOT="$(realpath $(dirname ${0})/..)" + PDC_ROOT_DIR_NAME=$(basename "${PDC_ROOT}") + PDC_HOST_ROOT="${KOKORO_HOST_ROOT_DIR}/src/git/${PDC_ROOT_DIR_NAME}" fi # This container is a reasonable start but is missing some prerequisite libs and @@ -16,7 +18,7 @@ fi readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20231218" time docker run \ - --volume="${PDC_ROOT}:/perf_data_converter:ro" \ + --mount "type=bind,src=${PDC_HOST_ROOT},target=/perf_data_converter" \ --workdir=/perf_data_converter \ --cap-add=SYS_PTRACE \ --rm \ From 67e4823e4d34d55800ef3ef2b9c285eb842276e7 Mon Sep 17 00:00:00 2001 From: blakejones Date: Wed, 28 Jan 2026 14:04:12 -0800 Subject: [PATCH 3/6] Add sample info support for PERF_RECORD_BPF_METADATA. PiperOrigin-RevId: 862386390 --- src/quipper/perf_data_utils.cc | 4 +++- src/quipper/perf_parser_test.cc | 3 ++- src/quipper/perf_serializer_test.cc | 5 ++++- src/quipper/sample_info_reader.cc | 2 ++ src/quipper/test_perf_data.cc | 7 +++++-- src/quipper/test_perf_data.h | 8 ++++++-- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/quipper/perf_data_utils.cc b/src/quipper/perf_data_utils.cc index 4bdbeac..1a54767 100644 --- a/src/quipper/perf_data_utils.cc +++ b/src/quipper/perf_data_utils.cc @@ -115,6 +115,8 @@ const PerfDataProto_SampleInfo* GetSampleInfoForEvent( return &event.cgroup_event().sample_info(); case PERF_RECORD_KSYMBOL: return &event.ksymbol_event().sample_info(); + case PERF_RECORD_BPF_METADATA: + return &event.bpf_metadata_event().sample_info(); } return nullptr; } @@ -555,7 +557,7 @@ bool GetEventDataVariablePayloadSize(const event_t& event, << remaining_event_size; return false; } - *size = remaining_event_size; + *size = actual_entries * sizeof(struct bpf_metadata_entry); break; } // The below events changed size between kernel versions, diff --git a/src/quipper/perf_parser_test.cc b/src/quipper/perf_parser_test.cc index b2bc4ba..8552d80 100644 --- a/src/quipper/perf_parser_test.cc +++ b/src/quipper/perf_parser_test.cc @@ -1904,7 +1904,8 @@ TEST(PerfParserTest, BpfMetadataEvents) { { {.key = "my_key", .value = "my_value"}, {.key = "longer_key", .value = "slightly_different_value"}, - }); + }, + testing::SampleInfo().Tid(2010)); size_t data_size = event.GetSize(); diff --git a/src/quipper/perf_serializer_test.cc b/src/quipper/perf_serializer_test.cc index 4caf512..dbdd2f6 100644 --- a/src/quipper/perf_serializer_test.cc +++ b/src/quipper/perf_serializer_test.cc @@ -85,6 +85,8 @@ uint64_t GetSampleTimestampFromEventProto( return event.context_switch_event().sample_info().sample_time_ns(); } else if (event.has_namespaces_event()) { return event.namespaces_event().sample_info().sample_time_ns(); + } else if (event.has_bpf_metadata_event()) { + return event.bpf_metadata_event().sample_info().sample_time_ns(); } return 0; } @@ -1868,7 +1870,8 @@ TEST(PerfSerializerTest, SerializesAndDeserializesBpfEvents) { { {.key = "my_key", .value = "my_value"}, {.key = "longer_key", .value = "slightly_different_value"}, - }) + }, + testing::SampleInfo().Tid(2010)) .WriteTo(&input); // Serialize. diff --git a/src/quipper/sample_info_reader.cc b/src/quipper/sample_info_reader.cc index 59e42f4..41dc2ec 100644 --- a/src/quipper/sample_info_reader.cc +++ b/src/quipper/sample_info_reader.cc @@ -829,6 +829,7 @@ bool SampleInfoReader::IsSupportedEventType(uint32_t type) { case PERF_RECORD_MMAP: case PERF_RECORD_MMAP2: case PERF_RECORD_KSYMBOL: + case PERF_RECORD_BPF_METADATA: case PERF_RECORD_FORK: case PERF_RECORD_EXIT: case PERF_RECORD_COMM: @@ -922,6 +923,7 @@ uint64_t SampleInfoReader::GetSampleFieldsForEventType(uint32_t event_type, case PERF_RECORD_FORK: case PERF_RECORD_MMAP2: case PERF_RECORD_KSYMBOL: + case PERF_RECORD_BPF_METADATA: case PERF_RECORD_AUX: case PERF_RECORD_ITRACE_START: case PERF_RECORD_LOST_SAMPLES: diff --git a/src/quipper/test_perf_data.cc b/src/quipper/test_perf_data.cc index 248a4a1..ababd21 100644 --- a/src/quipper/test_perf_data.cc +++ b/src/quipper/test_perf_data.cc @@ -940,7 +940,8 @@ void ExampleKsymbolEvent::WriteTo(std::ostream* out) const { size_t ExampleBpfMetadataEvent::GetSize() const { return offsetof(struct bpf_metadata_event, entries) + - entries_.size() * sizeof(struct bpf_metadata_entry); + entries_.size() * sizeof(struct bpf_metadata_entry) + + sample_id_.size(); // sample_id_all } void ExampleBpfMetadataEvent::WriteTo(std::ostream* out) const { @@ -960,7 +961,9 @@ void ExampleBpfMetadataEvent::WriteTo(std::ostream* out) const { } const size_t previous_offset = out->tellp(); - out->write(reinterpret_cast(event.get()), event_size); + out->write(reinterpret_cast(event.get()), + event_size - sample_id_.size()); + out->write(sample_id_.data(), sample_id_.size()); const size_t written_event_size = static_cast(out->tellp()) - previous_offset; CHECK_EQ(event_size, static_cast(written_event_size)); diff --git a/src/quipper/test_perf_data.h b/src/quipper/test_perf_data.h index 2561a0a..1f0a0fb 100644 --- a/src/quipper/test_perf_data.h +++ b/src/quipper/test_perf_data.h @@ -958,14 +958,18 @@ class ExampleKsymbolEvent : public StreamWriteable { class ExampleBpfMetadataEvent : public StreamWriteable { public: ExampleBpfMetadataEvent(std::string prog_name, - std::vector entries) - : prog_name_(prog_name), entries_(std::move(entries)) {} + std::vector entries, + const SampleInfo& sample_id) + : prog_name_(prog_name), + entries_(std::move(entries)), + sample_id_(sample_id) {} size_t GetSize() const; void WriteTo(std::ostream* out) const override; private: const std::string prog_name_; const std::vector entries_; + const SampleInfo sample_id_; }; } // namespace testing From 2c7c20de4e97e4d7ade6ac3a376637b544390c8d Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 12 Feb 2026 11:09:43 -0800 Subject: [PATCH 4/6] Dependency cleanup PiperOrigin-RevId: 869299341 --- src/builder.cc | 44 ++++++++++++++++++++++---------------------- src/builder.h | 21 ++++++++++----------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/builder.cc b/src/builder.cc index a50097a..a28fc0b 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -25,10 +25,10 @@ #include "google/protobuf/io/gzip_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" -using google::protobuf::io::StringOutputStream; -using google::protobuf::io::GzipOutputStream; -using google::protobuf::io::FileOutputStream; using google::protobuf::RepeatedField; +using google::protobuf::io::FileOutputStream; +using google::protobuf::io::GzipOutputStream; +using google::protobuf::io::StringOutputStream; namespace perftools { namespace profiles { @@ -36,7 +36,7 @@ namespace profiles { typedef absl::flat_hash_map IndexMap; typedef absl::flat_hash_set IndexSet; -void AddCallstackToSample(Sample *sample, const void *const *stack, int depth, +void AddCallstackToSample(Sample* sample, const void* const* stack, int depth, CallstackType type) { if (depth <= 0) return; if (type == kInterrupt) { @@ -74,8 +74,8 @@ int64_t Builder::InternalStringId(absl::string_view str) { return index; } -uint64_t Builder::FunctionId(const char *name, const char *system_name, - const char *file, int64_t start_line) { +uint64_t Builder::FunctionId(const char* name, const char* system_name, + const char* file, int64_t start_line) { int64_t name_index = StringId(name); int64_t system_name_index = StringId(system_name); int64_t file_index = StringId(file); @@ -100,7 +100,7 @@ uint64_t Builder::FunctionId(const char *name, const char *system_name, return index; } -void Builder::SetDocURL(const std::string &url) { +void Builder::SetDocURL(const std::string& url) { const std::string kHttp = "http://"; const std::string kHttps = "https://"; @@ -116,7 +116,7 @@ void Builder::SetDocURL(const std::string &url) { profile_->set_doc_url(InternalStringId(url)); } -bool Builder::Emit(std::string *output) { +bool Builder::Emit(std::string* output) { *output = ""; if (!profile_ || !Finalize()) { return false; @@ -124,7 +124,7 @@ bool Builder::Emit(std::string *output) { return Marshal(*profile_, output); } -bool Builder::Marshal(const Profile &profile, std::string *output) { +bool Builder::Marshal(const Profile& profile, std::string* output) { *output = ""; StringOutputStream stream(output); GzipOutputStream gzip_stream(&stream); @@ -135,7 +135,7 @@ bool Builder::Marshal(const Profile &profile, std::string *output) { return gzip_stream.Close(); } -bool Builder::MarshalToFile(const Profile &profile, int fd) { +bool Builder::MarshalToFile(const Profile& profile, int fd) { FileOutputStream stream(fd); GzipOutputStream gzip_stream(&stream); if (!profile.SerializeToZeroCopyStream(&gzip_stream)) { @@ -145,7 +145,7 @@ bool Builder::MarshalToFile(const Profile &profile, int fd) { return gzip_stream.Close(); } -bool Builder::MarshalToFile(const Profile &profile, const char *filename) { +bool Builder::MarshalToFile(const Profile& profile, const char* filename) { int fd; while ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0 && errno == EINTR) { @@ -161,10 +161,10 @@ bool Builder::MarshalToFile(const Profile &profile, const char *filename) { // Returns a bool indicating if the profile is valid. It logs any // errors it encounters. -bool Builder::CheckValid(const Profile &profile) { +bool Builder::CheckValid(const Profile& profile) { IndexSet mapping_ids; mapping_ids.reserve(profile.mapping_size()); - for (const auto &mapping : profile.mapping()) { + for (const auto& mapping : profile.mapping()) { const int64_t id = mapping.id(); if (id != 0) { const bool insert_successful = mapping_ids.insert(id).second; @@ -177,7 +177,7 @@ bool Builder::CheckValid(const Profile &profile) { IndexSet function_ids; function_ids.reserve(profile.function_size()); - for (const auto &function : profile.function()) { + for (const auto& function : profile.function()) { const int64_t id = function.id(); if (id != 0) { const bool insert_successful = function_ids.insert(id).second; @@ -190,7 +190,7 @@ bool Builder::CheckValid(const Profile &profile) { IndexSet location_ids; location_ids.reserve(profile.location_size()); - for (const auto &location : profile.location()) { + for (const auto& location : profile.location()) { const int64_t id = location.id(); if (id != 0) { const bool insert_successful = location_ids.insert(id).second; @@ -204,7 +204,7 @@ bool Builder::CheckValid(const Profile &profile) { LOG(ERROR) << "Missing mapping " << mapping_id << " from location " << id; return false; } - for (const auto &line : location.line()) { + for (const auto& line : location.line()) { int64_t function_id = line.function_id(); if (function_id != 0 && function_ids.count(function_id) == 0) { LOG(ERROR) << "Missing function " << function_id; @@ -227,7 +227,7 @@ bool Builder::CheckValid(const Profile &profile) { } std::unordered_set value_types; - for (const auto &sample_type : profile.sample_type()) { + for (const auto& sample_type : profile.sample_type()) { if (!value_types.insert(sample_type.type()).second) { LOG(ERROR) << "Duplicate sample_type specified"; return false; @@ -239,7 +239,7 @@ bool Builder::CheckValid(const Profile &profile) { return false; } - for (const auto &sample : profile.sample()) { + for (const auto& sample : profile.sample()) { if (sample.value_size() != sample_type_len) { LOG(ERROR) << "Found sample with " << sample.value_size() << " values, expecting " << sample_type_len; @@ -257,7 +257,7 @@ bool Builder::CheckValid(const Profile &profile) { } } - for (const auto &label : sample.label()) { + for (const auto& label : sample.label()) { int64_t str = label.str(); int64_t num = label.num(); if (str != 0 && num != 0) { @@ -281,7 +281,7 @@ bool Builder::Finalize() { if (profile_->location_size() == 0) { IndexMap address_to_id; address_to_id.reserve(profile_->sample_size()); - for (auto &sample : *profile_->mutable_sample()) { + for (auto& sample : *profile_->mutable_sample()) { // Copy sample locations into a temp vector, and then clear and // repopulate it with the corresponding location IDs. const RepeatedField addresses = sample.location_id(); @@ -302,12 +302,12 @@ bool Builder::Finalize() { // Look up location address on mapping ranges. if (profile_->mapping_size() > 0) { std::map > mapping_map; - for (const auto &mapping : profile_->mapping()) { + for (const auto& mapping : profile_->mapping()) { mapping_map[mapping.memory_start()] = std::make_pair(mapping.memory_limit(), mapping.id()); } - for (auto &loc : *profile_->mutable_location()) { + for (auto& loc : *profile_->mutable_location()) { if (loc.address() != 0 && loc.mapping_id() == 0) { auto mapping = mapping_map.upper_bound(loc.address()); if (mapping == mapping_map.begin()) { diff --git a/src/builder.h b/src/builder.h index 4349ed9..b440876 100644 --- a/src/builder.h +++ b/src/builder.h @@ -9,7 +9,6 @@ #include -#include #include #include #include @@ -31,7 +30,7 @@ typedef absl::flat_hash_map, enum CallstackType { kRegular = 0, kInterrupt = 1 }; -void AddCallstackToSample(Sample *sample, const void *const *stack, int depth, +void AddCallstackToSample(Sample* sample, const void* const* stack, int depth, CallstackType type); // Provides mechanisms to facilitate the generation of profiles @@ -55,14 +54,14 @@ class Builder { // Adds a function with these attributes to the profile function // table, if not already present. Returns a unique integer id for // this function. - uint64_t FunctionId(const char *name, const char *system_name, - const char *file, int64_t start_line); + uint64_t FunctionId(const char* name, const char* system_name, + const char* file, int64_t start_line); // Adds mappings for the currently running binary to the profile. void AddCurrentMappings(); // Add documentation URL. - void SetDocURL(const std::string &url); + void SetDocURL(const std::string& url); // Prepares the profile for encoding. Returns true on success. // If the profile has no locations, inserts location using the @@ -74,25 +73,25 @@ class Builder { // Serializes and compresses the profile into a string, replacing // its contents. It calls Finalize() and returns whether the // encoding was successful. - bool Emit(std::string *output); + bool Emit(std::string* output); // Serializes and compresses a profile into a string, replacing its // contents. Returns false if there were errors on the serialization // or compression, and the output string will not contain valid data. - static bool Marshal(const Profile &profile, std::string *output); + static bool Marshal(const Profile& profile, std::string* output); // Serializes and compresses a profile into a file represented by a // file descriptor. Returns false if there were errors on the // serialization or compression. - static bool MarshalToFile(const Profile &profile, int fd); + static bool MarshalToFile(const Profile& profile, int fd); // Serializes and compresses a profile into a file, creating a new // file or replacing its contents if it already exists. - static bool MarshalToFile(const Profile &profile, const char *filename); + static bool MarshalToFile(const Profile& profile, const char* filename); // Determines if the profile is internally consistent (suitable for // serialization). Returns true if no errors were encountered. - static bool CheckValid(const Profile &profile); + static bool CheckValid(const Profile& profile); // Extract the profile from the builder object. No further calls // should be made to the builder after this. @@ -102,7 +101,7 @@ class Builder { // managed by the builder. The fields function and string_table // should be populated through Builder::StringId and // Builder::FunctionId. - Profile *mutable_profile() { return profile_.get(); } + Profile* mutable_profile() { return profile_.get(); } private: int64_t InternalStringId(absl::string_view str); From d88696ea0858d613dbd11d7eaba43a6e26a9ab25 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 12 Feb 2026 12:19:58 -0800 Subject: [PATCH 5/6] Automated g4 rollback of changelist 869299341 PiperOrigin-RevId: 869329884 --- src/builder.cc | 44 ++++++++++++++++++++++---------------------- src/builder.h | 21 +++++++++++---------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/builder.cc b/src/builder.cc index a28fc0b..a50097a 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -25,10 +25,10 @@ #include "google/protobuf/io/gzip_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" -using google::protobuf::RepeatedField; -using google::protobuf::io::FileOutputStream; -using google::protobuf::io::GzipOutputStream; using google::protobuf::io::StringOutputStream; +using google::protobuf::io::GzipOutputStream; +using google::protobuf::io::FileOutputStream; +using google::protobuf::RepeatedField; namespace perftools { namespace profiles { @@ -36,7 +36,7 @@ namespace profiles { typedef absl::flat_hash_map IndexMap; typedef absl::flat_hash_set IndexSet; -void AddCallstackToSample(Sample* sample, const void* const* stack, int depth, +void AddCallstackToSample(Sample *sample, const void *const *stack, int depth, CallstackType type) { if (depth <= 0) return; if (type == kInterrupt) { @@ -74,8 +74,8 @@ int64_t Builder::InternalStringId(absl::string_view str) { return index; } -uint64_t Builder::FunctionId(const char* name, const char* system_name, - const char* file, int64_t start_line) { +uint64_t Builder::FunctionId(const char *name, const char *system_name, + const char *file, int64_t start_line) { int64_t name_index = StringId(name); int64_t system_name_index = StringId(system_name); int64_t file_index = StringId(file); @@ -100,7 +100,7 @@ uint64_t Builder::FunctionId(const char* name, const char* system_name, return index; } -void Builder::SetDocURL(const std::string& url) { +void Builder::SetDocURL(const std::string &url) { const std::string kHttp = "http://"; const std::string kHttps = "https://"; @@ -116,7 +116,7 @@ void Builder::SetDocURL(const std::string& url) { profile_->set_doc_url(InternalStringId(url)); } -bool Builder::Emit(std::string* output) { +bool Builder::Emit(std::string *output) { *output = ""; if (!profile_ || !Finalize()) { return false; @@ -124,7 +124,7 @@ bool Builder::Emit(std::string* output) { return Marshal(*profile_, output); } -bool Builder::Marshal(const Profile& profile, std::string* output) { +bool Builder::Marshal(const Profile &profile, std::string *output) { *output = ""; StringOutputStream stream(output); GzipOutputStream gzip_stream(&stream); @@ -135,7 +135,7 @@ bool Builder::Marshal(const Profile& profile, std::string* output) { return gzip_stream.Close(); } -bool Builder::MarshalToFile(const Profile& profile, int fd) { +bool Builder::MarshalToFile(const Profile &profile, int fd) { FileOutputStream stream(fd); GzipOutputStream gzip_stream(&stream); if (!profile.SerializeToZeroCopyStream(&gzip_stream)) { @@ -145,7 +145,7 @@ bool Builder::MarshalToFile(const Profile& profile, int fd) { return gzip_stream.Close(); } -bool Builder::MarshalToFile(const Profile& profile, const char* filename) { +bool Builder::MarshalToFile(const Profile &profile, const char *filename) { int fd; while ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0 && errno == EINTR) { @@ -161,10 +161,10 @@ bool Builder::MarshalToFile(const Profile& profile, const char* filename) { // Returns a bool indicating if the profile is valid. It logs any // errors it encounters. -bool Builder::CheckValid(const Profile& profile) { +bool Builder::CheckValid(const Profile &profile) { IndexSet mapping_ids; mapping_ids.reserve(profile.mapping_size()); - for (const auto& mapping : profile.mapping()) { + for (const auto &mapping : profile.mapping()) { const int64_t id = mapping.id(); if (id != 0) { const bool insert_successful = mapping_ids.insert(id).second; @@ -177,7 +177,7 @@ bool Builder::CheckValid(const Profile& profile) { IndexSet function_ids; function_ids.reserve(profile.function_size()); - for (const auto& function : profile.function()) { + for (const auto &function : profile.function()) { const int64_t id = function.id(); if (id != 0) { const bool insert_successful = function_ids.insert(id).second; @@ -190,7 +190,7 @@ bool Builder::CheckValid(const Profile& profile) { IndexSet location_ids; location_ids.reserve(profile.location_size()); - for (const auto& location : profile.location()) { + for (const auto &location : profile.location()) { const int64_t id = location.id(); if (id != 0) { const bool insert_successful = location_ids.insert(id).second; @@ -204,7 +204,7 @@ bool Builder::CheckValid(const Profile& profile) { LOG(ERROR) << "Missing mapping " << mapping_id << " from location " << id; return false; } - for (const auto& line : location.line()) { + for (const auto &line : location.line()) { int64_t function_id = line.function_id(); if (function_id != 0 && function_ids.count(function_id) == 0) { LOG(ERROR) << "Missing function " << function_id; @@ -227,7 +227,7 @@ bool Builder::CheckValid(const Profile& profile) { } std::unordered_set value_types; - for (const auto& sample_type : profile.sample_type()) { + for (const auto &sample_type : profile.sample_type()) { if (!value_types.insert(sample_type.type()).second) { LOG(ERROR) << "Duplicate sample_type specified"; return false; @@ -239,7 +239,7 @@ bool Builder::CheckValid(const Profile& profile) { return false; } - for (const auto& sample : profile.sample()) { + for (const auto &sample : profile.sample()) { if (sample.value_size() != sample_type_len) { LOG(ERROR) << "Found sample with " << sample.value_size() << " values, expecting " << sample_type_len; @@ -257,7 +257,7 @@ bool Builder::CheckValid(const Profile& profile) { } } - for (const auto& label : sample.label()) { + for (const auto &label : sample.label()) { int64_t str = label.str(); int64_t num = label.num(); if (str != 0 && num != 0) { @@ -281,7 +281,7 @@ bool Builder::Finalize() { if (profile_->location_size() == 0) { IndexMap address_to_id; address_to_id.reserve(profile_->sample_size()); - for (auto& sample : *profile_->mutable_sample()) { + for (auto &sample : *profile_->mutable_sample()) { // Copy sample locations into a temp vector, and then clear and // repopulate it with the corresponding location IDs. const RepeatedField addresses = sample.location_id(); @@ -302,12 +302,12 @@ bool Builder::Finalize() { // Look up location address on mapping ranges. if (profile_->mapping_size() > 0) { std::map > mapping_map; - for (const auto& mapping : profile_->mapping()) { + for (const auto &mapping : profile_->mapping()) { mapping_map[mapping.memory_start()] = std::make_pair(mapping.memory_limit(), mapping.id()); } - for (auto& loc : *profile_->mutable_location()) { + for (auto &loc : *profile_->mutable_location()) { if (loc.address() != 0 && loc.mapping_id() == 0) { auto mapping = mapping_map.upper_bound(loc.address()); if (mapping == mapping_map.begin()) { diff --git a/src/builder.h b/src/builder.h index b440876..4349ed9 100644 --- a/src/builder.h +++ b/src/builder.h @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -30,7 +31,7 @@ typedef absl::flat_hash_map, enum CallstackType { kRegular = 0, kInterrupt = 1 }; -void AddCallstackToSample(Sample* sample, const void* const* stack, int depth, +void AddCallstackToSample(Sample *sample, const void *const *stack, int depth, CallstackType type); // Provides mechanisms to facilitate the generation of profiles @@ -54,14 +55,14 @@ class Builder { // Adds a function with these attributes to the profile function // table, if not already present. Returns a unique integer id for // this function. - uint64_t FunctionId(const char* name, const char* system_name, - const char* file, int64_t start_line); + uint64_t FunctionId(const char *name, const char *system_name, + const char *file, int64_t start_line); // Adds mappings for the currently running binary to the profile. void AddCurrentMappings(); // Add documentation URL. - void SetDocURL(const std::string& url); + void SetDocURL(const std::string &url); // Prepares the profile for encoding. Returns true on success. // If the profile has no locations, inserts location using the @@ -73,25 +74,25 @@ class Builder { // Serializes and compresses the profile into a string, replacing // its contents. It calls Finalize() and returns whether the // encoding was successful. - bool Emit(std::string* output); + bool Emit(std::string *output); // Serializes and compresses a profile into a string, replacing its // contents. Returns false if there were errors on the serialization // or compression, and the output string will not contain valid data. - static bool Marshal(const Profile& profile, std::string* output); + static bool Marshal(const Profile &profile, std::string *output); // Serializes and compresses a profile into a file represented by a // file descriptor. Returns false if there were errors on the // serialization or compression. - static bool MarshalToFile(const Profile& profile, int fd); + static bool MarshalToFile(const Profile &profile, int fd); // Serializes and compresses a profile into a file, creating a new // file or replacing its contents if it already exists. - static bool MarshalToFile(const Profile& profile, const char* filename); + static bool MarshalToFile(const Profile &profile, const char *filename); // Determines if the profile is internally consistent (suitable for // serialization). Returns true if no errors were encountered. - static bool CheckValid(const Profile& profile); + static bool CheckValid(const Profile &profile); // Extract the profile from the builder object. No further calls // should be made to the builder after this. @@ -101,7 +102,7 @@ class Builder { // managed by the builder. The fields function and string_table // should be populated through Builder::StringId and // Builder::FunctionId. - Profile* mutable_profile() { return profile_.get(); } + Profile *mutable_profile() { return profile_.get(); } private: int64_t InternalStringId(absl::string_view str); From f9eb05fcce80189c311a01341bb535a382d5d740 Mon Sep 17 00:00:00 2001 From: skanev Date: Wed, 18 Feb 2026 11:52:54 -0800 Subject: [PATCH 6/6] Update dependencies to build with bazel 9.0. Fix upstreaming process so that it doesn't accidentally strip out cc and proto rules. Also, update our internal CI-for-upstream to use a newer docker container with a bazel 9.0 default. PiperOrigin-RevId: 871975647 --- MODULE.bazel | 12 ++++++------ ci/linux_clang-latest_libcxx_bazel.sh | 7 ++++--- src/BUILD | 3 +++ src/quipper/BUILD | 9 ++++++++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index bdba966..43cdc9a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -4,25 +4,25 @@ module( compatibility_level = 1, ) -bazel_dep(name = "rules_cc", version = "0.1.5") +bazel_dep(name = "rules_cc", version = "0.2.14") # GoogleTest/GoogleMock framework. Used by most unit-tests. bazel_dep( name = "googletest", - version = "1.11.0", + version = "1.17.0.bcr.2", repo_name = "com_google_googletest", ) # zlib, used by proto builders. bazel_dep( name = "zlib", - version = "1.3.1", + version = "1.3.1.bcr.5", ) # Proto rules for Bazel and Protobuf bazel_dep( name = "protobuf", - version = "31.1", + version = "33.4", repo_name = "com_google_protobuf", ) bazel_dep( @@ -31,10 +31,10 @@ bazel_dep( ) bazel_dep( name = "gflags", - version = "2.2.2", + version = "2.2.2.bcr.1", repo_name = "com_github_gflags_gflags", ) bazel_dep( name = "abseil-cpp", - version = "20250512.0", + version = "20250814.1", ) diff --git a/ci/linux_clang-latest_libcxx_bazel.sh b/ci/linux_clang-latest_libcxx_bazel.sh index 83ad7e0..86f5acc 100755 --- a/ci/linux_clang-latest_libcxx_bazel.sh +++ b/ci/linux_clang-latest_libcxx_bazel.sh @@ -15,7 +15,7 @@ fi # This container is a reasonable start but is missing some prerequisite libs and # an installation of linux_perf. We'll manually add them below. -readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20231218" +readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20260131" time docker run \ --mount "type=bind,src=${PDC_HOST_ROOT},target=/perf_data_converter" \ @@ -23,10 +23,12 @@ time docker run \ --cap-add=SYS_PTRACE \ --rm \ -i \ - -e CC="/opt/llvm/clang/bin/clang" \ + -e CC="/opt/llvm/bin/clang" \ -e BAZEL_CXXOPTS="-nostdinc++" \ -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib" \ -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/c++/v1" \ + -e BAZEL_LINKOPTS="-L/opt/llvm/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/lib/x86_64-unknown-linux-gnu" \ + -e CPLUS_INCLUDE_PATH="/opt/llvm/include/c++/v1:/opt/llvm/include/x86_64-unknown-linux-gnu/c++/v1/" \ ${DOCKER_EXTRA_ARGS:-} \ ${DOCKER_CONTAINER} \ bash <