|
|
|
// Copyright 2019 The Abseil Authors.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
// https://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.
|
|
|
|
|
|
|
|
#include "absl/strings/internal/cordz_info.h"
|
|
|
|
|
|
|
|
#include "absl/base/config.h"
|
|
|
|
#include "absl/base/internal/spinlock.h"
|
|
|
|
#include "absl/container/inlined_vector.h"
|
|
|
|
#include "absl/debugging/stacktrace.h"
|
|
|
|
#include "absl/strings/internal/cord_internal.h"
|
|
|
|
#include "absl/strings/internal/cord_rep_ring.h"
|
|
|
|
#include "absl/strings/internal/cordz_handle.h"
|
|
|
|
#include "absl/strings/internal/cordz_statistics.h"
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
#include "absl/strings/internal/cordz_update_tracker.h"
|
|
|
|
#include "absl/synchronization/mutex.h"
|
|
|
|
#include "absl/types/span.h"
|
|
|
|
|
|
|
|
namespace absl {
|
|
|
|
ABSL_NAMESPACE_BEGIN
|
|
|
|
namespace cord_internal {
|
|
|
|
|
|
|
|
using ::absl::base_internal::SpinLockHolder;
|
|
|
|
|
|
|
|
constexpr int CordzInfo::kMaxStackDepth;
|
|
|
|
|
|
|
|
ABSL_CONST_INIT CordzInfo::List CordzInfo::global_list_{absl::kConstInit};
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// CordRepAnalyzer performs the analysis of a cord.
|
|
|
|
//
|
|
|
|
// It computes absolute node counts and total memory usage, and an 'estimated
|
|
|
|
// fair share memory usage` statistic.
|
|
|
|
// Conceptually, it divides the 'memory usage' at each location in the 'cord
|
|
|
|
// graph' by the cumulative reference count of that location. The cumulative
|
|
|
|
// reference count is the factored total of all edges leading into that node.
|
|
|
|
//
|
|
|
|
// The top level node is treated specially: we assume the current thread
|
|
|
|
// (typically called from the CordzHandler) to hold a reference purely to
|
|
|
|
// perform a safe analysis, and not being part of the application. So we
|
|
|
|
// substract 1 from the reference count of the top node to compute the
|
|
|
|
// 'application fair share' excluding the reference of the current thread.
|
|
|
|
//
|
|
|
|
// An example of fair sharing, and why we multiply reference counts:
|
|
|
|
// Assume we have 2 CordReps, both being a Substring referencing a Flat:
|
|
|
|
// CordSubstring A (refcount = 5) --> child Flat C (refcount = 2)
|
|
|
|
// CordSubstring B (refcount = 9) --> child Flat C (refcount = 2)
|
|
|
|
//
|
|
|
|
// Flat C has 2 incoming edges from the 2 substrings (refcount = 2) and is not
|
|
|
|
// referenced directly anywhere else. Translated into a 'fair share', we then
|
|
|
|
// attribute 50% of the memory (memory / refcount = 2) to each incoming edge.
|
|
|
|
// Rep A has a refcount of 5, so we attribute each incoming edge 1 / 5th of the
|
|
|
|
// memory cost below it, i.e.: the fair share of Rep A of the memory used by C
|
|
|
|
// is then 'memory C / (refcount C * refcount A) + (memory A / refcount A)'.
|
|
|
|
// It is also easy to see how all incoming edges add up to 100%.
|
|
|
|
class CordRepAnalyzer {
|
|
|
|
public:
|
|
|
|
// Creates an analyzer instance binding to `statistics`.
|
|
|
|
explicit CordRepAnalyzer(CordzStatistics& statistics)
|
|
|
|
: statistics_(statistics) {}
|
|
|
|
|
|
|
|
// Analyzes the memory statistics and node counts for the provided `rep`, and
|
|
|
|
// adds the results to `statistics`. Note that node counts and memory sizes
|
|
|
|
// are not initialized, computed values are added to any existing values.
|
|
|
|
void AnalyzeCordRep(const CordRep* rep) {
|
|
|
|
// Process all linear nodes.
|
|
|
|
// As per the class comments, use refcout - 1 on the top level node, as the
|
|
|
|
// top level node is assumed to be referenced only for analysis purposes.
|
|
|
|
size_t refcount = rep->refcount.Get();
|
|
|
|
RepRef repref{rep, (refcount > 1) ? refcount - 1 : 1};
|
|
|
|
|
|
|
|
// Process all top level linear nodes (substrings and flats).
|
|
|
|
repref = CountLinearReps(repref, memory_usage_);
|
|
|
|
|
|
|
|
// We should have have either a concat or ring node node if not null.
|
|
|
|
if (repref.rep != nullptr) {
|
|
|
|
assert(repref.rep->tag == RING || repref.rep->tag == CONCAT);
|
|
|
|
if (repref.rep->tag == RING) {
|
|
|
|
AnalyzeRing(repref);
|
|
|
|
} else if (repref.rep->tag == CONCAT) {
|
|
|
|
AnalyzeConcat(repref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adds values to output
|
|
|
|
statistics_.estimated_memory_usage += memory_usage_.total;
|
|
|
|
statistics_.estimated_fair_share_memory_usage += memory_usage_.fair_share;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// RepRef identifies a CordRep* inside the Cord tree with its cumulative
|
|
|
|
// refcount including itself. For example, a tree consisting of a substring
|
|
|
|
// with a refcount of 3 and a child flat with a refcount of 4 will have RepRef
|
|
|
|
// refcounts of 3 and 12 respectively.
|
|
|
|
struct RepRef {
|
|
|
|
const CordRep* rep;
|
|
|
|
size_t refcount;
|
|
|
|
|
|
|
|
// Returns a 'child' RepRef which contains the cumulative reference count of
|
|
|
|
// this instance multiplied by the child's reference count.
|
|
|
|
RepRef Child(const CordRep* child) const {
|
|
|
|
return RepRef{child, refcount * child->refcount.Get()};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Memory usage values
|
|
|
|
struct MemoryUsage {
|
|
|
|
size_t total = 0;
|
|
|
|
size_t fair_share = 0;
|
|
|
|
|
|
|
|
// Adds 'size` memory usage to this class, with a cumulative (recursive)
|
|
|
|
// reference count of `refcount`
|
|
|
|
void Add(size_t size, size_t refcount) {
|
|
|
|
total += size;
|
|
|
|
fair_share += size / refcount;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Returns `rr` if `rr.rep` is not null and a CONCAT type.
|
|
|
|
// Asserts that `rr.rep` is a concat node or null.
|
|
|
|
static RepRef AssertConcat(RepRef repref) {
|
|
|
|
const CordRep* rep = repref.rep;
|
|
|
|
assert(rep == nullptr || rep->tag == CONCAT);
|
|
|
|
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.
|
|
|
|
// Node counts are updated into `statistics_`, memory usage is update into
|
|
|
|
// `memory_usage`, which typically references `memory_usage_` except for ring
|
|
|
|
// buffers where we count children unrounded.
|
|
|
|
RepRef CountLinearReps(RepRef rep, MemoryUsage& memory_usage) {
|
|
|
|
// Consume all substrings
|
|
|
|
while (rep.rep->tag == SUBSTRING) {
|
|
|
|
statistics_.node_count++;
|
|
|
|
statistics_.node_counts.substring++;
|
|
|
|
memory_usage.Add(sizeof(CordRepSubstring), rep.refcount);
|
|
|
|
rep = rep.Child(rep.rep->substring()->child);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Consume possible FLAT
|
|
|
|
if (rep.rep->tag >= FLAT) {
|
|
|
|
size_t size = rep.rep->flat()->AllocatedSize();
|
|
|
|
CountFlat(size);
|
|
|
|
memory_usage.Add(size, rep.refcount);
|
|
|
|
return RepRef{nullptr, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Consume possible external
|
|
|
|
if (rep.rep->tag == EXTERNAL) {
|
|
|
|
statistics_.node_count++;
|
|
|
|
statistics_.node_counts.external++;
|
|
|
|
size_t size = rep.rep->length + sizeof(CordRepExternalImpl<intptr_t>);
|
|
|
|
memory_usage.Add(size, rep.refcount);
|
|
|
|
return RepRef{nullptr, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
return rep;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Analyzes the provided concat node in a flattened recursive way.
|
|
|
|
void AnalyzeConcat(RepRef rep) {
|
|
|
|
absl::InlinedVector<RepRef, 47> pending;
|
|
|
|
|
|
|
|
while (rep.rep != nullptr) {
|
|
|
|
const CordRepConcat* concat = rep.rep->concat();
|
|
|
|
RepRef left = rep.Child(concat->left);
|
|
|
|
RepRef right = rep.Child(concat->right);
|
|
|
|
|
|
|
|
statistics_.node_count++;
|
|
|
|
statistics_.node_counts.concat++;
|
|
|
|
memory_usage_.Add(sizeof(CordRepConcat), rep.refcount);
|
|
|
|
|
|
|
|
right = AssertConcat(CountLinearReps(right, memory_usage_));
|
|
|
|
rep = AssertConcat(CountLinearReps(left, memory_usage_));
|
|
|
|
if (rep.rep != nullptr) {
|
|
|
|
if (right.rep != nullptr) {
|
|
|
|
pending.push_back(right);
|
|
|
|
}
|
|
|
|
} else if (right.rep != nullptr) {
|
|
|
|
rep = right;
|
|
|
|
} else if (!pending.empty()) {
|
|
|
|
rep = pending.back();
|
|
|
|
pending.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Counts the provided ring buffer child into `child_usage`.
|
|
|
|
void CountRingChild(const CordRep* child, MemoryUsage& child_usage) {
|
|
|
|
RepRef rep{child, static_cast<size_t>(child->refcount.Get())};
|
|
|
|
rep = CountLinearReps(rep, child_usage);
|
|
|
|
assert(rep.rep == nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Analyzes the provided ring. As ring buffers can have many child nodes, the
|
|
|
|
// effect of rounding errors can become non trivial, so we compute the totals
|
|
|
|
// first at the ring level, and then divide the fair share of the total
|
|
|
|
// including children fair share totals.
|
|
|
|
void AnalyzeRing(RepRef rep) {
|
|
|
|
statistics_.node_count++;
|
|
|
|
statistics_.node_counts.ring++;
|
|
|
|
MemoryUsage ring_usage;
|
|
|
|
const CordRepRing* ring = rep.rep->ring();
|
|
|
|
ring_usage.Add(CordRepRing::AllocSize(ring->capacity()), 1);
|
|
|
|
ring->ForEach([&](CordRepRing::index_type pos) {
|
|
|
|
CountRingChild(ring->entry_child(pos), ring_usage);
|
|
|
|
});
|
|
|
|
memory_usage_.total += ring_usage.total;
|
|
|
|
memory_usage_.fair_share += ring_usage.fair_share / rep.refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
CordzStatistics& statistics_;
|
|
|
|
MemoryUsage memory_usage_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
CordzInfo* CordzInfo::Head(const CordzSnapshot& snapshot) {
|
|
|
|
ABSL_ASSERT(snapshot.is_snapshot());
|
|
|
|
|
|
|
|
// We can do an 'unsafe' load of 'head', as we are guaranteed that the
|
|
|
|
// instance it points to is kept alive by the provided CordzSnapshot, so we
|
|
|
|
// can simply return the current value using an acquire load.
|
|
|
|
// We do enforce in DEBUG builds that the 'head' value is present in the
|
|
|
|
// delete queue: ODR violations may lead to 'snapshot' and 'global_list_'
|
|
|
|
// being in different libraries / modules.
|
|
|
|
CordzInfo* head = global_list_.head.load(std::memory_order_acquire);
|
|
|
|
ABSL_ASSERT(snapshot.DiagnosticsHandleIsSafeToInspect(head));
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
|
|
|
CordzInfo* CordzInfo::Next(const CordzSnapshot& snapshot) const {
|
|
|
|
ABSL_ASSERT(snapshot.is_snapshot());
|
|
|
|
|
|
|
|
// Similar to the 'Head()' function, we do not need a mutex here.
|
|
|
|
CordzInfo* next = ci_next_.load(std::memory_order_acquire);
|
|
|
|
ABSL_ASSERT(snapshot.DiagnosticsHandleIsSafeToInspect(this));
|
|
|
|
ABSL_ASSERT(snapshot.DiagnosticsHandleIsSafeToInspect(next));
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CordzInfo::TrackCord(InlineData& cord, MethodIdentifier method) {
|
|
|
|
assert(cord.is_tree());
|
|
|
|
assert(!cord.is_profiled());
|
|
|
|
CordzInfo* cordz_info = new CordzInfo(cord.as_tree(), nullptr, method);
|
|
|
|
cord.set_cordz_info(cordz_info);
|
|
|
|
cordz_info->Track();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CordzInfo::TrackCord(InlineData& cord, const InlineData& src,
|
|
|
|
MethodIdentifier method) {
|
|
|
|
assert(cord.is_tree());
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
CordzInfo::MethodIdentifier CordzInfo::GetParentMethod(const CordzInfo* src) {
|
|
|
|
if (src == nullptr) return MethodIdentifier::kUnknown;
|
|
|
|
return src->parent_method_ != MethodIdentifier::kUnknown ? src->parent_method_
|
|
|
|
: src->method_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CordzInfo::FillParentStack(const CordzInfo* src, void** stack) {
|
|
|
|
assert(stack);
|
|
|
|
if (src == nullptr) return 0;
|
|
|
|
if (src->parent_stack_depth_) {
|
|
|
|
memcpy(stack, src->parent_stack_, src->parent_stack_depth_ * sizeof(void*));
|
|
|
|
return src->parent_stack_depth_;
|
|
|
|
}
|
|
|
|
memcpy(stack, src->stack_, src->stack_depth_ * sizeof(void*));
|
|
|
|
return src->stack_depth_;
|
|
|
|
}
|
|
|
|
|
|
|
|
CordzInfo::CordzInfo(CordRep* rep, const CordzInfo* src,
|
|
|
|
MethodIdentifier method)
|
|
|
|
: rep_(rep),
|
|
|
|
stack_depth_(absl::GetStackTrace(stack_, /*max_depth=*/kMaxStackDepth,
|
|
|
|
/*skip_count=*/1)),
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
parent_stack_depth_(FillParentStack(src, parent_stack_)),
|
|
|
|
method_(method),
|
|
|
|
parent_method_(GetParentMethod(src)),
|
|
|
|
create_time_(absl::Now()) {
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
update_tracker_.LossyAdd(method);
|
|
|
|
if (src) {
|
|
|
|
// Copy parent counters.
|
|
|
|
update_tracker_.LossyAdd(src->update_tracker_);
|
|
|
|
}
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
}
|
|
|
|
|
|
|
|
CordzInfo::~CordzInfo() {
|
|
|
|
// `rep_` is potentially kept alive if CordzInfo is included
|
|
|
|
// in a collection snapshot (which should be rare).
|
|
|
|
if (ABSL_PREDICT_FALSE(rep_)) {
|
|
|
|
CordRep::Unref(rep_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CordzInfo::Track() {
|
|
|
|
SpinLockHolder l(&list_->mutex);
|
|
|
|
|
|
|
|
CordzInfo* const head = list_->head.load(std::memory_order_acquire);
|
|
|
|
if (head != nullptr) {
|
|
|
|
head->ci_prev_.store(this, std::memory_order_release);
|
|
|
|
}
|
|
|
|
ci_next_.store(head, std::memory_order_release);
|
|
|
|
list_->head.store(this, std::memory_order_release);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CordzInfo::Untrack() {
|
|
|
|
ODRCheck();
|
|
|
|
{
|
|
|
|
SpinLockHolder l(&list_->mutex);
|
|
|
|
|
|
|
|
CordzInfo* const head = list_->head.load(std::memory_order_acquire);
|
|
|
|
CordzInfo* const next = ci_next_.load(std::memory_order_acquire);
|
|
|
|
CordzInfo* const prev = ci_prev_.load(std::memory_order_acquire);
|
|
|
|
|
|
|
|
if (next) {
|
|
|
|
ABSL_ASSERT(next->ci_prev_.load(std::memory_order_acquire) == this);
|
|
|
|
next->ci_prev_.store(prev, std::memory_order_release);
|
|
|
|
}
|
|
|
|
if (prev) {
|
|
|
|
ABSL_ASSERT(head != this);
|
|
|
|
ABSL_ASSERT(prev->ci_next_.load(std::memory_order_acquire) == this);
|
|
|
|
prev->ci_next_.store(next, std::memory_order_release);
|
|
|
|
} else {
|
|
|
|
ABSL_ASSERT(head == this);
|
|
|
|
list_->head.store(next, std::memory_order_release);
|
|
|
|
}
|
|
|
|
}
|
Export of internal Abseil changes
--
60b8e77be4bab1bbd3b4c3b70054879229634511 by Derek Mauro <dmauro@google.com>:
Use _MSVC_LANG for some C++ dialect checks since MSVC doesn't
set __cplusplus accurately by default.
https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
See GitHub #722.
PiperOrigin-RevId: 371362181
--
5d736accdff04db0e722f377c0d79f2d3ed53263 by Martijn Vels <mvels@google.com>:
Fix the estimated memory size for CordRepExternal
PiperOrigin-RevId: 371350380
--
eaaa1d8a167aeca67a2aa3a098a2b61a9d72172f by Martijn Vels <mvels@google.com>:
Remove flakes by not enforcing re-allocated pointers do never match original
Tests that do multiple updates could end up with the original allocated pointer on a 2nd resize, so the 'EqIfPrivate' should not assume that if we do 'not' have the capacity that all following relocations will never match the original. We only care about 'pointer unchanged if private and there is capacity', trying to establish 'pointer changed at some point due to re-allocation; is pointless.
PiperOrigin-RevId: 371338965
--
d1837bee6bade1902b095c1cbf64231668bb84c5 by Martijn Vels <mvels@google.com>:
Undo inline of small data copy in cord
This leads to a performance regression as the code is not inlined (absent hard FDO inputs), and there are no suitable tail call options.
PiperOrigin-RevId: 371332332
--
06dc64b833069efc7d18b11df607c8c22be690da by Martijn Vels <mvels@google.com>:
Add final instrumentation for Cordz and remove 'old' cordz logic.
This change instruments the last cord function for cordz. It removes the 'old' functions: set_tree, replace_tree, UpdateCordzStatistics and RecordMetrics.
PiperOrigin-RevId: 371219909
--
a5e0be538579c603052feec03e6d9910c43ea787 by Martijn Vels <mvels@google.com>:
Extend the life of CordRep* if inside a snapshot
If a snapshot (potentially) includes the current CordzInfo, we need to extent the lifetime of the CordRep*, as the snapshot 'point in time' observation of the cord should ideally be preserved.
PiperOrigin-RevId: 371146151
--
74d77a89774cd6c8ecdeebee0193b294a39383d6 by Martijn Vels <mvels@google.com>:
Instrument std::string consuming methods: ctor, operator=, Append and Prepend
This change moves the 'steal into CordRep' logic into a separate function so we can use it directly in the ctor, operator assign and append and prepend, allowing Cordz instrumentation with the proper method attributes.
The assign operator is implemented in AssignLargeString leaving the dispatch inlined in cord.h (which as a side effects also allows clean tail calls in the AssignLargeString method)
PiperOrigin-RevId: 371094756
--
b39effc45266b7ce2e7f96caa3b16cb6e3acc2dd by Martijn Vels <mvels@google.com>:
Add Cordz instrumentation to CordReader
PiperOrigin-RevId: 370990181
GitOrigin-RevId: 60b8e77be4bab1bbd3b4c3b70054879229634511
Change-Id: I96af62e6f1a643e8b1228ae01e6c84e33706bb05
4 years ago
|
|
|
|
|
|
|
// We can no longer be discovered: perform a fast path check if we are not
|
|
|
|
// listed on any delete queue, so we can directly delete this instance.
|
|
|
|
if (SafeToDelete()) {
|
|
|
|
UnsafeSetCordRep(nullptr);
|
|
|
|
delete this;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We are likely part of a snapshot, extend the life of the CordRep
|
|
|
|
{
|
|
|
|
absl::MutexLock lock(&mutex_);
|
|
|
|
if (rep_) CordRep::Ref(rep_);
|
|
|
|
}
|
|
|
|
CordzHandle::Delete(this);
|
|
|
|
}
|
|
|
|
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
void CordzInfo::Lock(MethodIdentifier method)
|
|
|
|
ABSL_EXCLUSIVE_LOCK_FUNCTION(mutex_) {
|
|
|
|
mutex_.Lock();
|
|
|
|
update_tracker_.LossyAdd(method);
|
|
|
|
assert(rep_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CordzInfo::Unlock() ABSL_UNLOCK_FUNCTION(mutex_) {
|
|
|
|
bool tracked = rep_ != nullptr;
|
|
|
|
mutex_.Unlock();
|
|
|
|
if (!tracked) {
|
|
|
|
Untrack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
absl::Span<void* const> CordzInfo::GetStack() const {
|
|
|
|
return absl::MakeConstSpan(stack_, stack_depth_);
|
|
|
|
}
|
|
|
|
|
|
|
|
absl::Span<void* const> CordzInfo::GetParentStack() const {
|
|
|
|
return absl::MakeConstSpan(parent_stack_, parent_stack_depth_);
|
|
|
|
}
|
|
|
|
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
CordzStatistics CordzInfo::GetCordzStatistics() const {
|
|
|
|
CordzStatistics stats;
|
|
|
|
stats.method = method_;
|
|
|
|
stats.parent_method = parent_method_;
|
|
|
|
stats.update_tracker = update_tracker_;
|
|
|
|
if (CordRep* rep = RefCordRep()) {
|
|
|
|
stats.size = rep->length;
|
|
|
|
CordRepAnalyzer analyzer(stats);
|
|
|
|
analyzer.AnalyzeCordRep(rep);
|
|
|
|
CordRep::Unref(rep);
|
|
|
|
}
|
Export of internal Abseil changes
--
ac1df60490c9583e475e22de7adfc40023196fbf by Martijn Vels <mvels@google.com>:
Change Cord constructor(string_view) to explicit make_tree and Cordz tracking
This CL changes the ctor to use an easier to maintain model where Cord code explicitly invokes Cordz update or new / tree logic, which avoids the ambiguity of the 'branched' InlineRep::set_tree code. This removes the need to equip InlineRep with 'MethodIdentifier' or other necessary call info, and also is a cleaner model: InlineRep is carrying too much code now that should plainly sit in Cord, especially with all internal abstractions having moved to InlineData.
See child CL(s) for desired state
PiperOrigin-RevId: 369433619
--
b665af7f586e6c679a8b27d4f78d5a1d2b596058 by Abseil Team <absl-team@google.com>:
Rename the 'Compare' template type to 'LessThan', as the passed-in function is expected to act like operator<. It is worth avoiding confusion with std::compare, which returns an int (-1/0/1), as due to implicit casting this can lead to hard-to-spot bugs.
PiperOrigin-RevId: 369391118
--
c3c775269cad0f4982ec63f3616dd78bb9e52dca by Martijn Vels <mvels@google.com>:
Integrate CordzUpdateTracker into CordzInfo
PiperOrigin-RevId: 369348824
--
771d81ed357496c117179e1daec76eba5155932d by Martijn Vels <mvels@google.com>:
Replace mutex() with Lock() / Unlock() function
Mini design future tracking of CordzInfo sampled cords: CordzInfo holds a CordRep* reference without a reference count. Cord is responsible for synchronizing updates for sampled cords such that the CordRep* contained in CordzInfo is at all times valid. This is done by scoping Lock() and Unlock() calls around the code modifying the code of a sampled cord. For example (using the future CL CordzUpdateScope()):
CordzInfo* cordz_info = get_cordz_info();
CordzUpdateScope scope(cordz_info, CordzUpdateTracker::kRemovePrefix);
CordRep* rep = RemovePrefixImpl(root);
set_tree(rep);
if (cordz_info) {
cordz_info->SetCordRep(rep);
}
On CordzInfo::Unlock(), if the internal rep is null, the cord is no longer sampled, and CordzInfo will be deleted. Thus any update resulting in the Cord being inlined will automatically no longer be sampled.
PiperOrigin-RevId: 369338802
--
5563c12df04a1e965a03b50bdd032739c55c0706 by Martijn Vels <mvels@google.com>:
Add UpdateTracker to CordzStatistics
PiperOrigin-RevId: 369318178
--
6b4d8463722a3e55a3e8f6cb3741a41055e7f83e by Martijn Vels <mvels@google.com>:
Add kClear, kConstructor* and kUnknown values and fix typo
PiperOrigin-RevId: 369297163
--
041adcbc929789d6d53371a8236840fc350e1eeb by Derek Mauro <dmauro@google.com>:
Switch from malloc to operator new in pool_urbg.cc
so it can only fail by throwing/aborting
PiperOrigin-RevId: 369274087
--
5d97a5f43e3f2d02d0a5bbe586d93b5751812981 by Benjamin Barenblat <bbaren@google.com>:
Correct Thumb function bound computation in the symbolizer
On 32-bit ARM, all functions are aligned to multiples of two bytes, and
the lowest-order bit in a function’s address is ignored by the CPU when
computing branch targets. That bit is still present in instructions and
ELF symbol tables, though; it’s repurposed to indicate whether the
function contains ARM or Thumb code. If the symbolizer doesn’t ignore
that bit, it will believe Thumb functions have boundaries that are off
by one byte, so instruct the symbolizer to null out the lowest-order bit
after retrieving it from the symbol table.
PiperOrigin-RevId: 369254082
--
462bb307c6cc332c1e2c3adb5f0cad51804bf937 by Derek Mauro <dmauro@google.com>:
Add a check for malloc failure in pool_urbg.cc
GitHub #940
PiperOrigin-RevId: 369238100
GitOrigin-RevId: ac1df60490c9583e475e22de7adfc40023196fbf
Change-Id: Ic6ec91c62cd3a0031f6a75a43a83da959ece2d25
4 years ago
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace cord_internal
|
|
|
|
ABSL_NAMESPACE_END
|
|
|
|
} // namespace absl
|