Skip to content

Commit

Permalink
Replace in-house rand with absl::Random for backoff (grpc#26463)
Browse files Browse the repository at this point in the history
* Replace in-house rand with absl::Random for backoff

* Run sanity

* Added bscrypt dependency
  • Loading branch information
veblush authored Jun 11, 2021
1 parent a7fdf12 commit b5191d0
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 43 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ grpc_cc_library(
external_deps = [
"absl/base",
"absl/memory",
"absl/random",
"absl/status",
"absl/strings",
"absl/strings:str_format",
Expand Down
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ config("grpc_config") {
deps = [
":absl/base:base",
":absl/memory:memory",
":absl/random:random",
":absl/status:status",
":absl/strings:str_format",
":absl/strings:strings",
Expand Down
35 changes: 30 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ set(gRPC_ABSL_USED_TARGETS
absl_endian
absl_errno_saver
absl_exponential_biased
absl_fast_type_id
absl_fixed_array
absl_flat_hash_map
absl_function_ref
Expand All @@ -141,6 +142,29 @@ set(gRPC_ABSL_USED_TARGETS
absl_memory
absl_numeric_representation
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_set
absl_raw_logging_internal
Expand Down Expand Up @@ -1417,6 +1441,7 @@ target_link_libraries(gpr
${_gRPC_ALLTARGETS_LIBRARIES}
absl::base
absl::memory
absl::random_random
absl::status
absl::str_format
absl::strings
Expand Down Expand Up @@ -15814,7 +15839,7 @@ generate_pkgconfig(
"gpr"
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
"absl_base absl_memory absl_optional absl_status absl_str_format absl_strings absl_synchronization absl_time"
"absl_base absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time"
"-lgpr"
""
"gpr.pc")
Expand All @@ -15824,7 +15849,7 @@ generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"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"
"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"
"-lgrpc -laddress_sorting -lre2 -lupb -lcares -lz"
""
"grpc.pc")
Expand All @@ -15834,7 +15859,7 @@ generate_pkgconfig(
"gRPC unsecure"
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"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"
"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"
"-lgrpc_unsecure"
""
"grpc_unsecure.pc")
Expand All @@ -15844,7 +15869,7 @@ generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}"
"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"
"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"
"-lgrpc++"
""
"grpc++.pc")
Expand All @@ -15854,7 +15879,7 @@ generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}"
"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"
"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"
"-lgrpc++_unsecure"
""
"grpc++_unsecure.pc")
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ LDFLAGS += -pthread
endif

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

Expand Down Expand Up @@ -2588,6 +2588,17 @@ LIBGRPC_ABSEIL_SRC = \
third_party/abseil-cpp/absl/hash/internal/hash.cc \
third_party/abseil-cpp/absl/hash/internal/wyhash.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_payload_printer.cc \
third_party/abseil-cpp/absl/status/statusor.cc \
Expand Down
1 change: 1 addition & 0 deletions build_autogenerated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ libs:
deps:
- absl/base:base
- absl/memory:memory
- absl/random:random
- absl/status:status
- absl/strings:str_format
- absl/strings:strings
Expand Down
13 changes: 13 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,17 @@ if test "$PHP_GRPC" != "no"; then
third_party/abseil-cpp/absl/hash/internal/hash.cc \
third_party/abseil-cpp/absl/hash/internal/wyhash.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_payload_printer.cc \
third_party/abseil-cpp/absl/status/statusor.cc \
Expand Down Expand Up @@ -1216,6 +1227,8 @@ 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/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/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/strings)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal)
Expand Down
13 changes: 13 additions & 0 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,17 @@ if (PHP_GRPC != "no") {
"third_party\\abseil-cpp\\absl\\hash\\internal\\hash.cc " +
"third_party\\abseil-cpp\\absl\\hash\\internal\\wyhash.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_payload_printer.cc " +
"third_party\\abseil-cpp\\absl\\status\\statusor.cc " +
Expand Down Expand Up @@ -1327,6 +1338,8 @@ 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\\internal");
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\\strings");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal");
Expand Down
1 change: 1 addition & 0 deletions gRPC-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/functional/bind_front', 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/statusor', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version
Expand Down
1 change: 1 addition & 0 deletions gRPC-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/functional/bind_front', 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/statusor', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version
Expand Down
46 changes: 46 additions & 0 deletions grpc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ 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/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/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/identity.h )
s.files += %w( third_party/abseil-cpp/absl/base/internal/inline_variable.h )
Expand Down Expand Up @@ -1371,6 +1372,51 @@ 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/internal/bits.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/statusor_internal.h )
s.files += %w( third_party/abseil-cpp/absl/status/status.cc )
Expand Down
1 change: 1 addition & 0 deletions grpc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
'dependencies': [
'absl/base:base',
'absl/memory:memory',
'absl/random:random',
'absl/status:status',
'absl/strings:str_format',
'absl/strings:strings',
Expand Down
Loading

0 comments on commit b5191d0

Please sign in to comment.