Revert "Replace in-house rand with absl::Random for backoff (#26463)" (#26476)

This reverts commit b5191d0930.
reviewable/pr26487/r1
Jan Tattermusch 3 years ago committed by GitHub
parent 22cbc3a388
commit 451127740d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 1
      BUILD.gn
  3. 35
      CMakeLists.txt
  4. 13
      Makefile
  5. 1
      build_autogenerated.yaml
  6. 13
      config.m4
  7. 13
      config.w32
  8. 1
      gRPC-C++.podspec
  9. 1
      gRPC-Core.podspec
  10. 46
      grpc.gemspec
  11. 1
      grpc.gyp
  12. 46
      package.xml
  13. 3
      setup.py
  14. 34
      src/core/lib/backoff/backoff.cc
  15. 6
      src/core/lib/backoff/backoff.h
  16. 11
      src/python/grpcio/grpc_core_dependencies.py
  17. 2
      templates/Makefile.template
  18. 2
      test/core/backoff/backoff_test.cc

@ -650,7 +650,6 @@ grpc_cc_library(
external_deps = [ external_deps = [
"absl/base", "absl/base",
"absl/memory", "absl/memory",
"absl/random",
"absl/status", "absl/status",
"absl/strings", "absl/strings",
"absl/strings:str_format", "absl/strings:str_format",

@ -203,7 +203,6 @@ config("grpc_config") {
deps = [ deps = [
":absl/base:base", ":absl/base:base",
":absl/memory:memory", ":absl/memory:memory",
":absl/random:random",
":absl/status:status", ":absl/status:status",
":absl/strings:str_format", ":absl/strings:str_format",
":absl/strings:strings", ":absl/strings:strings",

@ -121,7 +121,6 @@ set(gRPC_ABSL_USED_TARGETS
absl_endian absl_endian
absl_errno_saver absl_errno_saver
absl_exponential_biased absl_exponential_biased
absl_fast_type_id
absl_fixed_array absl_fixed_array
absl_flat_hash_map absl_flat_hash_map
absl_function_ref absl_function_ref
@ -142,29 +141,6 @@ set(gRPC_ABSL_USED_TARGETS
absl_memory absl_memory
absl_numeric_representation absl_numeric_representation
absl_optional absl_optional
absl_random_distributions
absl_random_internal_distribution_caller
absl_random_internal_fast_uniform_bits
absl_random_internal_fastmath
absl_random_internal_generate_real
absl_random_internal_iostream_state_saver
absl_random_internal_nonsecure_base
absl_random_internal_pcg_engine
absl_random_internal_platform
absl_random_internal_pool_urbg
absl_random_internal_randen
absl_random_internal_randen_engine
absl_random_internal_randen_hwaes
absl_random_internal_randen_hwaes_impl
absl_random_internal_randen_slow
absl_random_internal_salted_seed_seq
absl_random_internal_seed_material
absl_random_internal_traits
absl_random_internal_uniform_helper
absl_random_internal_wide_multiply
absl_random_random
absl_random_seed_gen_exception
absl_random_seed_sequences
absl_raw_hash_map absl_raw_hash_map
absl_raw_hash_set absl_raw_hash_set
absl_raw_logging_internal absl_raw_logging_internal
@ -1449,7 +1425,6 @@ target_link_libraries(gpr
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
absl::base absl::base
absl::memory absl::memory
absl::random_random
absl::status absl::status
absl::str_format absl::str_format
absl::strings absl::strings
@ -15847,7 +15822,7 @@ generate_pkgconfig(
"gpr" "gpr"
"gRPC platform support library" "gRPC platform support library"
"${gRPC_CORE_VERSION}" "${gRPC_CORE_VERSION}"
"absl_base absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time" "absl_base absl_memory absl_optional absl_status absl_str_format absl_strings absl_synchronization absl_time"
"-lgpr" "-lgpr"
"" ""
"gpr.pc") "gpr.pc")
@ -15857,7 +15832,7 @@ generate_pkgconfig(
"gRPC" "gRPC"
"high performance general RPC framework" "high performance general RPC framework"
"${gRPC_CORE_VERSION}" "${gRPC_CORE_VERSION}"
"gpr openssl absl_base absl_bind_front absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_random_random absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time" "gpr openssl absl_base absl_bind_front absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time"
"-lgrpc -laddress_sorting -lre2 -lupb -lcares -lz" "-lgrpc -laddress_sorting -lre2 -lupb -lcares -lz"
"" ""
"grpc.pc") "grpc.pc")
@ -15867,7 +15842,7 @@ generate_pkgconfig(
"gRPC unsecure" "gRPC unsecure"
"high performance general RPC framework without SSL" "high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}" "${gRPC_CORE_VERSION}"
"gpr absl_base absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_random_random absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time" "gpr absl_base absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time"
"-lgrpc_unsecure" "-lgrpc_unsecure"
"" ""
"grpc_unsecure.pc") "grpc_unsecure.pc")
@ -15877,7 +15852,7 @@ generate_pkgconfig(
"gRPC++" "gRPC++"
"C++ wrapper for gRPC" "C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}" "${gRPC_CPP_VERSION}"
"grpc absl_base absl_bind_front absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_random_random absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time" "grpc absl_base absl_bind_front absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time"
"-lgrpc++" "-lgrpc++"
"" ""
"grpc++.pc") "grpc++.pc")
@ -15887,7 +15862,7 @@ generate_pkgconfig(
"gRPC++ unsecure" "gRPC++ unsecure"
"C++ wrapper for gRPC without SSL" "C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}" "${gRPC_CPP_VERSION}"
"grpc_unsecure absl_base absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_random_random absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time" "grpc_unsecure absl_base absl_flat_hash_map absl_inlined_vector absl_memory absl_optional absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time"
"-lgrpc++_unsecure" "-lgrpc++_unsecure"
"" ""
"grpc++_unsecure.pc") "grpc++_unsecure.pc")

@ -418,7 +418,7 @@ LDFLAGS += -pthread
endif endif
ifeq ($(SYSTEM),MINGW32) ifeq ($(SYSTEM),MINGW32)
LIBS = m pthread ws2_32 dbghelp bcrypt LIBS = m pthread ws2_32 dbghelp
LDFLAGS += -pthread LDFLAGS += -pthread
endif endif
@ -2588,17 +2588,6 @@ LIBGRPC_ABSEIL_SRC = \
third_party/abseil-cpp/absl/hash/internal/hash.cc \ third_party/abseil-cpp/absl/hash/internal/hash.cc \
third_party/abseil-cpp/absl/hash/internal/wyhash.cc \ third_party/abseil-cpp/absl/hash/internal/wyhash.cc \
third_party/abseil-cpp/absl/numeric/int128.cc \ third_party/abseil-cpp/absl/numeric/int128.cc \
third_party/abseil-cpp/absl/random/discrete_distribution.cc \
third_party/abseil-cpp/absl/random/gaussian_distribution.cc \
third_party/abseil-cpp/absl/random/internal/pool_urbg.cc \
third_party/abseil-cpp/absl/random/internal/randen.cc \
third_party/abseil-cpp/absl/random/internal/randen_detect.cc \
third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc \
third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc \
third_party/abseil-cpp/absl/random/internal/randen_slow.cc \
third_party/abseil-cpp/absl/random/internal/seed_material.cc \
third_party/abseil-cpp/absl/random/seed_gen_exception.cc \
third_party/abseil-cpp/absl/random/seed_sequences.cc \
third_party/abseil-cpp/absl/status/status.cc \ third_party/abseil-cpp/absl/status/status.cc \
third_party/abseil-cpp/absl/status/status_payload_printer.cc \ third_party/abseil-cpp/absl/status/status_payload_printer.cc \
third_party/abseil-cpp/absl/status/statusor.cc \ third_party/abseil-cpp/absl/status/statusor.cc \

@ -385,7 +385,6 @@ libs:
deps: deps:
- absl/base:base - absl/base:base
- absl/memory:memory - absl/memory:memory
- absl/random:random
- absl/status:status - absl/status:status
- absl/strings:str_format - absl/strings:str_format
- absl/strings:strings - absl/strings:strings

@ -680,17 +680,6 @@ if test "$PHP_GRPC" != "no"; then
third_party/abseil-cpp/absl/hash/internal/hash.cc \ third_party/abseil-cpp/absl/hash/internal/hash.cc \
third_party/abseil-cpp/absl/hash/internal/wyhash.cc \ third_party/abseil-cpp/absl/hash/internal/wyhash.cc \
third_party/abseil-cpp/absl/numeric/int128.cc \ third_party/abseil-cpp/absl/numeric/int128.cc \
third_party/abseil-cpp/absl/random/discrete_distribution.cc \
third_party/abseil-cpp/absl/random/gaussian_distribution.cc \
third_party/abseil-cpp/absl/random/internal/pool_urbg.cc \
third_party/abseil-cpp/absl/random/internal/randen.cc \
third_party/abseil-cpp/absl/random/internal/randen_detect.cc \
third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc \
third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc \
third_party/abseil-cpp/absl/random/internal/randen_slow.cc \
third_party/abseil-cpp/absl/random/internal/seed_material.cc \
third_party/abseil-cpp/absl/random/seed_gen_exception.cc \
third_party/abseil-cpp/absl/random/seed_sequences.cc \
third_party/abseil-cpp/absl/status/status.cc \ third_party/abseil-cpp/absl/status/status.cc \
third_party/abseil-cpp/absl/status/status_payload_printer.cc \ third_party/abseil-cpp/absl/status/status_payload_printer.cc \
third_party/abseil-cpp/absl/status/statusor.cc \ third_party/abseil-cpp/absl/status/statusor.cc \
@ -1227,8 +1216,6 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/debugging/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/debugging/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/hash/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/hash/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/numeric) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/numeric)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/random)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/random/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/status) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/status)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal)

@ -646,17 +646,6 @@ if (PHP_GRPC != "no") {
"third_party\\abseil-cpp\\absl\\hash\\internal\\hash.cc " + "third_party\\abseil-cpp\\absl\\hash\\internal\\hash.cc " +
"third_party\\abseil-cpp\\absl\\hash\\internal\\wyhash.cc " + "third_party\\abseil-cpp\\absl\\hash\\internal\\wyhash.cc " +
"third_party\\abseil-cpp\\absl\\numeric\\int128.cc " + "third_party\\abseil-cpp\\absl\\numeric\\int128.cc " +
"third_party\\abseil-cpp\\absl\\random\\discrete_distribution.cc " +
"third_party\\abseil-cpp\\absl\\random\\gaussian_distribution.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\pool_urbg.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\randen.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\randen_detect.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\randen_hwaes.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\randen_round_keys.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\randen_slow.cc " +
"third_party\\abseil-cpp\\absl\\random\\internal\\seed_material.cc " +
"third_party\\abseil-cpp\\absl\\random\\seed_gen_exception.cc " +
"third_party\\abseil-cpp\\absl\\random\\seed_sequences.cc " +
"third_party\\abseil-cpp\\absl\\status\\status.cc " + "third_party\\abseil-cpp\\absl\\status\\status.cc " +
"third_party\\abseil-cpp\\absl\\status\\status_payload_printer.cc " + "third_party\\abseil-cpp\\absl\\status\\status_payload_printer.cc " +
"third_party\\abseil-cpp\\absl\\status\\statusor.cc " + "third_party\\abseil-cpp\\absl\\status\\statusor.cc " +
@ -1338,8 +1327,6 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\hash"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\hash");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\hash\\internal"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\hash\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\numeric"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\numeric");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\random");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\random\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\status"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\status");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal");

@ -193,7 +193,6 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/container/inlined_vector', abseil_version ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/functional/bind_front', abseil_version ss.dependency 'abseil/functional/bind_front', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/random/random', abseil_version
ss.dependency 'abseil/status/status', abseil_version ss.dependency 'abseil/status/status', abseil_version
ss.dependency 'abseil/status/statusor', abseil_version ss.dependency 'abseil/status/statusor', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version ss.dependency 'abseil/strings/str_format', abseil_version

@ -180,7 +180,6 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/container/inlined_vector', abseil_version ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/functional/bind_front', abseil_version ss.dependency 'abseil/functional/bind_front', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/random/random', abseil_version
ss.dependency 'abseil/status/status', abseil_version ss.dependency 'abseil/status/status', abseil_version
ss.dependency 'abseil/status/statusor', abseil_version ss.dependency 'abseil/status/statusor', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version ss.dependency 'abseil/strings/str_format', abseil_version

@ -1270,7 +1270,6 @@ Gem::Specification.new do |s|
s.files += %w( third_party/abseil-cpp/absl/base/internal/errno_saver.h ) s.files += %w( third_party/abseil-cpp/absl/base/internal/errno_saver.h )
s.files += %w( third_party/abseil-cpp/absl/base/internal/exponential_biased.cc ) s.files += %w( third_party/abseil-cpp/absl/base/internal/exponential_biased.cc )
s.files += %w( third_party/abseil-cpp/absl/base/internal/exponential_biased.h ) s.files += %w( third_party/abseil-cpp/absl/base/internal/exponential_biased.h )
s.files += %w( third_party/abseil-cpp/absl/base/internal/fast_type_id.h )
s.files += %w( third_party/abseil-cpp/absl/base/internal/hide_ptr.h ) s.files += %w( third_party/abseil-cpp/absl/base/internal/hide_ptr.h )
s.files += %w( third_party/abseil-cpp/absl/base/internal/identity.h ) s.files += %w( third_party/abseil-cpp/absl/base/internal/identity.h )
s.files += %w( third_party/abseil-cpp/absl/base/internal/inline_variable.h ) s.files += %w( third_party/abseil-cpp/absl/base/internal/inline_variable.h )
@ -1372,51 +1371,6 @@ Gem::Specification.new do |s|
s.files += %w( third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc ) s.files += %w( third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc )
s.files += %w( third_party/abseil-cpp/absl/numeric/internal/bits.h ) s.files += %w( third_party/abseil-cpp/absl/numeric/internal/bits.h )
s.files += %w( third_party/abseil-cpp/absl/numeric/internal/representation.h ) s.files += %w( third_party/abseil-cpp/absl/numeric/internal/representation.h )
s.files += %w( third_party/abseil-cpp/absl/random/bernoulli_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/beta_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/discrete_distribution.cc )
s.files += %w( third_party/abseil-cpp/absl/random/discrete_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/distributions.h )
s.files += %w( third_party/abseil-cpp/absl/random/exponential_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/gaussian_distribution.cc )
s.files += %w( third_party/abseil-cpp/absl/random/gaussian_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/distribution_caller.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/fastmath.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/generate_real.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/nonsecure_base.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/pcg_engine.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/platform.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/pool_urbg.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/pool_urbg.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_detect.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_detect.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_engine.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_hwaes.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_slow.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_slow.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/randen_traits.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/seed_material.cc )
s.files += %w( third_party/abseil-cpp/absl/random/internal/seed_material.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/traits.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/uniform_helper.h )
s.files += %w( third_party/abseil-cpp/absl/random/internal/wide_multiply.h )
s.files += %w( third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/poisson_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/random.h )
s.files += %w( third_party/abseil-cpp/absl/random/seed_gen_exception.cc )
s.files += %w( third_party/abseil-cpp/absl/random/seed_gen_exception.h )
s.files += %w( third_party/abseil-cpp/absl/random/seed_sequences.cc )
s.files += %w( third_party/abseil-cpp/absl/random/seed_sequences.h )
s.files += %w( third_party/abseil-cpp/absl/random/uniform_int_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/uniform_real_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/random/zipf_distribution.h )
s.files += %w( third_party/abseil-cpp/absl/status/internal/status_internal.h ) s.files += %w( third_party/abseil-cpp/absl/status/internal/status_internal.h )
s.files += %w( third_party/abseil-cpp/absl/status/internal/statusor_internal.h ) s.files += %w( third_party/abseil-cpp/absl/status/internal/statusor_internal.h )
s.files += %w( third_party/abseil-cpp/absl/status/status.cc ) s.files += %w( third_party/abseil-cpp/absl/status/status.cc )

@ -386,7 +386,6 @@
'dependencies': [ 'dependencies': [
'absl/base:base', 'absl/base:base',
'absl/memory:memory', 'absl/memory:memory',
'absl/random:random',
'absl/status:status', 'absl/status:status',
'absl/strings:str_format', 'absl/strings:str_format',
'absl/strings:strings', 'absl/strings:strings',

@ -1272,7 +1272,6 @@
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/errno_saver.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/errno_saver.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/exponential_biased.cc" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/exponential_biased.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/exponential_biased.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/exponential_biased.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/fast_type_id.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/hide_ptr.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/hide_ptr.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/identity.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/identity.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/inline_variable.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/base/internal/inline_variable.h" role="src" />
@ -1374,51 +1373,6 @@
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/numeric/internal/bits.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/numeric/internal/bits.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/numeric/internal/representation.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/numeric/internal/representation.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/bernoulli_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/beta_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/discrete_distribution.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/discrete_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/distributions.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/exponential_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/gaussian_distribution.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/gaussian_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/distribution_caller.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/fastmath.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/generate_real.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/nonsecure_base.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/pcg_engine.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/platform.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/pool_urbg.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/pool_urbg.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_detect.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_detect.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_engine.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_hwaes.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_slow.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_slow.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/randen_traits.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/seed_material.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/seed_material.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/traits.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/uniform_helper.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/internal/wide_multiply.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/poisson_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/random.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/seed_gen_exception.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/seed_gen_exception.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/seed_sequences.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/seed_sequences.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/uniform_int_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/uniform_real_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/random/zipf_distribution.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/status/internal/status_internal.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/status/internal/status_internal.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/status/internal/statusor_internal.h" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/status/internal/statusor_internal.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/status/status.cc" role="src" /> <file baseinstalldir="/" name="third_party/abseil-cpp/absl/status/status.cc" role="src" />

@ -316,9 +316,8 @@ if not "win32" in sys.platform:
if "win32" in sys.platform: if "win32" in sys.platform:
EXTENSION_LIBRARIES += ( EXTENSION_LIBRARIES += (
'advapi32', 'advapi32',
'bcrypt',
'dbghelp',
'ws2_32', 'ws2_32',
'dbghelp',
) )
if BUILD_WITH_SYSTEM_OPENSSL: if BUILD_WITH_SYSTEM_OPENSSL:
EXTENSION_LIBRARIES += ( EXTENSION_LIBRARIES += (

@ -26,7 +26,31 @@
namespace grpc_core { namespace grpc_core {
BackOff::BackOff(const Options& options) : options_(options) { Reset(); } namespace {
/* Generate a random number between 0 and 1. We roll our own RNG because seeding
* rand() modifies a global variable we have no control over. */
double generate_uniform_random_number(uint32_t* rng_state) {
constexpr uint32_t two_raise_31 = uint32_t(1) << 31;
*rng_state = (1103515245 * *rng_state + 12345) % two_raise_31;
return *rng_state / static_cast<double>(two_raise_31);
}
double generate_uniform_random_number_between(uint32_t* rng_state, double a,
double b) {
if (a == b) return a;
if (a > b) GPR_SWAP(double, a, b); // make sure a < b
const double range = b - a;
return a + generate_uniform_random_number(rng_state) * range;
}
} // namespace
BackOff::BackOff(const Options& options)
: options_(options),
rng_state_(static_cast<uint32_t>(gpr_now(GPR_CLOCK_REALTIME).tv_nsec)) {
Reset();
}
grpc_millis BackOff::NextAttemptTime() { grpc_millis BackOff::NextAttemptTime() {
if (initial_) { if (initial_) {
@ -36,9 +60,9 @@ grpc_millis BackOff::NextAttemptTime() {
current_backoff_ = static_cast<grpc_millis>( current_backoff_ = static_cast<grpc_millis>(
std::min(current_backoff_ * options_.multiplier(), std::min(current_backoff_ * options_.multiplier(),
static_cast<double>(options_.max_backoff()))); static_cast<double>(options_.max_backoff())));
const double jitter = const double jitter = generate_uniform_random_number_between(
absl::Uniform(rand_gen_, -options_.jitter() * current_backoff_, &rng_state_, -options_.jitter() * current_backoff_,
options_.jitter() * current_backoff_); options_.jitter() * current_backoff_);
const grpc_millis next_timeout = const grpc_millis next_timeout =
static_cast<grpc_millis>(current_backoff_ + jitter); static_cast<grpc_millis>(current_backoff_ + jitter);
return next_timeout + grpc_core::ExecCtx::Get()->Now(); return next_timeout + grpc_core::ExecCtx::Get()->Now();
@ -49,4 +73,6 @@ void BackOff::Reset() {
initial_ = true; initial_ = true;
} }
void BackOff::SetRandomSeed(uint32_t seed) { rng_state_ = seed; }
} // namespace grpc_core } // namespace grpc_core

@ -23,8 +23,6 @@
#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/exec_ctx.h"
#include "absl/random/random.h"
namespace grpc_core { namespace grpc_core {
/// Implementation of the backoff mechanism described in /// Implementation of the backoff mechanism described in
@ -43,6 +41,8 @@ class BackOff {
/// will be the time of the second attempt (rather than the Nth). /// will be the time of the second attempt (rather than the Nth).
void Reset(); void Reset();
void SetRandomSeed(unsigned int seed);
class Options { class Options {
public: public:
Options& set_initial_backoff(grpc_millis initial_backoff) { Options& set_initial_backoff(grpc_millis initial_backoff) {
@ -79,7 +79,7 @@ class BackOff {
private: private:
const Options options_; const Options options_;
absl::BitGen rand_gen_; uint32_t rng_state_;
bool initial_; bool initial_;
/// current delay before retries /// current delay before retries
grpc_millis current_backoff_; grpc_millis current_backoff_;

@ -645,17 +645,6 @@ CORE_SOURCE_FILES = [
'third_party/abseil-cpp/absl/hash/internal/hash.cc', 'third_party/abseil-cpp/absl/hash/internal/hash.cc',
'third_party/abseil-cpp/absl/hash/internal/wyhash.cc', 'third_party/abseil-cpp/absl/hash/internal/wyhash.cc',
'third_party/abseil-cpp/absl/numeric/int128.cc', 'third_party/abseil-cpp/absl/numeric/int128.cc',
'third_party/abseil-cpp/absl/random/discrete_distribution.cc',
'third_party/abseil-cpp/absl/random/gaussian_distribution.cc',
'third_party/abseil-cpp/absl/random/internal/pool_urbg.cc',
'third_party/abseil-cpp/absl/random/internal/randen.cc',
'third_party/abseil-cpp/absl/random/internal/randen_detect.cc',
'third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc',
'third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc',
'third_party/abseil-cpp/absl/random/internal/randen_slow.cc',
'third_party/abseil-cpp/absl/random/internal/seed_material.cc',
'third_party/abseil-cpp/absl/random/seed_gen_exception.cc',
'third_party/abseil-cpp/absl/random/seed_sequences.cc',
'third_party/abseil-cpp/absl/status/status.cc', 'third_party/abseil-cpp/absl/status/status.cc',
'third_party/abseil-cpp/absl/status/status_payload_printer.cc', 'third_party/abseil-cpp/absl/status/status_payload_printer.cc',
'third_party/abseil-cpp/absl/status/statusor.cc', 'third_party/abseil-cpp/absl/status/statusor.cc',

@ -284,7 +284,7 @@
endif endif
ifeq ($(SYSTEM),MINGW32) ifeq ($(SYSTEM),MINGW32)
LIBS = m pthread ws2_32 dbghelp bcrypt LIBS = m pthread ws2_32 dbghelp
LDFLAGS += -pthread LDFLAGS += -pthread
endif endif

@ -138,6 +138,8 @@ TEST(BackOffTest, JitterBackOff) {
.set_max_backoff(max_backoff); .set_max_backoff(max_backoff);
BackOff backoff(options); BackOff backoff(options);
backoff.SetRandomSeed(0); // force consistent PRNG
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_millis next = backoff.NextAttemptTime(); grpc_millis next = backoff.NextAttemptTime();
EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff); EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);

Loading…
Cancel
Save