From e5ebc4dde8ed25c91225eb775fb4d7d125f23c91 Mon Sep 17 00:00:00 2001 From: blakejones Date: Thu, 20 Nov 2025 00:24:59 +0000 Subject: [PATCH 1/3] Store BPF ksymbol events with kernel mappings. PiperOrigin-RevId: 834488529 --- src/perf_data_handler.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/perf_data_handler.cc b/src/perf_data_handler.cc index 8fe0c3d..abdeb61 100644 --- a/src/perf_data_handler.cc +++ b/src/perf_data_handler.cc @@ -759,8 +759,8 @@ static bool IsVirtualMapping(const std::string& map_name) { void Normalizer::ConvertMmapFromKsymbol( const quipper::PerfDataProto_KsymbolEvent& ksymbol_event, uint32_t prot, quipper::PerfDataProto_MMapEvent* mmap) { - uint32_t pid = 1; - uint32_t tid = 1; + uint32_t pid = kKernelPid; + uint32_t tid = 0; uint32_t flags = 0; uint64_t pgoff = 0; mmap->set_pid(pid); From 4c2c94c49f00b1bfebaa1075cd7229904e34dac0 Mon Sep 17 00:00:00 2001 From: blakejones Date: Wed, 26 Nov 2025 02:01:35 +0000 Subject: [PATCH 2/3] Remove a noisy warning. PiperOrigin-RevId: 836876147 --- src/quipper/huge_page_deducer.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/quipper/huge_page_deducer.cc b/src/quipper/huge_page_deducer.cc index c3d61c0..9ca50ab 100644 --- a/src/quipper/huge_page_deducer.cc +++ b/src/quipper/huge_page_deducer.cc @@ -25,10 +25,6 @@ bool IsAnon(const MMapEvent& event) { bool is_anon = (event.filename() == kAnonFilename || event.filename() == kAnonHugepageFilename || event.filename() == kAnonHugepageDeletedFilename); - if (is_anon && event.pgoff() != 0) { - LOG(WARNING) << "//anon should have offset=0 for mmap " - << event.ShortDebugString(); - } return is_anon; } From 538b97f373916421a04b32c1515f6bacf18c7bea Mon Sep 17 00:00:00 2001 From: jcking Date: Fri, 5 Dec 2025 02:45:17 +0000 Subject: [PATCH 3/3] Internal change PiperOrigin-RevId: 840489807 --- src/builder.cc | 19 ++++++++----------- src/builder.h | 42 ++++++++++++------------------------------ 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/src/builder.cc b/src/builder.cc index 790ed21..a50097a 100644 --- a/src/builder.cc +++ b/src/builder.cc @@ -17,8 +17,9 @@ #include #include -#include -#include +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/strings/string_view.h" #include "src/quipper/base/logging.h" #include "google/protobuf/io/gzip_stream.h" @@ -31,13 +32,9 @@ using google::protobuf::RepeatedField; namespace perftools { namespace profiles { -typedef std::unordered_map IndexMap; -typedef std::unordered_set IndexSet; -} // namespace profiles -} // namespace perftools -namespace perftools { -namespace profiles { +typedef absl::flat_hash_map IndexMap; +typedef absl::flat_hash_set IndexSet; void AddCallstackToSample(Sample *sample, const void *const *stack, int depth, CallstackType type) { @@ -59,14 +56,14 @@ Builder::Builder() : profile_(new Profile()) { profile_->add_string_table(""); } -int64_t Builder::StringId(const char *str) { - if (str == nullptr || !str[0]) { +int64_t Builder::StringId(absl::string_view str) { + if (str.empty()) { return 0; } return InternalStringId(str); } -int64_t Builder::InternalStringId(const std::string &str) { +int64_t Builder::InternalStringId(absl::string_view str) { const int64_t index = profile_->string_table_size(); const auto inserted = strings_.emplace(str, index); if (!inserted.second) { diff --git a/src/builder.h b/src/builder.h index 243f428..4349ed9 100644 --- a/src/builder.h +++ b/src/builder.h @@ -16,40 +16,19 @@ #include #include -#include - -namespace perftools { -namespace profiles { - -typedef int64_t int64; -typedef uint64_t uint64; -typedef std::string string; - -typedef std::unordered_map StringIndexMap; - -class FunctionHasher { - public: - size_t operator()(const std::tuple &f) const { - int64 hash = std::get<0>(f); - hash = hash + ((hash << 8) ^ std::get<1>(f)); - hash = hash + ((hash << 8) ^ std::get<2>(f)); - hash = hash + ((hash << 8) ^ std::get<3>(f)); - return static_cast(hash); - } -}; - -typedef std::unordered_map, int64, - FunctionHasher> - FunctionIndexMap; - -} // namespace profiles -} // namespace perftools +#include "absl/container/flat_hash_map.h" +#include "absl/strings/string_view.h" #include "src/profile.pb.h" namespace perftools { namespace profiles { +typedef absl::flat_hash_map StringIndexMap; +typedef absl::flat_hash_map, + int64_t> + FunctionIndexMap; + enum CallstackType { kRegular = 0, kInterrupt = 1 }; void AddCallstackToSample(Sample *sample, const void *const *stack, int depth, @@ -68,7 +47,10 @@ class Builder { // Adds a string to the profile string table if not already present. // Returns a unique integer id for this string. - int64_t StringId(const char *str); + int64_t StringId(const char* str) { + return StringId(absl::NullSafeStringView(str)); + } + int64_t StringId(absl::string_view str); // Adds a function with these attributes to the profile function // table, if not already present. Returns a unique integer id for @@ -123,7 +105,7 @@ class Builder { Profile *mutable_profile() { return profile_.get(); } private: - int64_t InternalStringId(const std::string &str); + int64_t InternalStringId(absl::string_view str); // Maps to deduplicate strings and functions. StringIndexMap strings_;