Skip to content

Commit

Permalink
Export of internal Abseil changes
Browse files Browse the repository at this point in the history
--
341670bce317dd6af8d3c066970230591a47e80c by Martijn Vels <mvels@google.com>:

Change GetStack() and GetParentStack() to return absl::Span

PiperOrigin-RevId: 368765721

--
6aaab9536d6957303c7aba100c3afaa6fb0ea2c8 by Martijn Vels <mvels@google.com>:

Remove locking from parent stack.

This change removes the need to lock all access to `parent_stack' by making the 'copy constructor' logic specify the 'copied from' CordzInfo (where available) to the TrackCord function, after which parent_stack is immutable.

PiperOrigin-RevId: 368760630

--
b19e2059cada35a8ede994833018edac94de6ddc by Martijn Vels <mvels@google.com>:

Add cordz instrumentation to Cord

PiperOrigin-RevId: 368746225

--
67b8bbf980f0f4e1db79aa32968e9a715a09b51a by Martijn Vels <mvels@google.com>:

Create ABSL_INTERNAL_CORDZ_ENABLED define controlling when Cordz code is enabled

There are specific builds and condtions under which we don't support cordz sampling, which is per this change represented by ABSL_INTERNAL_CORDZ_ENABLED being defined.

PiperOrigin-RevId: 368731603

--
8cbfe0e3169637a620f4b66ad2bc2ce340879cb0 by Martijn Vels <mvels@google.com>:

Add a `rep` property to CordzInfo to be managed by Cord logic.

This change adds a `rep` property to CordzInfo, which is intended to be used by collection logic.

Mini design:
Cord invokes TrackCord() providing the active 'root' cordrep of the newly sampled Cord, returning a CordzInfo with a weak (uncounted) reference to this root. Cord invokes `SetCordRep()` each time the root cordrep of the sampled Cord is updated while holding `mutex()`. Cord must also obtain `mutex()` _before_ removing a reference on the old root. i.e.: Cord must guarantee that the (weak) reference held in CordzInfo is at all times valid.

CordzInfo collection code can then safely obtain a (reference counted) rep pointer by adding a reference to `rep_` while holding `mutex()`. This requires only a very brief critical section inside CordzInfo logic, minimizing contention with concurrent Cord updates.

Cord code should typically obtain and hold `mutex()` for the entirety of each mutating Cord operation on a sampled cord. As Cord is thread compatible, it never competes on the lock with any other thread. The only possible concurrent access is from Cordz collection code, which should be a relatively rare event.

PiperOrigin-RevId: 368673758

--
1255120dce2bdd6b4205a34a0e555e0b74b6152f by Martijn Vels <mvels@google.com>:

Remove 'depth' from active recorded metrics.

Going forward we do not 'live' record depth (and size), but will observe these at collection time only.

PiperOrigin-RevId: 368636572

--
83e5146e35f221736b49e9f0a8805f8c159a51db by Martijn Vels <mvels@google.com>:

Make cordz targets visible in OSS

PiperOrigin-RevId: 368615010

--
dcb16a4f1239151f0a8c70a8cfeb29dabbd113b8 by Martijn Vels <mvels@google.com>:

Internal cleanup

PiperOrigin-RevId: 368514666
GitOrigin-RevId: 341670bce317dd6af8d3c066970230591a47e80c
Change-Id: I94cecfbbd441eb386f99fc5186c468a7a5538862
  • Loading branch information
Abseil Team authored and dinord committed Apr 16, 2021
1 parent 46dfbfe commit e20fe88
Show file tree
Hide file tree
Showing 18 changed files with 2,142 additions and 5 deletions.
17 changes: 13 additions & 4 deletions CMake/AbseilDll.cmake
Expand Up @@ -197,17 +197,26 @@ set(ABSL_INTERNAL_DLL_FILES
"strings/cord.h"
"strings/escaping.cc"
"strings/escaping.h"
"strings/internal/charconv_bigint.cc"
"strings/internal/charconv_bigint.h"
"strings/internal/charconv_parse.cc"
"strings/internal/charconv_parse.h"
"strings/internal/cord_internal.cc"
"strings/internal/cord_internal.h"
"strings/internal/cord_rep_flat.h"
"strings/internal/cord_rep_ring.cc"
"strings/internal/cord_rep_ring.h"
"strings/internal/cord_rep_ring_reader.h"
"strings/internal/cordz_functions.cc"
"strings/internal/cordz_functions.h"
"strings/internal/cordz_handle.cc"
"strings/internal/cordz_handle.h"
"strings/internal/cordz_info.cc"
"strings/internal/cordz_info.h"
"strings/internal/cordz_sample_token.cc"
"strings/internal/cordz_sample_token.h"
"strings/internal/cordz_statistics.h"
"strings/internal/cordz_update_tracker.h"
"strings/internal/charconv_bigint.cc"
"strings/internal/charconv_bigint.h"
"strings/internal/charconv_parse.cc"
"strings/internal/charconv_parse.h"
"strings/internal/stl_type_traits.h"
"strings/internal/string_constant.h"
"strings/match.cc"
Expand Down
136 changes: 136 additions & 0 deletions absl/strings/BUILD.bazel
Expand Up @@ -327,11 +327,15 @@ cc_library(
copts = ABSL_DEFAULT_COPTS,
deps = [
":cord_internal",
":cordz_functions",
":cordz_info",
":cordz_statistics",
":cordz_update_tracker",
":internal",
":str_format",
":strings",
"//absl/base",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:endian",
"//absl/base:raw_logging_internal",
Expand All @@ -343,6 +347,138 @@ cc_library(
],
)

cc_library(
name = "cordz_handle",
srcs = ["internal/cordz_handle.cc"],
hdrs = ["internal/cordz_handle.h"],
copts = ABSL_DEFAULT_COPTS,
deps = [
"//absl/base:config",
"//absl/base:raw_logging_internal",
"//absl/synchronization",
],
)

cc_library(
name = "cordz_info",
srcs = ["internal/cordz_info.cc"],
hdrs = ["internal/cordz_info.h"],
copts = ABSL_DEFAULT_COPTS,
deps = [
":cord_internal",
":cordz_handle",
":cordz_statistics",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/debugging:stacktrace",
"//absl/synchronization",
"//absl/types:span",
],
)

cc_library(
name = "cordz_sample_token",
srcs = ["internal/cordz_sample_token.cc"],
hdrs = ["internal/cordz_sample_token.h"],
copts = ABSL_DEFAULT_COPTS,
deps = [
":cordz_handle",
":cordz_info",
"//absl/base:config",
],
)

cc_library(
name = "cordz_functions",
srcs = ["internal/cordz_functions.cc"],
hdrs = ["internal/cordz_functions.h"],
copts = ABSL_DEFAULT_COPTS,
deps = [
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:exponential_biased",
"//absl/base:raw_logging_internal",
],
)

cc_library(
name = "cordz_statistics",
hdrs = ["internal/cordz_statistics.h"],
copts = ABSL_DEFAULT_COPTS,
deps = [
"//absl/base:config",
],
)

cc_test(
name = "cordz_functions_test",
srcs = [
"internal/cordz_functions_test.cc",
],
deps = [
":cord_test_helpers",
":cordz_functions",
"//absl/base:config",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "cordz_handle_test",
srcs = [
"internal/cordz_handle_test.cc",
],
deps = [
":cordz_handle",
"//absl/base:config",
"//absl/memory",
"//absl/random",
"//absl/random:distributions",
"//absl/synchronization",
"//absl/synchronization:thread_pool",
"//absl/time",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "cordz_info_test",
srcs = [
"internal/cordz_info_test.cc",
],
deps = [
":cord_internal",
":cordz_handle",
":cordz_info",
":strings",
"//absl/base:config",
"//absl/debugging:stacktrace",
"//absl/debugging:symbolize",
"//absl/types:span",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "cordz_sample_token_test",
srcs = [
"internal/cordz_sample_token_test.cc",
],
deps = [
":cord_internal",
":cordz_handle",
":cordz_info",
":cordz_sample_token",
"//absl/base:config",
"//absl/memory",
"//absl/random",
"//absl/synchronization",
"//absl/synchronization:thread_pool",
"//absl/time",
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "cord_test_helpers",
testonly = 1,
Expand Down
150 changes: 149 additions & 1 deletion absl/strings/CMakeLists.txt
Expand Up @@ -259,7 +259,7 @@ absl_cc_test(
absl_cc_test(
NAME
str_join_test
SRCS
ss SRCS
"str_join_test.cc"
COPTS
${ABSL_TEST_COPTS}
Expand Down Expand Up @@ -603,6 +603,152 @@ absl_cc_test(
gmock_main
)

absl_cc_library(
NAME
cordz_functions
HDRS
"internal/cordz_functions.h"
SRCS
"internal/cordz_functions.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::core_headers
absl::exponential_biased
absl::raw_logging_internal
)

absl_cc_test(
NAME
cordz_functions_test
SRCS
"internal/cordz_functions_test.cc"
DEPS
absl::config
absl::cord_test_helpers
absl::cordz_functions
gmock_main
)

absl_cc_library(
NAME
cordz_statistics
HDRS
"internal/cordz_statistics.h"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::core_headers
absl::synchronization
)

absl_cc_library(
NAME
cordz_handle
HDRS
"internal/cordz_handle.h"
SRCS
"internal/cordz_handle.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::synchronization
)

absl_cc_test(
NAME
cordz_handle_test
SRCS
"internal/cordz_handle_test.cc"
DEPS
absl::config
absl::cord_test_helpers
absl::cordz_handle
absl::memory
absl::random_random
absl::random_distributions
absl::synchronization
absl::time
gmock_main
)

absl_cc_library(
NAME
cordz_info
HDRS
"internal/cordz_info.h"
SRCS
"internal/cordz_info.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::cord_internal
absl::cordz_handle
absl::cordz_statistics
absl::core_headers
absl::span
absl::stacktrace
absl::synchronization
)

absl_cc_test(
NAME
cordz_info_test
SRCS
"internal/cordz_info_test.cc"
DEPS
absl::config
absl::cord_internal
absl::cord_test_helpers
absl::cordz_handle
absl::cordz_info
absl::span
absl::stacktrace
absl::symbolize
gmock_main
)

absl_cc_library(
NAME
cordz_sample_token
HDRS
"internal/cordz_sample_token.h"
SRCS
"internal/cordz_sample_token.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::cordz_handle
absl::cordz_info
)

absl_cc_test(
NAME
cordz_sample_token_test
SRCS
"internal/cordz_sample_token_test.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::cord_internal
absl::cordz_handle
absl::cordz_info
absl::cordz_info
absl::cordz_sample_token
absl::memory
absl::random_random
absl::synchronization
absl::thread_pool
absl::time
gmock_main
)

absl_cc_library(
NAME
cord
Expand All @@ -616,6 +762,8 @@ absl_cc_library(
absl::base
absl::config
absl::cord_internal
absl::cordz_functions
absl::cordz_info
absl::cordz_update_tracker
absl::core_headers
absl::endian
Expand Down

0 comments on commit e20fe88

Please sign in to comment.