grpc 1.73.0 → 1.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +38 -17
- data/include/grpc/create_channel_from_endpoint.h +54 -0
- data/include/grpc/credentials.h +11 -5
- data/include/grpc/event_engine/event_engine.h +74 -17
- data/include/grpc/grpc_posix.h +20 -1
- data/include/grpc/impl/channel_arg_names.h +2 -4
- data/include/grpc/module.modulemap +1 -0
- data/include/grpc/support/json.h +24 -0
- data/src/core/call/interception_chain.h +7 -11
- data/src/core/channelz/channel_trace.cc +213 -115
- data/src/core/channelz/channel_trace.h +380 -86
- data/src/core/channelz/channelz.cc +270 -181
- data/src/core/channelz/channelz.h +168 -55
- data/src/core/channelz/channelz_registry.cc +2 -1
- data/src/core/channelz/channelz_registry.h +24 -0
- data/src/core/channelz/property_list.cc +357 -0
- data/src/core/channelz/property_list.h +202 -0
- data/src/core/channelz/ztrace_collector.h +3 -2
- data/src/core/client_channel/backup_poller.cc +17 -2
- data/src/core/client_channel/client_channel.cc +17 -28
- data/src/core/client_channel/client_channel_filter.cc +19 -29
- data/src/core/client_channel/config_selector.h +8 -2
- data/src/core/client_channel/dynamic_filters.cc +5 -6
- data/src/core/client_channel/dynamic_filters.h +1 -1
- data/src/core/client_channel/global_subchannel_pool.cc +4 -1
- data/src/core/client_channel/retry_filter.cc +21 -27
- data/src/core/client_channel/retry_filter.h +10 -7
- data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -5
- data/src/core/client_channel/retry_filter_legacy_call_data.h +1 -1
- data/src/core/client_channel/retry_interceptor.cc +30 -44
- data/src/core/client_channel/retry_interceptor.h +18 -17
- data/src/core/client_channel/retry_throttle.cc +46 -61
- data/src/core/client_channel/retry_throttle.h +17 -39
- data/src/core/client_channel/subchannel.cc +43 -19
- data/src/core/client_channel/subchannel.h +8 -0
- data/src/core/config/config_vars.cc +2 -0
- data/src/core/config/core_configuration.cc +1 -0
- data/src/core/config/core_configuration.h +11 -0
- data/src/core/credentials/call/call_creds_registry.h +125 -0
- data/src/core/credentials/call/call_creds_registry_init.cc +91 -0
- data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +6 -48
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +86 -0
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h +74 -0
- data/src/core/credentials/call/jwt_util.cc +70 -0
- data/src/core/credentials/call/jwt_util.h +32 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +1 -1
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +72 -4
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +0 -1
- data/src/core/credentials/transport/tls/load_system_roots_supported.cc +1 -0
- data/src/core/credentials/transport/xds/xds_credentials.cc +0 -3
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +8 -8
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +16 -16
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/compression_filter.h +25 -22
- data/src/core/ext/filters/http/server/http_server_filter.h +12 -11
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +120 -35
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +162 -115
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +0 -3
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +1239 -3514
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1008 -1486
- data/src/core/ext/transport/chttp2/transport/flow_control.h +22 -17
- data/src/core/ext/transport/chttp2/transport/frame.cc +10 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +299 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +11 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +12 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +1017 -0
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +593 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +19 -22
- data/{third_party/abseil-cpp/absl/strings/cord_buffer.cc → src/core/ext/transport/chttp2/transport/http2_stats_collector.cc} +14 -14
- data/src/core/ext/transport/chttp2/transport/http2_stats_collector.h +33 -0
- data/src/core/ext/transport/chttp2/transport/http2_status.h +6 -1
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +43 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +65 -0
- data/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h +0 -29
- data/src/core/ext/transport/chttp2/transport/internal.h +18 -8
- data/src/core/ext/transport/chttp2/transport/keepalive.cc +105 -0
- data/src/core/ext/transport/chttp2/transport/keepalive.h +138 -0
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +185 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -4
- data/src/core/ext/transport/chttp2/transport/ping_callbacks.h +19 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +151 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +180 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +5 -9
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +11 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +39 -1
- data/src/core/ext/transport/chttp2/transport/transport_common.cc +19 -0
- data/src/core/ext/transport/chttp2/transport/transport_common.h +27 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +37 -11
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb.h +571 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.c +120 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.h +36 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb.h +1272 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.c +312 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.h +50 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +984 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +226 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +44 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.c +175 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.h +82 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +135 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +67 -0
- data/src/core/filter/auth/auth_filters.h +0 -25
- data/src/core/filter/auth/client_auth_filter.cc +0 -118
- data/src/core/filter/filter_args.h +9 -23
- data/src/core/handshaker/handshaker.cc +23 -14
- data/src/core/handshaker/handshaker.h +3 -0
- data/src/core/handshaker/http_connect/http_connect_handshaker.cc +3 -1
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +6 -5
- data/src/core/handshaker/security/secure_endpoint.cc +70 -25
- data/src/core/handshaker/security/security_handshaker.cc +4 -1
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +7 -1
- data/src/core/lib/channel/channel_args.cc +15 -0
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/channel_stack.cc +22 -23
- data/src/core/lib/channel/channel_stack.h +9 -7
- data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -1
- data/src/core/lib/channel/channel_stack_builder_impl.h +2 -7
- data/src/core/lib/channel/promise_based_filter.h +5 -5
- data/src/core/lib/debug/trace_impl.h +0 -1
- data/src/core/lib/event_engine/ares_resolver.cc +165 -46
- data/src/core/lib/event_engine/ares_resolver.h +48 -2
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +1 -4
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +2 -6
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.cc +40 -0
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.h +60 -0
- data/src/core/lib/event_engine/event_engine.cc +7 -0
- data/src/core/lib/event_engine/extensions/channelz.h +10 -6
- data/src/core/lib/event_engine/grpc_polled_fd.h +5 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +130 -162
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +11 -15
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +75 -117
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -9
- data/src/core/lib/event_engine/posix_engine/event_poller.h +18 -15
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +0 -18
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +124 -0
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h +243 -0
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +29 -19
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +6 -2
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +6 -1
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +145 -92
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -19
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +333 -116
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +61 -18
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +45 -37
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +6 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +32 -142
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +6 -5
- data/src/core/lib/event_engine/posix_engine/posix_interface.h +211 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc +1083 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_windows.cc +281 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.cc +154 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h +174 -0
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -719
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +10 -170
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +33 -22
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +13 -11
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +117 -151
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +26 -94
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +26 -25
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +36 -62
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +7 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +12 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +3 -1
- data/src/core/lib/event_engine/shim.cc +9 -0
- data/src/core/lib/event_engine/shim.h +3 -0
- data/src/core/lib/event_engine/thread_pool/thread_pool.h +7 -3
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +0 -17
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +4 -2
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +3 -2
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +4 -0
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h +4 -0
- data/src/core/lib/event_engine/windows/windows_endpoint.h +2 -6
- data/src/core/lib/event_engine/windows/windows_engine.cc +0 -1
- data/src/core/lib/event_engine/windows/windows_engine.h +1 -3
- data/src/core/lib/event_engine/windows/windows_listener.cc +14 -2
- data/src/core/lib/experiments/experiments.cc +45 -93
- data/src/core/lib/experiments/experiments.h +21 -51
- data/src/core/lib/iomgr/endpoint.cc +4 -3
- data/src/core/lib/iomgr/endpoint.h +7 -4
- data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +7 -2
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -2
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +4 -6
- data/src/core/lib/iomgr/tcp_posix.cc +12 -6
- data/src/core/lib/iomgr/tcp_windows.cc +3 -2
- data/src/core/lib/promise/activity.h +1 -0
- data/src/core/lib/promise/arena_promise.h +23 -7
- data/src/core/lib/promise/detail/promise_factory.h +10 -0
- data/src/core/lib/promise/detail/promise_like.h +118 -11
- data/src/core/lib/promise/detail/promise_variant.h +50 -0
- data/src/core/lib/promise/detail/seq_state.h +687 -548
- data/src/core/lib/promise/if.h +20 -0
- data/src/core/lib/promise/inter_activity_latch.h +147 -0
- data/src/core/lib/promise/inter_activity_mutex.h +547 -0
- data/src/core/lib/promise/loop.h +65 -3
- data/src/core/lib/promise/map.h +24 -0
- data/src/core/lib/promise/match_promise.h +103 -0
- data/src/core/lib/promise/mpsc.cc +425 -0
- data/src/core/lib/promise/mpsc.h +490 -0
- data/src/core/lib/promise/party.cc +50 -1
- data/src/core/lib/promise/party.h +66 -1
- data/src/core/lib/promise/race.h +31 -0
- data/src/core/lib/promise/seq.h +4 -1
- data/src/core/lib/promise/status_flag.h +7 -0
- data/src/core/lib/promise/try_seq.h +4 -1
- data/src/core/lib/promise/wait_set.cc +28 -0
- data/src/core/lib/promise/wait_set.h +86 -0
- data/src/core/lib/resource_quota/arena.h +19 -0
- data/src/core/lib/slice/slice.h +5 -0
- data/src/core/lib/surface/channel_create.cc +88 -13
- data/src/core/lib/surface/channel_create.h +4 -0
- data/src/core/lib/surface/channel_init.cc +164 -47
- data/src/core/lib/surface/channel_init.h +64 -1
- data/src/core/lib/surface/filter_stack_call.cc +18 -9
- data/src/core/lib/surface/init.cc +6 -15
- data/src/core/lib/surface/legacy_channel.cc +3 -5
- data/src/core/lib/surface/legacy_channel.h +3 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +110 -0
- data/src/core/lib/transport/promise_endpoint.h +307 -0
- data/src/core/load_balancing/child_policy_handler.cc +2 -4
- data/src/core/load_balancing/delegating_helper.h +2 -3
- data/src/core/load_balancing/health_check_client.cc +1 -5
- data/src/core/load_balancing/lb_policy.h +1 -3
- data/src/core/load_balancing/oob_backend_metric.cc +1 -5
- data/src/core/load_balancing/pick_first/pick_first.cc +3 -0
- data/src/core/load_balancing/xds/cds.cc +10 -1
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
- data/src/core/resolver/xds/xds_config.cc +6 -3
- data/src/core/resolver/xds/xds_config.h +9 -4
- data/src/core/resolver/xds/xds_dependency_manager.cc +21 -6
- data/src/core/resolver/xds/xds_dependency_manager.h +2 -1
- data/src/core/resolver/xds/xds_resolver.cc +31 -11
- data/src/core/server/server.cc +83 -12
- data/src/core/server/server.h +21 -2
- data/src/core/server/xds_server_config_fetcher.cc +63 -25
- data/src/core/service_config/service_config.h +1 -1
- data/src/core/service_config/service_config_impl.h +1 -1
- data/src/core/telemetry/context_list_entry.cc +38 -0
- data/src/core/telemetry/context_list_entry.h +42 -12
- data/src/core/telemetry/stats_data.cc +233 -207
- data/src/core/telemetry/stats_data.h +250 -153
- data/src/core/telemetry/tcp_tracer.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +11 -3
- data/src/core/tsi/fake_transport_security.cc +17 -0
- data/src/core/tsi/ssl_transport_security.cc +2 -0
- data/src/core/tsi/transport_security_grpc.cc +8 -0
- data/src/core/tsi/transport_security_grpc.h +15 -0
- data/src/core/util/backoff.cc +1 -5
- data/src/core/util/backoff.h +1 -0
- data/src/core/util/down_cast.h +1 -1
- data/src/core/util/function_signature.h +15 -1
- data/src/core/util/http_client/httpcli.cc +12 -5
- data/src/core/util/http_client/httpcli.h +4 -1
- data/src/core/util/latent_see.h +8 -5
- data/src/core/util/log.cc +4 -0
- data/src/core/util/memory_usage.h +268 -0
- data/src/core/util/per_cpu.cc +2 -0
- data/src/core/util/per_cpu.h +7 -0
- data/src/core/util/shared_bit_gen.h +20 -0
- data/src/core/util/single_set_ptr.h +2 -2
- data/src/core/util/upb_utils.h +42 -0
- data/src/core/util/uri.cc +3 -2
- data/src/core/util/useful.h +53 -2
- data/src/core/util/wait_for_single_owner.cc +31 -0
- data/src/core/util/wait_for_single_owner.h +24 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.h +5 -0
- data/src/core/xds/grpc/xds_client_grpc.cc +6 -2
- data/src/core/xds/grpc/xds_common_types_parser.cc +138 -50
- data/src/core/xds/grpc/xds_common_types_parser.h +12 -0
- data/src/core/xds/grpc/xds_http_filter.h +7 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +22 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -0
- data/src/core/xds/grpc/xds_route_config_parser.cc +15 -38
- data/src/core/xds/grpc/xds_server_grpc.cc +63 -13
- data/src/core/xds/grpc/xds_server_grpc.h +10 -2
- data/src/core/xds/grpc/xds_server_grpc_interface.h +4 -0
- data/src/core/xds/grpc/xds_transport_grpc.cc +18 -0
- data/src/core/xds/xds_client/xds_bootstrap.h +2 -0
- data/src/core/xds/xds_client/xds_client.cc +26 -5
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_call.c +1 -8
- data/src/ruby/ext/grpc/rb_channel.c +72 -568
- data/src/ruby/ext/grpc/rb_channel.h +0 -3
- data/src/ruby/ext/grpc/rb_completion_queue.c +26 -14
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -7
- data/src/ruby/ext/grpc/rb_grpc.c +9 -5
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/ext/grpc/rb_loader.c +0 -4
- data/src/ruby/ext/grpc/rb_server.c +31 -50
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -4
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/core_spec.rb +22 -0
- data/src/ruby/spec/generic/active_call_spec.rb +1 -1
- data/third_party/abseil-cpp/absl/algorithm/container.h +2 -19
- data/third_party/abseil-cpp/absl/base/attributes.h +76 -7
- data/third_party/abseil-cpp/absl/base/call_once.h +11 -12
- data/third_party/abseil-cpp/absl/base/config.h +20 -129
- data/third_party/abseil-cpp/absl/base/{internal/fast_type_id.h → fast_type_id.h} +11 -16
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +0 -5
- data/third_party/abseil-cpp/absl/base/internal/cycleclock_config.h +7 -7
- data/third_party/abseil-cpp/absl/base/internal/endian.h +34 -38
- data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +71 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +6 -5
- data/third_party/abseil-cpp/absl/base/internal/{nullability_impl.h → nullability_deprecated.h} +45 -8
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +0 -9
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +3 -13
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +6 -6
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +8 -3
- data/third_party/abseil-cpp/absl/base/no_destructor.h +11 -32
- data/third_party/abseil-cpp/absl/base/nullability.h +84 -72
- data/third_party/abseil-cpp/absl/base/options.h +3 -80
- data/third_party/abseil-cpp/absl/base/policy_checks.h +7 -7
- data/third_party/abseil-cpp/absl/cleanup/cleanup.h +1 -3
- data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -4
- data/third_party/abseil-cpp/absl/container/btree_map.h +4 -2
- data/third_party/abseil-cpp/absl/container/btree_set.h +4 -2
- data/third_party/abseil-cpp/absl/container/fixed_array.h +7 -14
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -0
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -1
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +8 -5
- data/third_party/abseil-cpp/absl/container/internal/btree.h +132 -29
- data/third_party/abseil-cpp/absl/container/internal/btree_container.h +175 -71
- data/third_party/abseil-cpp/absl/container/internal/common.h +43 -0
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -2
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +9 -10
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +1 -8
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +0 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +527 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +20 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +31 -12
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +2 -7
- data/third_party/abseil-cpp/absl/container/internal/layout.h +26 -42
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +199 -68
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +1354 -183
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +881 -1424
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +80 -0
- data/third_party/abseil-cpp/absl/crc/crc32c.cc +0 -4
- data/third_party/abseil-cpp/absl/crc/crc32c.h +7 -5
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +0 -22
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +45 -74
- data/third_party/abseil-cpp/absl/debugging/internal/addresses.h +57 -0
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.cc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.h +5 -5
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +8 -35
- data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.cc +16 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +40 -37
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +16 -7
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +14 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +10 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +27 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +13 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +4 -3
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +15 -28
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +144 -27
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +73 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +25 -6
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/flag.h +4 -3
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +7 -6
- data/third_party/abseil-cpp/absl/flags/internal/registry.h +4 -3
- data/third_party/abseil-cpp/absl/flags/reflection.cc +2 -3
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +8 -10
- data/third_party/abseil-cpp/absl/functional/function_ref.h +2 -9
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +110 -226
- data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +10 -12
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -5
- data/third_party/abseil-cpp/absl/hash/hash.h +18 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +1 -5
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -61
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +25 -68
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +2 -6
- data/third_party/abseil-cpp/absl/hash/internal/weakly_mixed_integer.h +38 -0
- data/third_party/abseil-cpp/absl/log/check.h +2 -1
- data/third_party/abseil-cpp/absl/log/globals.h +4 -5
- data/third_party/abseil-cpp/absl/log/internal/append_truncated.h +28 -0
- data/third_party/abseil-cpp/absl/log/internal/check_op.cc +22 -22
- data/third_party/abseil-cpp/absl/log/internal/check_op.h +65 -62
- data/third_party/abseil-cpp/absl/log/internal/conditions.cc +5 -3
- data/third_party/abseil-cpp/absl/log/internal/conditions.h +7 -2
- data/third_party/abseil-cpp/absl/log/internal/log_message.cc +85 -43
- data/third_party/abseil-cpp/absl/log/internal/log_message.h +84 -59
- data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -0
- data/third_party/abseil-cpp/absl/log/internal/proto.cc +3 -2
- data/third_party/abseil-cpp/absl/log/internal/proto.h +3 -3
- data/third_party/abseil-cpp/absl/log/internal/strip.h +4 -12
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +8 -6
- data/third_party/abseil-cpp/absl/log/internal/voidify.h +10 -4
- data/third_party/abseil-cpp/absl/log/log.h +48 -35
- data/third_party/abseil-cpp/absl/log/log_sink_registry.h +2 -2
- data/third_party/abseil-cpp/absl/meta/type_traits.h +46 -175
- data/third_party/abseil-cpp/absl/numeric/bits.h +68 -2
- data/third_party/abseil-cpp/absl/numeric/int128.cc +0 -52
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +7 -3
- data/third_party/abseil-cpp/absl/profiling/internal/exponential_biased.cc +1 -1
- data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +10 -11
- data/third_party/abseil-cpp/absl/random/distributions.h +6 -8
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/{pool_urbg.cc → entropy_pool.cc} +22 -90
- data/third_party/abseil-cpp/absl/random/internal/entropy_pool.h +35 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +1 -1
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +20 -12
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +5 -5
- data/third_party/abseil-cpp/absl/random/random.h +88 -53
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +6 -2
- data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +3 -4
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +3 -4
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -3
- data/third_party/abseil-cpp/absl/status/status.cc +4 -8
- data/third_party/abseil-cpp/absl/status/status.h +8 -8
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.cc +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +6 -6
- data/third_party/abseil-cpp/absl/strings/ascii.cc +9 -9
- data/third_party/abseil-cpp/absl/strings/ascii.h +18 -18
- data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -22
- data/third_party/abseil-cpp/absl/strings/charconv.h +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +54 -58
- data/third_party/abseil-cpp/absl/strings/cord.h +94 -83
- data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +11 -11
- data/third_party/abseil-cpp/absl/strings/cord_analysis.h +3 -3
- data/third_party/abseil-cpp/absl/strings/escaping.cc +130 -149
- data/third_party/abseil-cpp/absl/strings/escaping.h +9 -10
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +6 -8
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +7 -63
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +1 -11
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +0 -22
- data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +5 -3
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +4 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +3 -3
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +0 -5
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +96 -1
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +15 -1
- data/third_party/abseil-cpp/absl/strings/numbers.cc +53 -32
- data/third_party/abseil-cpp/absl/strings/numbers.h +87 -58
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +6 -7
- data/third_party/abseil-cpp/absl/strings/str_cat.h +32 -32
- data/third_party/abseil-cpp/absl/strings/str_format.h +18 -18
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +3 -3
- data/third_party/abseil-cpp/absl/strings/str_replace.h +6 -6
- data/third_party/abseil-cpp/absl/strings/string_view.cc +4 -9
- data/third_party/abseil-cpp/absl/strings/string_view.h +27 -32
- data/third_party/abseil-cpp/absl/strings/strip.h +4 -4
- data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -4
- data/third_party/abseil-cpp/absl/strings/substitute.h +66 -64
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +0 -5
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +97 -69
- data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
- data/third_party/abseil-cpp/absl/time/civil_time.cc +1 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +12 -7
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +90 -111
- data/third_party/abseil-cpp/absl/time/time.h +20 -15
- data/third_party/abseil-cpp/absl/types/optional.h +7 -747
- data/third_party/abseil-cpp/absl/types/span.h +13 -11
- data/third_party/abseil-cpp/absl/types/variant.h +5 -784
- data/third_party/abseil-cpp/absl/utility/utility.h +10 -185
- metadata +72 -20
- data/src/core/lib/event_engine/forkable.cc +0 -105
- data/src/core/lib/event_engine/forkable.h +0 -67
- data/src/core/lib/iomgr/python_util.h +0 -46
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +0 -108
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +0 -241
- data/third_party/abseil-cpp/absl/log/log_entry.cc +0 -41
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +0 -131
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +0 -66
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +0 -78
- data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +0 -82
- data/third_party/abseil-cpp/absl/types/bad_variant_access.h +0 -82
- data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -352
- data/third_party/abseil-cpp/absl/types/internal/variant.h +0 -1622
@@ -0,0 +1,527 @@
|
|
1
|
+
// Copyright 2025 The Abseil Authors
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
//
|
15
|
+
// This file contains the implementation of the hashtable control bytes
|
16
|
+
// manipulation.
|
17
|
+
|
18
|
+
#ifndef ABSL_CONTAINER_INTERNAL_HASHTABLE_CONTROL_BYTES_H_
|
19
|
+
#define ABSL_CONTAINER_INTERNAL_HASHTABLE_CONTROL_BYTES_H_
|
20
|
+
|
21
|
+
#include <cassert>
|
22
|
+
#include <cstddef>
|
23
|
+
#include <cstdint>
|
24
|
+
#include <type_traits>
|
25
|
+
|
26
|
+
#include "absl/base/config.h"
|
27
|
+
|
28
|
+
#ifdef ABSL_INTERNAL_HAVE_SSE2
|
29
|
+
#include <emmintrin.h>
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#ifdef ABSL_INTERNAL_HAVE_SSSE3
|
33
|
+
#include <tmmintrin.h>
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#ifdef _MSC_VER
|
37
|
+
#include <intrin.h>
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#ifdef ABSL_INTERNAL_HAVE_ARM_NEON
|
41
|
+
#include <arm_neon.h>
|
42
|
+
#endif
|
43
|
+
|
44
|
+
#include "absl/base/optimization.h"
|
45
|
+
#include "absl/numeric/bits.h"
|
46
|
+
#include "absl/base/internal/endian.h"
|
47
|
+
|
48
|
+
namespace absl {
|
49
|
+
ABSL_NAMESPACE_BEGIN
|
50
|
+
namespace container_internal {
|
51
|
+
|
52
|
+
#ifdef ABSL_SWISSTABLE_ASSERT
|
53
|
+
#error ABSL_SWISSTABLE_ASSERT cannot be directly set
|
54
|
+
#else
|
55
|
+
// We use this macro for assertions that users may see when the table is in an
|
56
|
+
// invalid state that sanitizers may help diagnose.
|
57
|
+
#define ABSL_SWISSTABLE_ASSERT(CONDITION) \
|
58
|
+
assert((CONDITION) && "Try enabling sanitizers.")
|
59
|
+
#endif
|
60
|
+
|
61
|
+
|
62
|
+
template <typename T>
|
63
|
+
uint32_t TrailingZeros(T x) {
|
64
|
+
ABSL_ASSUME(x != 0);
|
65
|
+
return static_cast<uint32_t>(countr_zero(x));
|
66
|
+
}
|
67
|
+
|
68
|
+
// 8 bytes bitmask with most significant bit set for every byte.
|
69
|
+
constexpr uint64_t kMsbs8Bytes = 0x8080808080808080ULL;
|
70
|
+
// 8 kEmpty bytes that is useful for small table initialization.
|
71
|
+
constexpr uint64_t k8EmptyBytes = kMsbs8Bytes;
|
72
|
+
|
73
|
+
// An abstract bitmask, such as that emitted by a SIMD instruction.
|
74
|
+
//
|
75
|
+
// Specifically, this type implements a simple bitset whose representation is
|
76
|
+
// controlled by `SignificantBits` and `Shift`. `SignificantBits` is the number
|
77
|
+
// of abstract bits in the bitset, while `Shift` is the log-base-two of the
|
78
|
+
// width of an abstract bit in the representation.
|
79
|
+
// This mask provides operations for any number of real bits set in an abstract
|
80
|
+
// bit. To add iteration on top of that, implementation must guarantee no more
|
81
|
+
// than the most significant real bit is set in a set abstract bit.
|
82
|
+
template <class T, int SignificantBits, int Shift = 0>
|
83
|
+
class NonIterableBitMask {
|
84
|
+
public:
|
85
|
+
explicit NonIterableBitMask(T mask) : mask_(mask) {}
|
86
|
+
|
87
|
+
explicit operator bool() const { return this->mask_ != 0; }
|
88
|
+
|
89
|
+
// Returns the index of the lowest *abstract* bit set in `self`.
|
90
|
+
uint32_t LowestBitSet() const {
|
91
|
+
return container_internal::TrailingZeros(mask_) >> Shift;
|
92
|
+
}
|
93
|
+
|
94
|
+
// Returns the index of the highest *abstract* bit set in `self`.
|
95
|
+
uint32_t HighestBitSet() const {
|
96
|
+
return static_cast<uint32_t>((bit_width(mask_) - 1) >> Shift);
|
97
|
+
}
|
98
|
+
|
99
|
+
// Returns the number of trailing zero *abstract* bits.
|
100
|
+
uint32_t TrailingZeros() const {
|
101
|
+
return container_internal::TrailingZeros(mask_) >> Shift;
|
102
|
+
}
|
103
|
+
|
104
|
+
// Returns the number of leading zero *abstract* bits.
|
105
|
+
uint32_t LeadingZeros() const {
|
106
|
+
constexpr int total_significant_bits = SignificantBits << Shift;
|
107
|
+
constexpr int extra_bits = sizeof(T) * 8 - total_significant_bits;
|
108
|
+
return static_cast<uint32_t>(
|
109
|
+
countl_zero(static_cast<T>(mask_ << extra_bits))) >>
|
110
|
+
Shift;
|
111
|
+
}
|
112
|
+
|
113
|
+
T mask_;
|
114
|
+
};
|
115
|
+
|
116
|
+
// Mask that can be iterable
|
117
|
+
//
|
118
|
+
// For example, when `SignificantBits` is 16 and `Shift` is zero, this is just
|
119
|
+
// an ordinary 16-bit bitset occupying the low 16 bits of `mask`. When
|
120
|
+
// `SignificantBits` is 8 and `Shift` is 3, abstract bits are represented as
|
121
|
+
// the bytes `0x00` and `0x80`, and it occupies all 64 bits of the bitmask.
|
122
|
+
// If NullifyBitsOnIteration is true (only allowed for Shift == 3),
|
123
|
+
// non zero abstract bit is allowed to have additional bits
|
124
|
+
// (e.g., `0xff`, `0x83` and `0x9c` are ok, but `0x6f` is not).
|
125
|
+
//
|
126
|
+
// For example:
|
127
|
+
// for (int i : BitMask<uint32_t, 16>(0b101)) -> yields 0, 2
|
128
|
+
// for (int i : BitMask<uint64_t, 8, 3>(0x0000000080800000)) -> yields 2, 3
|
129
|
+
template <class T, int SignificantBits, int Shift = 0,
|
130
|
+
bool NullifyBitsOnIteration = false>
|
131
|
+
class BitMask : public NonIterableBitMask<T, SignificantBits, Shift> {
|
132
|
+
using Base = NonIterableBitMask<T, SignificantBits, Shift>;
|
133
|
+
static_assert(std::is_unsigned<T>::value, "");
|
134
|
+
static_assert(Shift == 0 || Shift == 3, "");
|
135
|
+
static_assert(!NullifyBitsOnIteration || Shift == 3, "");
|
136
|
+
|
137
|
+
public:
|
138
|
+
explicit BitMask(T mask) : Base(mask) {
|
139
|
+
if (Shift == 3 && !NullifyBitsOnIteration) {
|
140
|
+
ABSL_SWISSTABLE_ASSERT(this->mask_ == (this->mask_ & kMsbs8Bytes));
|
141
|
+
}
|
142
|
+
}
|
143
|
+
// BitMask is an iterator over the indices of its abstract bits.
|
144
|
+
using value_type = int;
|
145
|
+
using iterator = BitMask;
|
146
|
+
using const_iterator = BitMask;
|
147
|
+
|
148
|
+
BitMask& operator++() {
|
149
|
+
if (Shift == 3 && NullifyBitsOnIteration) {
|
150
|
+
this->mask_ &= kMsbs8Bytes;
|
151
|
+
}
|
152
|
+
this->mask_ &= (this->mask_ - 1);
|
153
|
+
return *this;
|
154
|
+
}
|
155
|
+
|
156
|
+
uint32_t operator*() const { return Base::LowestBitSet(); }
|
157
|
+
|
158
|
+
BitMask begin() const { return *this; }
|
159
|
+
BitMask end() const { return BitMask(0); }
|
160
|
+
|
161
|
+
private:
|
162
|
+
friend bool operator==(const BitMask& a, const BitMask& b) {
|
163
|
+
return a.mask_ == b.mask_;
|
164
|
+
}
|
165
|
+
friend bool operator!=(const BitMask& a, const BitMask& b) {
|
166
|
+
return a.mask_ != b.mask_;
|
167
|
+
}
|
168
|
+
};
|
169
|
+
|
170
|
+
using h2_t = uint8_t;
|
171
|
+
|
172
|
+
// The values here are selected for maximum performance. See the static asserts
|
173
|
+
// below for details.
|
174
|
+
|
175
|
+
// A `ctrl_t` is a single control byte, which can have one of four
|
176
|
+
// states: empty, deleted, full (which has an associated seven-bit h2_t value)
|
177
|
+
// and the sentinel. They have the following bit patterns:
|
178
|
+
//
|
179
|
+
// empty: 1 0 0 0 0 0 0 0
|
180
|
+
// deleted: 1 1 1 1 1 1 1 0
|
181
|
+
// full: 0 h h h h h h h // h represents the hash bits.
|
182
|
+
// sentinel: 1 1 1 1 1 1 1 1
|
183
|
+
//
|
184
|
+
// These values are specifically tuned for SSE-flavored SIMD.
|
185
|
+
// The static_asserts below detail the source of these choices.
|
186
|
+
//
|
187
|
+
// We use an enum class so that when strict aliasing is enabled, the compiler
|
188
|
+
// knows ctrl_t doesn't alias other types.
|
189
|
+
enum class ctrl_t : int8_t {
|
190
|
+
kEmpty = -128, // 0b10000000
|
191
|
+
kDeleted = -2, // 0b11111110
|
192
|
+
kSentinel = -1, // 0b11111111
|
193
|
+
};
|
194
|
+
static_assert(
|
195
|
+
(static_cast<int8_t>(ctrl_t::kEmpty) &
|
196
|
+
static_cast<int8_t>(ctrl_t::kDeleted) &
|
197
|
+
static_cast<int8_t>(ctrl_t::kSentinel) & 0x80) != 0,
|
198
|
+
"Special markers need to have the MSB to make checking for them efficient");
|
199
|
+
static_assert(
|
200
|
+
ctrl_t::kEmpty < ctrl_t::kSentinel && ctrl_t::kDeleted < ctrl_t::kSentinel,
|
201
|
+
"ctrl_t::kEmpty and ctrl_t::kDeleted must be smaller than "
|
202
|
+
"ctrl_t::kSentinel to make the SIMD test of IsEmptyOrDeleted() efficient");
|
203
|
+
static_assert(
|
204
|
+
ctrl_t::kSentinel == static_cast<ctrl_t>(-1),
|
205
|
+
"ctrl_t::kSentinel must be -1 to elide loading it from memory into SIMD "
|
206
|
+
"registers (pcmpeqd xmm, xmm)");
|
207
|
+
static_assert(ctrl_t::kEmpty == static_cast<ctrl_t>(-128),
|
208
|
+
"ctrl_t::kEmpty must be -128 to make the SIMD check for its "
|
209
|
+
"existence efficient (psignb xmm, xmm)");
|
210
|
+
static_assert(
|
211
|
+
(~static_cast<int8_t>(ctrl_t::kEmpty) &
|
212
|
+
~static_cast<int8_t>(ctrl_t::kDeleted) &
|
213
|
+
static_cast<int8_t>(ctrl_t::kSentinel) & 0x7F) != 0,
|
214
|
+
"ctrl_t::kEmpty and ctrl_t::kDeleted must share an unset bit that is not "
|
215
|
+
"shared by ctrl_t::kSentinel to make the scalar test for "
|
216
|
+
"MaskEmptyOrDeleted() efficient");
|
217
|
+
static_assert(ctrl_t::kDeleted == static_cast<ctrl_t>(-2),
|
218
|
+
"ctrl_t::kDeleted must be -2 to make the implementation of "
|
219
|
+
"ConvertSpecialToEmptyAndFullToDeleted efficient");
|
220
|
+
|
221
|
+
// Helpers for checking the state of a control byte.
|
222
|
+
inline bool IsEmpty(ctrl_t c) { return c == ctrl_t::kEmpty; }
|
223
|
+
inline bool IsFull(ctrl_t c) {
|
224
|
+
// Cast `c` to the underlying type instead of casting `0` to `ctrl_t` as `0`
|
225
|
+
// is not a value in the enum. Both ways are equivalent, but this way makes
|
226
|
+
// linters happier.
|
227
|
+
return static_cast<std::underlying_type_t<ctrl_t>>(c) >= 0;
|
228
|
+
}
|
229
|
+
inline bool IsDeleted(ctrl_t c) { return c == ctrl_t::kDeleted; }
|
230
|
+
inline bool IsEmptyOrDeleted(ctrl_t c) { return c < ctrl_t::kSentinel; }
|
231
|
+
|
232
|
+
#ifdef ABSL_INTERNAL_HAVE_SSE2
|
233
|
+
// Quick reference guide for intrinsics used below:
|
234
|
+
//
|
235
|
+
// * __m128i: An XMM (128-bit) word.
|
236
|
+
//
|
237
|
+
// * _mm_setzero_si128: Returns a zero vector.
|
238
|
+
// * _mm_set1_epi8: Returns a vector with the same i8 in each lane.
|
239
|
+
//
|
240
|
+
// * _mm_subs_epi8: Saturating-subtracts two i8 vectors.
|
241
|
+
// * _mm_and_si128: Ands two i128s together.
|
242
|
+
// * _mm_or_si128: Ors two i128s together.
|
243
|
+
// * _mm_andnot_si128: And-nots two i128s together.
|
244
|
+
//
|
245
|
+
// * _mm_cmpeq_epi8: Component-wise compares two i8 vectors for equality,
|
246
|
+
// filling each lane with 0x00 or 0xff.
|
247
|
+
// * _mm_cmpgt_epi8: Same as above, but using > rather than ==.
|
248
|
+
//
|
249
|
+
// * _mm_loadu_si128: Performs an unaligned load of an i128.
|
250
|
+
// * _mm_storeu_si128: Performs an unaligned store of an i128.
|
251
|
+
//
|
252
|
+
// * _mm_sign_epi8: Retains, negates, or zeroes each i8 lane of the first
|
253
|
+
// argument if the corresponding lane of the second
|
254
|
+
// argument is positive, negative, or zero, respectively.
|
255
|
+
// * _mm_movemask_epi8: Selects the sign bit out of each i8 lane and produces a
|
256
|
+
// bitmask consisting of those bits.
|
257
|
+
// * _mm_shuffle_epi8: Selects i8s from the first argument, using the low
|
258
|
+
// four bits of each i8 lane in the second argument as
|
259
|
+
// indices.
|
260
|
+
|
261
|
+
// https://github.com/abseil/abseil-cpp/issues/209
|
262
|
+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87853
|
263
|
+
// _mm_cmpgt_epi8 is broken under GCC with -funsigned-char
|
264
|
+
// Work around this by using the portable implementation of Group
|
265
|
+
// when using -funsigned-char under GCC.
|
266
|
+
inline __m128i _mm_cmpgt_epi8_fixed(__m128i a, __m128i b) {
|
267
|
+
#if defined(__GNUC__) && !defined(__clang__)
|
268
|
+
if (std::is_unsigned<char>::value) {
|
269
|
+
const __m128i mask = _mm_set1_epi8(0x80);
|
270
|
+
const __m128i diff = _mm_subs_epi8(b, a);
|
271
|
+
return _mm_cmpeq_epi8(_mm_and_si128(diff, mask), mask);
|
272
|
+
}
|
273
|
+
#endif
|
274
|
+
return _mm_cmpgt_epi8(a, b);
|
275
|
+
}
|
276
|
+
|
277
|
+
struct GroupSse2Impl {
|
278
|
+
static constexpr size_t kWidth = 16; // the number of slots per group
|
279
|
+
using BitMaskType = BitMask<uint16_t, kWidth>;
|
280
|
+
using NonIterableBitMaskType = NonIterableBitMask<uint16_t, kWidth>;
|
281
|
+
|
282
|
+
explicit GroupSse2Impl(const ctrl_t* pos) {
|
283
|
+
ctrl = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pos));
|
284
|
+
}
|
285
|
+
|
286
|
+
// Returns a bitmask representing the positions of slots that match hash.
|
287
|
+
BitMaskType Match(h2_t hash) const {
|
288
|
+
auto match = _mm_set1_epi8(static_cast<char>(hash));
|
289
|
+
return BitMaskType(
|
290
|
+
static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
|
291
|
+
}
|
292
|
+
|
293
|
+
// Returns a bitmask representing the positions of empty slots.
|
294
|
+
NonIterableBitMaskType MaskEmpty() const {
|
295
|
+
#ifdef ABSL_INTERNAL_HAVE_SSSE3
|
296
|
+
// This only works because ctrl_t::kEmpty is -128.
|
297
|
+
return NonIterableBitMaskType(
|
298
|
+
static_cast<uint16_t>(_mm_movemask_epi8(_mm_sign_epi8(ctrl, ctrl))));
|
299
|
+
#else
|
300
|
+
auto match = _mm_set1_epi8(static_cast<char>(ctrl_t::kEmpty));
|
301
|
+
return NonIterableBitMaskType(
|
302
|
+
static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
|
303
|
+
#endif
|
304
|
+
}
|
305
|
+
|
306
|
+
// Returns a bitmask representing the positions of full slots.
|
307
|
+
// Note: for `is_small()` tables group may contain the "same" slot twice:
|
308
|
+
// original and mirrored.
|
309
|
+
BitMaskType MaskFull() const {
|
310
|
+
return BitMaskType(static_cast<uint16_t>(_mm_movemask_epi8(ctrl) ^ 0xffff));
|
311
|
+
}
|
312
|
+
|
313
|
+
// Returns a bitmask representing the positions of non full slots.
|
314
|
+
// Note: this includes: kEmpty, kDeleted, kSentinel.
|
315
|
+
// It is useful in contexts when kSentinel is not present.
|
316
|
+
auto MaskNonFull() const {
|
317
|
+
return BitMaskType(static_cast<uint16_t>(_mm_movemask_epi8(ctrl)));
|
318
|
+
}
|
319
|
+
|
320
|
+
// Returns a bitmask representing the positions of empty or deleted slots.
|
321
|
+
NonIterableBitMaskType MaskEmptyOrDeleted() const {
|
322
|
+
auto special = _mm_set1_epi8(static_cast<char>(ctrl_t::kSentinel));
|
323
|
+
return NonIterableBitMaskType(static_cast<uint16_t>(
|
324
|
+
_mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl))));
|
325
|
+
}
|
326
|
+
|
327
|
+
// Returns the number of trailing empty or deleted elements in the group.
|
328
|
+
uint32_t CountLeadingEmptyOrDeleted() const {
|
329
|
+
auto special = _mm_set1_epi8(static_cast<char>(ctrl_t::kSentinel));
|
330
|
+
return TrailingZeros(static_cast<uint32_t>(
|
331
|
+
_mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl)) + 1));
|
332
|
+
}
|
333
|
+
|
334
|
+
void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const {
|
335
|
+
auto msbs = _mm_set1_epi8(static_cast<char>(-128));
|
336
|
+
auto x126 = _mm_set1_epi8(126);
|
337
|
+
#ifdef ABSL_INTERNAL_HAVE_SSSE3
|
338
|
+
auto res = _mm_or_si128(_mm_shuffle_epi8(x126, ctrl), msbs);
|
339
|
+
#else
|
340
|
+
auto zero = _mm_setzero_si128();
|
341
|
+
auto special_mask = _mm_cmpgt_epi8_fixed(zero, ctrl);
|
342
|
+
auto res = _mm_or_si128(msbs, _mm_andnot_si128(special_mask, x126));
|
343
|
+
#endif
|
344
|
+
_mm_storeu_si128(reinterpret_cast<__m128i*>(dst), res);
|
345
|
+
}
|
346
|
+
|
347
|
+
__m128i ctrl;
|
348
|
+
};
|
349
|
+
#endif // ABSL_INTERNAL_RAW_HASH_SET_HAVE_SSE2
|
350
|
+
|
351
|
+
#if defined(ABSL_INTERNAL_HAVE_ARM_NEON) && defined(ABSL_IS_LITTLE_ENDIAN)
|
352
|
+
struct GroupAArch64Impl {
|
353
|
+
static constexpr size_t kWidth = 8;
|
354
|
+
using BitMaskType = BitMask<uint64_t, kWidth, /*Shift=*/3,
|
355
|
+
/*NullifyBitsOnIteration=*/true>;
|
356
|
+
using NonIterableBitMaskType =
|
357
|
+
NonIterableBitMask<uint64_t, kWidth, /*Shift=*/3>;
|
358
|
+
|
359
|
+
explicit GroupAArch64Impl(const ctrl_t* pos) {
|
360
|
+
ctrl = vld1_u8(reinterpret_cast<const uint8_t*>(pos));
|
361
|
+
}
|
362
|
+
|
363
|
+
auto Match(h2_t hash) const {
|
364
|
+
uint8x8_t dup = vdup_n_u8(hash);
|
365
|
+
auto mask = vceq_u8(ctrl, dup);
|
366
|
+
return BitMaskType(vget_lane_u64(vreinterpret_u64_u8(mask), 0));
|
367
|
+
}
|
368
|
+
|
369
|
+
auto MaskEmpty() const {
|
370
|
+
uint64_t mask =
|
371
|
+
vget_lane_u64(vreinterpret_u64_u8(vceq_s8(
|
372
|
+
vdup_n_s8(static_cast<int8_t>(ctrl_t::kEmpty)),
|
373
|
+
vreinterpret_s8_u8(ctrl))),
|
374
|
+
0);
|
375
|
+
return NonIterableBitMaskType(mask);
|
376
|
+
}
|
377
|
+
|
378
|
+
// Returns a bitmask representing the positions of full slots.
|
379
|
+
// Note: for `is_small()` tables group may contain the "same" slot twice:
|
380
|
+
// original and mirrored.
|
381
|
+
auto MaskFull() const {
|
382
|
+
uint64_t mask = vget_lane_u64(
|
383
|
+
vreinterpret_u64_u8(vcge_s8(vreinterpret_s8_u8(ctrl),
|
384
|
+
vdup_n_s8(static_cast<int8_t>(0)))),
|
385
|
+
0);
|
386
|
+
return BitMaskType(mask);
|
387
|
+
}
|
388
|
+
|
389
|
+
// Returns a bitmask representing the positions of non full slots.
|
390
|
+
// Note: this includes: kEmpty, kDeleted, kSentinel.
|
391
|
+
// It is useful in contexts when kSentinel is not present.
|
392
|
+
auto MaskNonFull() const {
|
393
|
+
uint64_t mask = vget_lane_u64(
|
394
|
+
vreinterpret_u64_u8(vclt_s8(vreinterpret_s8_u8(ctrl),
|
395
|
+
vdup_n_s8(static_cast<int8_t>(0)))),
|
396
|
+
0);
|
397
|
+
return BitMaskType(mask);
|
398
|
+
}
|
399
|
+
|
400
|
+
auto MaskEmptyOrDeleted() const {
|
401
|
+
uint64_t mask =
|
402
|
+
vget_lane_u64(vreinterpret_u64_u8(vcgt_s8(
|
403
|
+
vdup_n_s8(static_cast<int8_t>(ctrl_t::kSentinel)),
|
404
|
+
vreinterpret_s8_u8(ctrl))),
|
405
|
+
0);
|
406
|
+
return NonIterableBitMaskType(mask);
|
407
|
+
}
|
408
|
+
|
409
|
+
uint32_t CountLeadingEmptyOrDeleted() const {
|
410
|
+
uint64_t mask =
|
411
|
+
vget_lane_u64(vreinterpret_u64_u8(vcle_s8(
|
412
|
+
vdup_n_s8(static_cast<int8_t>(ctrl_t::kSentinel)),
|
413
|
+
vreinterpret_s8_u8(ctrl))),
|
414
|
+
0);
|
415
|
+
// Similar to MaskEmptyorDeleted() but we invert the logic to invert the
|
416
|
+
// produced bitfield. We then count number of trailing zeros.
|
417
|
+
// Clang and GCC optimize countr_zero to rbit+clz without any check for 0,
|
418
|
+
// so we should be fine.
|
419
|
+
return static_cast<uint32_t>(countr_zero(mask)) >> 3;
|
420
|
+
}
|
421
|
+
|
422
|
+
void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const {
|
423
|
+
uint64_t mask = vget_lane_u64(vreinterpret_u64_u8(ctrl), 0);
|
424
|
+
constexpr uint64_t slsbs = 0x0202020202020202ULL;
|
425
|
+
constexpr uint64_t midbs = 0x7e7e7e7e7e7e7e7eULL;
|
426
|
+
auto x = slsbs & (mask >> 6);
|
427
|
+
auto res = (x + midbs) | kMsbs8Bytes;
|
428
|
+
little_endian::Store64(dst, res);
|
429
|
+
}
|
430
|
+
|
431
|
+
uint8x8_t ctrl;
|
432
|
+
};
|
433
|
+
#endif // ABSL_INTERNAL_HAVE_ARM_NEON && ABSL_IS_LITTLE_ENDIAN
|
434
|
+
|
435
|
+
struct GroupPortableImpl {
|
436
|
+
static constexpr size_t kWidth = 8;
|
437
|
+
using BitMaskType = BitMask<uint64_t, kWidth, /*Shift=*/3,
|
438
|
+
/*NullifyBitsOnIteration=*/false>;
|
439
|
+
using NonIterableBitMaskType =
|
440
|
+
NonIterableBitMask<uint64_t, kWidth, /*Shift=*/3>;
|
441
|
+
|
442
|
+
explicit GroupPortableImpl(const ctrl_t* pos)
|
443
|
+
: ctrl(little_endian::Load64(pos)) {}
|
444
|
+
|
445
|
+
BitMaskType Match(h2_t hash) const {
|
446
|
+
// For the technique, see:
|
447
|
+
// http://graphics.stanford.edu/~seander/bithacks.html##ValueInWord
|
448
|
+
// (Determine if a word has a byte equal to n).
|
449
|
+
//
|
450
|
+
// Caveat: there are false positives but:
|
451
|
+
// - they only occur if there is a real match
|
452
|
+
// - they never occur on ctrl_t::kEmpty, ctrl_t::kDeleted, ctrl_t::kSentinel
|
453
|
+
// - they will be handled gracefully by subsequent checks in code
|
454
|
+
//
|
455
|
+
// Example:
|
456
|
+
// v = 0x1716151413121110
|
457
|
+
// hash = 0x12
|
458
|
+
// retval = (v - lsbs) & ~v & msbs = 0x0000000080800000
|
459
|
+
constexpr uint64_t lsbs = 0x0101010101010101ULL;
|
460
|
+
auto x = ctrl ^ (lsbs * hash);
|
461
|
+
return BitMaskType((x - lsbs) & ~x & kMsbs8Bytes);
|
462
|
+
}
|
463
|
+
|
464
|
+
auto MaskEmpty() const {
|
465
|
+
return NonIterableBitMaskType((ctrl & ~(ctrl << 6)) & kMsbs8Bytes);
|
466
|
+
}
|
467
|
+
|
468
|
+
// Returns a bitmask representing the positions of full slots.
|
469
|
+
// Note: for `is_small()` tables group may contain the "same" slot twice:
|
470
|
+
// original and mirrored.
|
471
|
+
auto MaskFull() const {
|
472
|
+
return BitMaskType((ctrl ^ kMsbs8Bytes) & kMsbs8Bytes);
|
473
|
+
}
|
474
|
+
|
475
|
+
// Returns a bitmask representing the positions of non full slots.
|
476
|
+
// Note: this includes: kEmpty, kDeleted, kSentinel.
|
477
|
+
// It is useful in contexts when kSentinel is not present.
|
478
|
+
auto MaskNonFull() const { return BitMaskType(ctrl & kMsbs8Bytes); }
|
479
|
+
|
480
|
+
auto MaskEmptyOrDeleted() const {
|
481
|
+
return NonIterableBitMaskType((ctrl & ~(ctrl << 7)) & kMsbs8Bytes);
|
482
|
+
}
|
483
|
+
|
484
|
+
uint32_t CountLeadingEmptyOrDeleted() const {
|
485
|
+
// ctrl | ~(ctrl >> 7) will have the lowest bit set to zero for kEmpty and
|
486
|
+
// kDeleted. We lower all other bits and count number of trailing zeros.
|
487
|
+
constexpr uint64_t bits = 0x0101010101010101ULL;
|
488
|
+
return static_cast<uint32_t>(countr_zero((ctrl | ~(ctrl >> 7)) & bits) >>
|
489
|
+
3);
|
490
|
+
}
|
491
|
+
|
492
|
+
void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const {
|
493
|
+
constexpr uint64_t lsbs = 0x0101010101010101ULL;
|
494
|
+
auto x = ctrl & kMsbs8Bytes;
|
495
|
+
auto res = (~x + (x >> 7)) & ~lsbs;
|
496
|
+
little_endian::Store64(dst, res);
|
497
|
+
}
|
498
|
+
|
499
|
+
uint64_t ctrl;
|
500
|
+
};
|
501
|
+
|
502
|
+
#ifdef ABSL_INTERNAL_HAVE_SSE2
|
503
|
+
using Group = GroupSse2Impl;
|
504
|
+
using GroupFullEmptyOrDeleted = GroupSse2Impl;
|
505
|
+
#elif defined(ABSL_INTERNAL_HAVE_ARM_NEON) && defined(ABSL_IS_LITTLE_ENDIAN)
|
506
|
+
using Group = GroupAArch64Impl;
|
507
|
+
// For Aarch64, we use the portable implementation for counting and masking
|
508
|
+
// full, empty or deleted group elements. This is to avoid the latency of moving
|
509
|
+
// between data GPRs and Neon registers when it does not provide a benefit.
|
510
|
+
// Using Neon is profitable when we call Match(), but is not when we don't,
|
511
|
+
// which is the case when we do *EmptyOrDeleted and MaskFull operations.
|
512
|
+
// It is difficult to make a similar approach beneficial on other architectures
|
513
|
+
// such as x86 since they have much lower GPR <-> vector register transfer
|
514
|
+
// latency and 16-wide Groups.
|
515
|
+
using GroupFullEmptyOrDeleted = GroupPortableImpl;
|
516
|
+
#else
|
517
|
+
using Group = GroupPortableImpl;
|
518
|
+
using GroupFullEmptyOrDeleted = GroupPortableImpl;
|
519
|
+
#endif
|
520
|
+
|
521
|
+
} // namespace container_internal
|
522
|
+
ABSL_NAMESPACE_END
|
523
|
+
} // namespace absl
|
524
|
+
|
525
|
+
#undef ABSL_SWISSTABLE_ASSERT
|
526
|
+
|
527
|
+
#endif // ABSL_CONTAINER_INTERNAL_HASHTABLE_CONTROL_BYTES_H_
|
@@ -42,10 +42,6 @@ namespace absl {
|
|
42
42
|
ABSL_NAMESPACE_BEGIN
|
43
43
|
namespace container_internal {
|
44
44
|
|
45
|
-
#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
|
46
|
-
constexpr int HashtablezInfo::kMaxStackDepth;
|
47
|
-
#endif
|
48
|
-
|
49
45
|
namespace {
|
50
46
|
ABSL_CONST_INIT std::atomic<bool> g_hashtablez_enabled{
|
51
47
|
false
|
@@ -126,6 +122,26 @@ static bool ShouldForceSampling() {
|
|
126
122
|
return state == kForce;
|
127
123
|
}
|
128
124
|
|
125
|
+
#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
|
126
|
+
HashtablezInfoHandle ForcedTrySample(size_t inline_element_size,
|
127
|
+
size_t key_size, size_t value_size,
|
128
|
+
uint16_t soo_capacity) {
|
129
|
+
return HashtablezInfoHandle(SampleSlow(global_next_sample,
|
130
|
+
inline_element_size, key_size,
|
131
|
+
value_size, soo_capacity));
|
132
|
+
}
|
133
|
+
void TestOnlyRefreshSamplingStateForCurrentThread() {
|
134
|
+
global_next_sample.next_sample =
|
135
|
+
g_hashtablez_sample_parameter.load(std::memory_order_relaxed);
|
136
|
+
global_next_sample.sample_stride = global_next_sample.next_sample;
|
137
|
+
}
|
138
|
+
#else
|
139
|
+
HashtablezInfoHandle ForcedTrySample(size_t, size_t, size_t, uint16_t) {
|
140
|
+
return HashtablezInfoHandle{nullptr};
|
141
|
+
}
|
142
|
+
void TestOnlyRefreshSamplingStateForCurrentThread() {}
|
143
|
+
#endif // ABSL_INTERNAL_HASHTABLEZ_SAMPLE
|
144
|
+
|
129
145
|
HashtablezInfo* SampleSlow(SamplingState& next_sample,
|
130
146
|
size_t inline_element_size, size_t key_size,
|
131
147
|
size_t value_size, uint16_t soo_capacity) {
|
@@ -219,22 +219,41 @@ class HashtablezInfoHandle {
|
|
219
219
|
extern ABSL_PER_THREAD_TLS_KEYWORD SamplingState global_next_sample;
|
220
220
|
#endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
|
221
221
|
|
222
|
-
// Returns
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
ABSL_ATTRIBUTE_UNUSED uint16_t soo_capacity) {
|
222
|
+
// Returns true if the next table should be sampled.
|
223
|
+
// This function updates the global state.
|
224
|
+
// If the function returns true, actual sampling should be done by calling
|
225
|
+
// ForcedTrySample().
|
226
|
+
inline bool ShouldSampleNextTable() {
|
228
227
|
#if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE)
|
229
228
|
if (ABSL_PREDICT_TRUE(--global_next_sample.next_sample > 0)) {
|
230
|
-
return
|
229
|
+
return false;
|
231
230
|
}
|
232
|
-
return
|
233
|
-
inline_element_size, key_size,
|
234
|
-
value_size, soo_capacity));
|
231
|
+
return true;
|
235
232
|
#else
|
236
|
-
return
|
237
|
-
#endif //
|
233
|
+
return false;
|
234
|
+
#endif // ABSL_INTERNAL_HASHTABLEZ_SAMPLE
|
235
|
+
}
|
236
|
+
|
237
|
+
// Returns a sampling handle.
|
238
|
+
// Must be called only if HashSetShouldBeSampled() returned true.
|
239
|
+
// Returned handle still can be unsampled if sampling is not possible.
|
240
|
+
HashtablezInfoHandle ForcedTrySample(size_t inline_element_size,
|
241
|
+
size_t key_size, size_t value_size,
|
242
|
+
uint16_t soo_capacity);
|
243
|
+
|
244
|
+
// In case sampling needs to be disabled and re-enabled in tests, this function
|
245
|
+
// can be used to reset the sampling state for the current thread.
|
246
|
+
// It is useful to avoid sampling attempts and sampling delays in tests.
|
247
|
+
void TestOnlyRefreshSamplingStateForCurrentThread();
|
248
|
+
|
249
|
+
// Returns a sampling handle.
|
250
|
+
inline HashtablezInfoHandle Sample(size_t inline_element_size, size_t key_size,
|
251
|
+
size_t value_size, uint16_t soo_capacity) {
|
252
|
+
if (ABSL_PREDICT_TRUE(!ShouldSampleNextTable())) {
|
253
|
+
return HashtablezInfoHandle(nullptr);
|
254
|
+
}
|
255
|
+
return ForcedTrySample(inline_element_size, key_size, value_size,
|
256
|
+
soo_capacity);
|
238
257
|
}
|
239
258
|
|
240
259
|
using HashtablezSampler =
|
@@ -73,11 +73,6 @@ using ConstReverseIterator = typename std::reverse_iterator<ConstIterator<A>>;
|
|
73
73
|
template <typename A>
|
74
74
|
using MoveIterator = typename std::move_iterator<Iterator<A>>;
|
75
75
|
|
76
|
-
template <typename Iterator>
|
77
|
-
using IsAtLeastForwardIterator = std::is_convertible<
|
78
|
-
typename std::iterator_traits<Iterator>::iterator_category,
|
79
|
-
std::forward_iterator_tag>;
|
80
|
-
|
81
76
|
template <typename A>
|
82
77
|
using IsMoveAssignOk = std::is_move_assignable<ValueType<A>>;
|
83
78
|
template <typename A>
|
@@ -234,7 +229,7 @@ class AllocationTransaction {
|
|
234
229
|
return result.data;
|
235
230
|
}
|
236
231
|
|
237
|
-
|
232
|
+
[[nodiscard]] Allocation<A> Release() && {
|
238
233
|
Allocation<A> result = {GetData(), GetCapacity()};
|
239
234
|
Reset();
|
240
235
|
return result;
|
@@ -548,7 +543,7 @@ class Storage {
|
|
548
543
|
(std::max)(N, sizeof(Allocated) / sizeof(ValueType<A>));
|
549
544
|
|
550
545
|
struct Inlined {
|
551
|
-
alignas(ValueType<A>) char inlined_data[sizeof(
|
546
|
+
alignas(ValueType<A>) unsigned char inlined_data[sizeof(
|
552
547
|
ValueType<A>[kOptimalInlinedSize])];
|
553
548
|
};
|
554
549
|
|