diff options
author | Abseil Team <absl-team@google.com> | 2021-05-06 20:08:01 -0700 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2021-05-07 13:51:04 -0400 |
commit | 079cf662544a14bd1cfaae6d6512645541ba10fb (patch) | |
tree | 99d164c0162508aa69ace6879d9a36f89e145065 /absl/strings/internal/cordz_info.cc | |
parent | 70b29fe5a5c1752158830eabc9aa273718b477af (diff) | |
download | abseil-079cf662544a14bd1cfaae6d6512645541ba10fb.tar.gz abseil-079cf662544a14bd1cfaae6d6512645541ba10fb.tar.bz2 abseil-079cf662544a14bd1cfaae6d6512645541ba10fb.zip |
Export of internal Abseil changes
--
51e9291d9bc385082b4061fe760b236ba59c79c3 by Abseil Team <absl-team@google.com>:
Cast to uint64_t using braces instead of parentheses.
PiperOrigin-RevId: 372475909
--
939fc409855da2639dcaf2d1d4971ca0e0568d03 by Martijn Vels <mvels@google.com>:
Expand # flat nodes into size detailed counters.
PiperOrigin-RevId: 372474608
--
54b158c99b32f8a14821ce74fed0f9f836525ce7 by Martijn Vels <mvels@google.com>:
Make copies of sampled cords sampled as well
This applies to the following methods:
- Cord(const Cord&)
- operator=(const Cord&)
- Subcord(...)
PiperOrigin-RevId: 372468160
--
876c2581ce008871464e8b471efbb967d150f83b by Andy Getzendanner <durandal@google.com>:
Document the type of an ABSL_FLAGS.OnUpdate() callback.
PiperOrigin-RevId: 372406390
GitOrigin-RevId: 51e9291d9bc385082b4061fe760b236ba59c79c3
Change-Id: Ifb75122cae56b66c28128aee90a63bbb28d93817
Diffstat (limited to 'absl/strings/internal/cordz_info.cc')
-rw-r--r-- | absl/strings/internal/cordz_info.cc | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/absl/strings/internal/cordz_info.cc b/absl/strings/internal/cordz_info.cc index e1fa6b6b..a6b045ff 100644 --- a/absl/strings/internal/cordz_info.cc +++ b/absl/strings/internal/cordz_info.cc @@ -135,6 +135,23 @@ class CordRepAnalyzer { return (rep != nullptr && rep->tag == CONCAT) ? repref : RepRef{nullptr, 0}; } + // Counts a flat of the provide allocated size + void CountFlat(size_t size) { + statistics_.node_count++; + statistics_.node_counts.flat++; + if (size <= 64) { + statistics_.node_counts.flat_64++; + } else if (size <= 128) { + statistics_.node_counts.flat_128++; + } else if (size <= 256) { + statistics_.node_counts.flat_256++; + } else if (size <= 512) { + statistics_.node_counts.flat_512++; + } else if (size <= 1024) { + statistics_.node_counts.flat_1k++; + } + } + // Processes 'linear' reps (substring, flat, external) not requiring iteration // or recursion. Returns RefRep{null} if all reps were processed, else returns // the top-most non-linear concat or ring cordrep. @@ -152,9 +169,9 @@ class CordRepAnalyzer { // Consume possible FLAT if (rep.rep->tag >= FLAT) { - statistics_.node_count++; - statistics_.node_counts.flat++; - memory_usage.Add(rep.rep->flat()->AllocatedSize(), rep.refcount); + size_t size = rep.rep->flat()->AllocatedSize(); + CountFlat(size); + memory_usage.Add(size, rep.refcount); return RepRef{nullptr, 0}; } @@ -263,9 +280,15 @@ void CordzInfo::TrackCord(InlineData& cord, MethodIdentifier method) { void CordzInfo::TrackCord(InlineData& cord, const InlineData& src, MethodIdentifier method) { assert(cord.is_tree()); - assert(!cord.is_profiled()); - auto* info = src.is_tree() && src.is_profiled() ? src.cordz_info() : nullptr; - CordzInfo* cordz_info = new CordzInfo(cord.as_tree(), info, method); + assert(src.is_tree()); + + // Unsample current as we the current cord is being replaced with 'src', + // so any method history is no longer relevant. + CordzInfo* cordz_info = cord.cordz_info(); + if (cordz_info != nullptr) cordz_info->Untrack(); + + // Start new cord sample + cordz_info = new CordzInfo(cord.as_tree(), src.cordz_info(), method); cord.set_cordz_info(cordz_info); cordz_info->Track(); } @@ -297,6 +320,10 @@ CordzInfo::CordzInfo(CordRep* rep, const CordzInfo* src, parent_method_(GetParentMethod(src)), create_time_(absl::Now()) { update_tracker_.LossyAdd(method); + if (src) { + // Copy parent counters. + update_tracker_.LossyAdd(src->update_tracker_); + } } CordzInfo::~CordzInfo() { |