diff options
author | 2021-04-22 04:30:35 -0700 | |
---|---|---|
committer | 2021-04-22 09:26:52 -0700 | |
commit | e38e1aae3866a4ae3a41ccb38d3f05618ea30ca4 (patch) | |
tree | 72a8ed083e3153a908a1c5fe1b3b506212c4bb14 /absl/strings/cord.h | |
parent | 1ae9b71c474628d60eb251a3f62967fe64151bb2 (diff) |
Export of internal Abseil changes
--
9e0df3dd23da17cd0ff75c93c1493a858032639c by Martijn Vels <mvels@google.com>:
Prep work for changing Cordz instrumentation
Create CordzInfo::TrackCord() and CordzInfo::MaybeTrackCord() methods on InlineData
This follows a suggestion from kfm@ to move where possible Cordz logic out of Cord and Cord::InlineRep, which we can now that InlineData provides us the abstraction of Cords internal data.
PiperOrigin-RevId: 369844310
--
45f39709033bd3bc09fa1a7880a5b3c9eaa617c7 by Abseil Team <absl-team@google.com>:
Fix dependence on C++20 constexpr default construction of std::atomic.
PiperOrigin-RevId: 369745251
--
195ae230963c95068406ab0e73b4e711b5f3cd62 by Martijn Vels <mvels@google.com>:
Reduce the cost of 'SetCordRep()`
This change inlines SetCordRep(), which is currently two stores and a branch, going forward a naked store. AssertHeld is only enforced for debug builds.
The intention here is not to reduce the 'actual' (or 'self') cost of SetCordRep() as it should only be called for sampled cords, but to reduce the cost of a branch and out of line call at the call site. The compiler can now 'perfectly inline' the single branch / store.
PiperOrigin-RevId: 369696265
--
d722199ed69d413994740624159ac7bd001a9219 by Martijn Vels <mvels@google.com>:
Add kDefaultInit initialization
This avoids double store on init
PiperOrigin-RevId: 369655217
--
3499aed79e6cc12ce36277063ec37991bba0cccd by Martijn Vels <mvels@google.com>:
Introduce CordzUpdateScope
PiperOrigin-RevId: 369491326
--
325c1bc99c7d1aeca7bd1273e51a0900b6faf731 by Abseil Team <absl-team@google.com>:
make unary and logical operators constexpr
PiperOrigin-RevId: 369476773
--
ad3bed3dea5e5d7d281ff36ee786f802630c3728 by Martijn Vels <mvels@google.com>:
Add LOCKABLE attribute to CordzInfo
PiperOrigin-RevId: 369476772
GitOrigin-RevId: 9e0df3dd23da17cd0ff75c93c1493a858032639c
Change-Id: I00e2859328fe8da46d2e04d3f07dfe70ec6cb1f5
Diffstat (limited to 'absl/strings/cord.h')
-rw-r--r-- | absl/strings/cord.h | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 1e6a73a5..bca20981 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -84,6 +84,7 @@ #include "absl/strings/internal/cordz_functions.h" #include "absl/strings/internal/cordz_info.h" #include "absl/strings/internal/cordz_statistics.h" +#include "absl/strings/internal/cordz_update_scope.h" #include "absl/strings/internal/cordz_update_tracker.h" #include "absl/strings/internal/resize_uninitialized.h" #include "absl/strings/internal/string_constant.h" @@ -669,7 +670,11 @@ class Cord { explicit constexpr Cord(strings_internal::StringConstant<T>); private: + using CordzInfo = cord_internal::CordzInfo; + using CordzUpdateScope = cord_internal::CordzUpdateScope; using CordzUpdateTracker = cord_internal::CordzUpdateTracker; + using InlineData = cord_internal::InlineData; + using MethodIdentifier = CordzUpdateTracker::MethodIdentifier; friend class CordTestPeer; friend bool operator==(const Cord& lhs, const Cord& rhs); @@ -694,6 +699,7 @@ class Cord { static_assert(kMaxInline >= sizeof(absl::cord_internal::CordRep*), ""); constexpr InlineRep() : data_() {} + explicit InlineRep(InlineData::DefaultInitType init) : data_(init) {} InlineRep(const InlineRep& src); InlineRep(InlineRep&& src); InlineRep& operator=(const InlineRep& src); @@ -779,15 +785,6 @@ class Cord { // Resets the current cordz_info to null / empty. void clear_cordz_info() { data_.clear_cordz_info(); } - // Starts profiling this cord. - void StartProfiling(); - - // Starts profiling this cord which has been copied from `src`. - void StartProfiling(const Cord::InlineRep& src); - - // Returns true if a Cord should be profiled and false otherwise. - static bool should_profile(); - // Updates the cordz statistics. info may be nullptr if the CordzInfo object // is unknown. void UpdateCordzStatistics(); @@ -964,9 +961,8 @@ inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) if (is_tree()) { data_.clear_cordz_info(); absl::cord_internal::CordRep::Ref(as_tree()); - if (ABSL_PREDICT_FALSE(should_profile())) { - StartProfiling(src); - } + CordzInfo::MaybeTrackCord(data_, src.data_, + CordzUpdateTracker::kConstructorCord); } } @@ -1040,9 +1036,7 @@ inline void Cord::InlineRep::set_tree(absl::cord_internal::CordRep* rep) { } else { // `data_` contains inlined data: initialize data_ to tree value `rep`. data_.make_tree(rep); - if (ABSL_PREDICT_FALSE(should_profile())) { - StartProfiling(); - } + CordzInfo::MaybeTrackCord(data_, CordzUpdateTracker::kUnknown); } UpdateCordzStatistics(); } @@ -1074,10 +1068,6 @@ inline void Cord::InlineRep::CopyToArray(char* dst) const { cord_internal::SmallMemmove(dst, data_.as_chars(), n); } -inline ABSL_ATTRIBUTE_ALWAYS_INLINE bool Cord::InlineRep::should_profile() { - return absl::cord_internal::cordz_should_profile(); -} - inline void Cord::InlineRep::UpdateCordzStatistics() { if (ABSL_PREDICT_TRUE(!is_profiled())) return; UpdateCordzStatisticsSlow(); |