Invoking Poller::Work in posix event engine constructor (#31128)

* adding Poller::Work to event engine constructor

* iwyu

* iwyu

* cleanup

* regenerate projects

* fix

* comments

* add experiments flag

* fix

* newline

* newline

* iwyu

* remove some ifdefs

* fix tsan issue in bm_event_engine_run

* Add a quiesce to threadpool

* fix

* Automated change: Fix sanity tests

* disable posix_event_engine_test on windows

Co-authored-by: Craig Tiller <ctiller@google.com>
Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/31407/head
Vignesh Babu 2 years ago committed by GitHub
parent 0d77dd2bbd
commit e8c30b487f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      BUILD
  2. 104
      CMakeLists.txt
  3. 16
      Makefile
  4. 3
      bazel/experiments.bzl
  5. 105
      build_autogenerated.yaml
  6. 8
      config.m4
  7. 8
      config.w32
  8. 24
      gRPC-C++.podspec
  9. 32
      gRPC-Core.podspec
  10. 20
      grpc.gemspec
  11. 16
      grpc.gyp
  12. 20
      package.xml
  13. 4
      src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
  14. 10
      src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h
  15. 14
      src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
  16. 2
      src/core/lib/event_engine/posix_engine/ev_poll_posix.h
  17. 20
      src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
  18. 2
      src/core/lib/event_engine/posix_engine/event_poller_posix_default.h
  19. 13
      src/core/lib/event_engine/posix_engine/posix_endpoint.cc
  20. 12
      src/core/lib/event_engine/posix_engine/posix_endpoint.h
  21. 142
      src/core/lib/event_engine/posix_engine/posix_engine.cc
  22. 85
      src/core/lib/event_engine/posix_engine/posix_engine.h
  23. 4
      src/core/lib/experiments/experiments.cc
  24. 5
      src/core/lib/experiments/experiments.h
  25. 7
      src/core/lib/experiments/experiments.yaml
  26. 8
      src/python/grpcio/grpc_core_dependencies.py
  27. 8
      test/core/event_engine/posix/event_poller_posix_test.cc
  28. 27
      test/core/event_engine/posix/posix_endpoint_test.cc
  29. 20
      test/core/event_engine/posix/posix_engine_test_utils.h
  30. 3
      test/core/event_engine/test_suite/BUILD
  31. 1
      test/cpp/microbenchmarks/BUILD
  32. 21
      test/cpp/microbenchmarks/bm_event_engine_run.cc
  33. 20
      tools/doxygen/Doxyfile.c++.internal
  34. 20
      tools/doxygen/Doxyfile.core.internal
  35. 6
      tools/run_tests/generated/tests.json

@ -2726,6 +2726,7 @@ grpc_cc_library(
external_deps = ["absl/strings"],
deps = [
"gpr",
"iomgr_port",
"posix_event_engine_event_poller",
"posix_event_engine_poller_posix_epoll1",
"posix_event_engine_poller_posix_poll",
@ -2873,12 +2874,17 @@ grpc_cc_library(
],
deps = [
"event_engine_base_hdrs",
"event_engine_poller",
"event_engine_thread_pool",
"event_engine_trace",
"event_engine_utils",
"experiments",
"gpr",
"grpc_trace",
"init_internally",
"iomgr_port",
"posix_event_engine_event_poller",
"posix_event_engine_poller_posix_default",
"posix_event_engine_timer",
"posix_event_engine_timer_manager",
"//src/core:event_engine_common",

104
CMakeLists.txt generated

@ -1070,7 +1070,9 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx posix_endpoint_test)
endif()
add_dependencies(buildtests_cxx posix_event_engine_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx posix_event_engine_test)
endif()
add_dependencies(buildtests_cxx promise_factory_test)
add_dependencies(buildtests_cxx promise_map_test)
add_dependencies(buildtests_cxx promise_test)
@ -2106,10 +2108,18 @@ add_library(grpc
src/core/lib/event_engine/default_event_engine_factory.cc
src/core/lib/event_engine/forkable.cc
src/core/lib/event_engine/memory_allocator.cc
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
src/core/lib/event_engine/posix_engine/internal_errqueue.cc
src/core/lib/event_engine/posix_engine/lockfree_event.cc
src/core/lib/event_engine/posix_engine/posix_engine.cc
src/core/lib/event_engine/posix_engine/timer.cc
src/core/lib/event_engine/posix_engine/timer_heap.cc
src/core/lib/event_engine/posix_engine/timer_manager.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
src/core/lib/event_engine/resolved_address.cc
src/core/lib/event_engine/slice.cc
src/core/lib/event_engine/slice_buffer.cc
@ -2715,10 +2725,18 @@ add_library(grpc_unsecure
src/core/lib/event_engine/default_event_engine_factory.cc
src/core/lib/event_engine/forkable.cc
src/core/lib/event_engine/memory_allocator.cc
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
src/core/lib/event_engine/posix_engine/internal_errqueue.cc
src/core/lib/event_engine/posix_engine/lockfree_event.cc
src/core/lib/event_engine/posix_engine/posix_engine.cc
src/core/lib/event_engine/posix_engine/timer.cc
src/core/lib/event_engine/posix_engine/timer_heap.cc
src/core/lib/event_engine/posix_engine/timer_manager.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
src/core/lib/event_engine/resolved_address.cc
src/core/lib/event_engine/slice.cc
src/core/lib/event_engine/slice_buffer.cc
@ -9482,14 +9500,6 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(event_poller_posix_test
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
src/core/lib/event_engine/posix_engine/internal_errqueue.cc
src/core/lib/event_engine/posix_engine/lockfree_event.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
test/core/event_engine/posix/event_poller_posix_test.cc
test/core/event_engine/posix/posix_engine_test_utils.cc
third_party/googletest/googletest/src/gtest-all.cc
@ -13094,7 +13104,6 @@ endif()
if(gRPC_BUILD_TESTS)
add_executable(lock_free_event_test
src/core/lib/event_engine/posix_engine/lockfree_event.cc
test/core/event_engine/posix/lock_free_event_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
@ -14622,17 +14631,9 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(posix_endpoint_test
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
src/core/lib/event_engine/posix_engine/internal_errqueue.cc
src/core/lib/event_engine/posix_engine/lockfree_event.cc
src/core/lib/event_engine/posix_engine/posix_endpoint.cc
src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc
src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
src/core/lib/gprpp/load_file.cc
src/core/lib/iomgr/socket_mutator.cc
test/core/event_engine/posix/posix_endpoint_test.cc
@ -14673,42 +14674,44 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
endif()
endif()
if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(posix_event_engine_test
test/core/event_engine/test_suite/event_engine_test.cc
test/core/event_engine/test_suite/event_engine_test_utils.cc
test/core/event_engine/test_suite/posix_event_engine_test.cc
test/core/event_engine/test_suite/timer_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
add_executable(posix_event_engine_test
test/core/event_engine/test_suite/event_engine_test.cc
test/core/event_engine/test_suite/event_engine_test_utils.cc
test/core/event_engine/test_suite/posix_event_engine_test.cc
test/core/event_engine/test_suite/timer_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(posix_event_engine_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_include_directories(posix_event_engine_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(posix_event_engine_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
target_link_libraries(posix_event_engine_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
)
endif()
endif()
if(gRPC_BUILD_TESTS)
@ -19128,7 +19131,6 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(traced_buffer_list_test
src/core/lib/event_engine/posix_engine/internal_errqueue.cc
src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
test/core/event_engine/posix/traced_buffer_list_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@ -19668,8 +19670,6 @@ if(gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(wakeup_fd_posix_test
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
test/core/event_engine/posix/wakeup_fd_posix_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc

16
Makefile generated

@ -1394,10 +1394,18 @@ LIBGRPC_SRC = \
src/core/lib/event_engine/default_event_engine_factory.cc \
src/core/lib/event_engine/forkable.cc \
src/core/lib/event_engine/memory_allocator.cc \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc \
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc \
src/core/lib/event_engine/posix_engine/internal_errqueue.cc \
src/core/lib/event_engine/posix_engine/lockfree_event.cc \
src/core/lib/event_engine/posix_engine/posix_engine.cc \
src/core/lib/event_engine/posix_engine/timer.cc \
src/core/lib/event_engine/posix_engine/timer_heap.cc \
src/core/lib/event_engine/posix_engine/timer_manager.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc \
src/core/lib/event_engine/resolved_address.cc \
src/core/lib/event_engine/slice.cc \
src/core/lib/event_engine/slice_buffer.cc \
@ -1866,10 +1874,18 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/event_engine/default_event_engine_factory.cc \
src/core/lib/event_engine/forkable.cc \
src/core/lib/event_engine/memory_allocator.cc \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc \
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc \
src/core/lib/event_engine/posix_engine/internal_errqueue.cc \
src/core/lib/event_engine/posix_engine/lockfree_event.cc \
src/core/lib/event_engine/posix_engine/posix_engine.cc \
src/core/lib/event_engine/posix_engine/timer.cc \
src/core/lib/event_engine/posix_engine/timer_heap.cc \
src/core/lib/event_engine/posix_engine/timer_manager.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc \
src/core/lib/event_engine/resolved_address.cc \
src/core/lib/event_engine/slice.cc \
src/core/lib/event_engine/slice_buffer.cc \

@ -24,6 +24,9 @@ EXPERIMENTS = {
"endpoint_test": [
"tcp_read_chunks",
],
"event_engine_client_test": [
"posix_event_engine_enable_polling",
],
"flow_control_test": [
"tcp_read_chunks",
],

@ -732,16 +732,28 @@ libs:
- src/core/lib/debug/stats_data.h
- src/core/lib/debug/trace.h
- src/core/lib/event_engine/channel_args_endpoint_config.h
- src/core/lib/event_engine/common_closures.h
- src/core/lib/event_engine/default_event_engine.h
- src/core/lib/event_engine/default_event_engine_factory.h
- src/core/lib/event_engine/executor/executor.h
- src/core/lib/event_engine/forkable.h
- src/core/lib/event_engine/handle_containers.h
- src/core/lib/event_engine/poller.h
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h
- src/core/lib/event_engine/posix_engine/ev_poll_posix.h
- src/core/lib/event_engine/posix_engine/event_poller.h
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.h
- src/core/lib/event_engine/posix_engine/internal_errqueue.h
- src/core/lib/event_engine/posix_engine/lockfree_event.h
- src/core/lib/event_engine/posix_engine/posix_engine.h
- src/core/lib/event_engine/posix_engine/posix_engine_closure.h
- src/core/lib/event_engine/posix_engine/timer.h
- src/core/lib/event_engine/posix_engine/timer_heap.h
- src/core/lib/event_engine/posix_engine/timer_manager.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h
- src/core/lib/event_engine/socket_notifier.h
- src/core/lib/event_engine/thread_pool.h
- src/core/lib/event_engine/time_util.h
@ -1452,10 +1464,18 @@ libs:
- src/core/lib/event_engine/default_event_engine_factory.cc
- src/core/lib/event_engine/forkable.cc
- src/core/lib/event_engine/memory_allocator.cc
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
- src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
- src/core/lib/event_engine/posix_engine/internal_errqueue.cc
- src/core/lib/event_engine/posix_engine/lockfree_event.cc
- src/core/lib/event_engine/posix_engine/posix_engine.cc
- src/core/lib/event_engine/posix_engine/timer.cc
- src/core/lib/event_engine/posix_engine/timer_heap.cc
- src/core/lib/event_engine/posix_engine/timer_manager.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
- src/core/lib/event_engine/resolved_address.cc
- src/core/lib/event_engine/slice.cc
- src/core/lib/event_engine/slice_buffer.cc
@ -1935,16 +1955,28 @@ libs:
- src/core/lib/debug/stats_data.h
- src/core/lib/debug/trace.h
- src/core/lib/event_engine/channel_args_endpoint_config.h
- src/core/lib/event_engine/common_closures.h
- src/core/lib/event_engine/default_event_engine.h
- src/core/lib/event_engine/default_event_engine_factory.h
- src/core/lib/event_engine/executor/executor.h
- src/core/lib/event_engine/forkable.h
- src/core/lib/event_engine/handle_containers.h
- src/core/lib/event_engine/poller.h
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h
- src/core/lib/event_engine/posix_engine/ev_poll_posix.h
- src/core/lib/event_engine/posix_engine/event_poller.h
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.h
- src/core/lib/event_engine/posix_engine/internal_errqueue.h
- src/core/lib/event_engine/posix_engine/lockfree_event.h
- src/core/lib/event_engine/posix_engine/posix_engine.h
- src/core/lib/event_engine/posix_engine/posix_engine_closure.h
- src/core/lib/event_engine/posix_engine/timer.h
- src/core/lib/event_engine/posix_engine/timer_heap.h
- src/core/lib/event_engine/posix_engine/timer_manager.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h
- src/core/lib/event_engine/socket_notifier.h
- src/core/lib/event_engine/thread_pool.h
- src/core/lib/event_engine/time_util.h
@ -2295,10 +2327,18 @@ libs:
- src/core/lib/event_engine/default_event_engine_factory.cc
- src/core/lib/event_engine/forkable.cc
- src/core/lib/event_engine/memory_allocator.cc
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
- src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
- src/core/lib/event_engine/posix_engine/internal_errqueue.cc
- src/core/lib/event_engine/posix_engine/lockfree_event.cc
- src/core/lib/event_engine/posix_engine/posix_engine.cc
- src/core/lib/event_engine/posix_engine/timer.cc
- src/core/lib/event_engine/posix_engine/timer_heap.cc
- src/core/lib/event_engine/posix_engine/timer_manager.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
- src/core/lib/event_engine/resolved_address.cc
- src/core/lib/event_engine/slice.cc
- src/core/lib/event_engine/slice_buffer.cc
@ -5742,28 +5782,8 @@ targets:
build: test
language: c++
headers:
- src/core/lib/event_engine/common_closures.h
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h
- src/core/lib/event_engine/posix_engine/ev_poll_posix.h
- src/core/lib/event_engine/posix_engine/event_poller.h
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.h
- src/core/lib/event_engine/posix_engine/internal_errqueue.h
- src/core/lib/event_engine/posix_engine/lockfree_event.h
- src/core/lib/event_engine/posix_engine/posix_engine_closure.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h
- test/core/event_engine/posix/posix_engine_test_utils.h
src:
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
- src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
- src/core/lib/event_engine/posix_engine/internal_errqueue.cc
- src/core/lib/event_engine/posix_engine/lockfree_event.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
- test/core/event_engine/posix/event_poller_posix_test.cc
- test/core/event_engine/posix/posix_engine_test_utils.cc
deps:
@ -7341,7 +7361,6 @@ targets:
build: test
language: c++
headers:
- src/core/lib/event_engine/common_closures.h
- test/core/event_engine/windows/create_sockpair.h
src:
- test/core/event_engine/windows/create_sockpair.cc
@ -7565,12 +7584,8 @@ targets:
gtest: true
build: test
language: c++
headers:
- src/core/lib/event_engine/posix_engine/event_poller.h
- src/core/lib/event_engine/posix_engine/lockfree_event.h
- src/core/lib/event_engine/posix_engine/posix_engine_closure.h
headers: []
src:
- src/core/lib/event_engine/posix_engine/lockfree_event.cc
- test/core/event_engine/posix/lock_free_event_test.cc
deps:
- grpc_test_util
@ -8272,21 +8287,9 @@ targets:
build: test
language: c++
headers:
- src/core/lib/event_engine/common_closures.h
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h
- src/core/lib/event_engine/posix_engine/ev_poll_posix.h
- src/core/lib/event_engine/posix_engine/event_poller.h
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.h
- src/core/lib/event_engine/posix_engine/internal_errqueue.h
- src/core/lib/event_engine/posix_engine/lockfree_event.h
- src/core/lib/event_engine/posix_engine/posix_endpoint.h
- src/core/lib/event_engine/posix_engine/posix_engine_closure.h
- src/core/lib/event_engine/posix_engine/tcp_socket_utils.h
- src/core/lib/event_engine/posix_engine/traced_buffer_list.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h
- src/core/lib/gprpp/load_file.h
- src/core/lib/iomgr/socket_mutator.h
- test/core/event_engine/posix/posix_engine_test_utils.h
@ -8294,17 +8297,9 @@ targets:
- test/core/event_engine/test_suite/event_engine_test_utils.h
- test/core/event_engine/test_suite/oracle_event_engine_posix.h
src:
- src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
- src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
- src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc
- src/core/lib/event_engine/posix_engine/internal_errqueue.cc
- src/core/lib/event_engine/posix_engine/lockfree_event.cc
- src/core/lib/event_engine/posix_engine/posix_endpoint.cc
- src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc
- src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc
- src/core/lib/gprpp/load_file.cc
- src/core/lib/iomgr/socket_mutator.cc
- test/core/event_engine/posix/posix_endpoint_test.cc
@ -8332,6 +8327,10 @@ targets:
- test/core/event_engine/test_suite/timer_test.cc
deps:
- grpc_test_util
platforms:
- linux
- posix
- mac
uses_polling: false
- name: promise_factory_test
gtest: true
@ -10238,8 +10237,7 @@ targets:
gtest: true
build: test
language: c++
headers:
- src/core/lib/event_engine/common_closures.h
headers: []
src:
- test/core/event_engine/posix/timer_manager_test.cc
deps:
@ -10333,10 +10331,8 @@ targets:
build: test
language: c++
headers:
- src/core/lib/event_engine/posix_engine/internal_errqueue.h
- src/core/lib/event_engine/posix_engine/traced_buffer_list.h
src:
- src/core/lib/event_engine/posix_engine/internal_errqueue.cc
- src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
- test/core/event_engine/posix/traced_buffer_list_test.cc
deps:
@ -10596,13 +10592,8 @@ targets:
gtest: true
build: test
language: c++
headers:
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h
- src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h
headers: []
src:
- src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
- src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
- test/core/event_engine/posix/wakeup_fd_posix_test.cc
deps:
- grpc_test_util
@ -10615,7 +10606,6 @@ targets:
build: test
language: c++
headers:
- src/core/lib/event_engine/common_closures.h
- test/core/event_engine/windows/create_sockpair.h
src:
- test/core/event_engine/windows/create_sockpair.cc
@ -10861,7 +10851,6 @@ targets:
build: test
language: c++
headers:
- src/core/lib/event_engine/common_closures.h
- src/core/lib/event_engine/work_queue.h
src:
- src/core/lib/event_engine/work_queue.cc

8
config.m4 generated

@ -476,10 +476,18 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/event_engine/default_event_engine_factory.cc \
src/core/lib/event_engine/forkable.cc \
src/core/lib/event_engine/memory_allocator.cc \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc \
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc \
src/core/lib/event_engine/posix_engine/internal_errqueue.cc \
src/core/lib/event_engine/posix_engine/lockfree_event.cc \
src/core/lib/event_engine/posix_engine/posix_engine.cc \
src/core/lib/event_engine/posix_engine/timer.cc \
src/core/lib/event_engine/posix_engine/timer_heap.cc \
src/core/lib/event_engine/posix_engine/timer_manager.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc \
src/core/lib/event_engine/resolved_address.cc \
src/core/lib/event_engine/slice.cc \
src/core/lib/event_engine/slice_buffer.cc \

8
config.w32 generated

@ -442,10 +442,18 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\event_engine\\default_event_engine_factory.cc " +
"src\\core\\lib\\event_engine\\forkable.cc " +
"src\\core\\lib\\event_engine\\memory_allocator.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\ev_epoll1_linux.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\ev_poll_posix.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\event_poller_posix_default.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\internal_errqueue.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\lockfree_event.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\posix_engine.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\timer.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\timer_heap.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\timer_manager.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\wakeup_fd_eventfd.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\wakeup_fd_pipe.cc " +
"src\\core\\lib\\event_engine\\posix_engine\\wakeup_fd_posix_default.cc " +
"src\\core\\lib\\event_engine\\resolved_address.cc " +
"src\\core\\lib\\event_engine\\slice.cc " +
"src\\core\\lib\\event_engine\\slice_buffer.cc " +

24
gRPC-C++.podspec generated

@ -683,16 +683,28 @@ Pod::Spec.new do |s|
'src/core/lib/debug/stats_data.h',
'src/core/lib/debug/trace.h',
'src/core/lib/event_engine/channel_args_endpoint_config.h',
'src/core/lib/event_engine/common_closures.h',
'src/core/lib/event_engine/default_event_engine.h',
'src/core/lib/event_engine/default_event_engine_factory.h',
'src/core/lib/event_engine/executor/executor.h',
'src/core/lib/event_engine/forkable.h',
'src/core/lib/event_engine/handle_containers.h',
'src/core/lib/event_engine/poller.h',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.h',
'src/core/lib/event_engine/posix_engine/event_poller.h',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h',
'src/core/lib/event_engine/posix_engine/internal_errqueue.h',
'src/core/lib/event_engine/posix_engine/lockfree_event.h',
'src/core/lib/event_engine/posix_engine/posix_engine.h',
'src/core/lib/event_engine/posix_engine/posix_engine_closure.h',
'src/core/lib/event_engine/posix_engine/timer.h',
'src/core/lib/event_engine/posix_engine/timer_heap.h',
'src/core/lib/event_engine/posix_engine/timer_manager.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h',
'src/core/lib/event_engine/socket_notifier.h',
'src/core/lib/event_engine/thread_pool.h',
'src/core/lib/event_engine/time_util.h',
@ -1548,16 +1560,28 @@ Pod::Spec.new do |s|
'src/core/lib/debug/stats_data.h',
'src/core/lib/debug/trace.h',
'src/core/lib/event_engine/channel_args_endpoint_config.h',
'src/core/lib/event_engine/common_closures.h',
'src/core/lib/event_engine/default_event_engine.h',
'src/core/lib/event_engine/default_event_engine_factory.h',
'src/core/lib/event_engine/executor/executor.h',
'src/core/lib/event_engine/forkable.h',
'src/core/lib/event_engine/handle_containers.h',
'src/core/lib/event_engine/poller.h',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.h',
'src/core/lib/event_engine/posix_engine/event_poller.h',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h',
'src/core/lib/event_engine/posix_engine/internal_errqueue.h',
'src/core/lib/event_engine/posix_engine/lockfree_event.h',
'src/core/lib/event_engine/posix_engine/posix_engine.h',
'src/core/lib/event_engine/posix_engine/posix_engine_closure.h',
'src/core/lib/event_engine/posix_engine/timer.h',
'src/core/lib/event_engine/posix_engine/timer_heap.h',
'src/core/lib/event_engine/posix_engine/timer_manager.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h',
'src/core/lib/event_engine/socket_notifier.h',
'src/core/lib/event_engine/thread_pool.h',
'src/core/lib/event_engine/time_util.h',

32
gRPC-Core.podspec generated

@ -1052,6 +1052,7 @@ Pod::Spec.new do |s|
'src/core/lib/debug/trace.h',
'src/core/lib/event_engine/channel_args_endpoint_config.cc',
'src/core/lib/event_engine/channel_args_endpoint_config.h',
'src/core/lib/event_engine/common_closures.h',
'src/core/lib/event_engine/default_event_engine.cc',
'src/core/lib/event_engine/default_event_engine.h',
'src/core/lib/event_engine/default_event_engine_factory.cc',
@ -1062,14 +1063,33 @@ Pod::Spec.new do |s|
'src/core/lib/event_engine/handle_containers.h',
'src/core/lib/event_engine/memory_allocator.cc',
'src/core/lib/event_engine/poller.h',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.cc',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.h',
'src/core/lib/event_engine/posix_engine/event_poller.h',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h',
'src/core/lib/event_engine/posix_engine/internal_errqueue.cc',
'src/core/lib/event_engine/posix_engine/internal_errqueue.h',
'src/core/lib/event_engine/posix_engine/lockfree_event.cc',
'src/core/lib/event_engine/posix_engine/lockfree_event.h',
'src/core/lib/event_engine/posix_engine/posix_engine.cc',
'src/core/lib/event_engine/posix_engine/posix_engine.h',
'src/core/lib/event_engine/posix_engine/posix_engine_closure.h',
'src/core/lib/event_engine/posix_engine/timer.cc',
'src/core/lib/event_engine/posix_engine/timer.h',
'src/core/lib/event_engine/posix_engine/timer_heap.cc',
'src/core/lib/event_engine/posix_engine/timer_heap.h',
'src/core/lib/event_engine/posix_engine/timer_manager.cc',
'src/core/lib/event_engine/posix_engine/timer_manager.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h',
'src/core/lib/event_engine/resolved_address.cc',
'src/core/lib/event_engine/slice.cc',
'src/core/lib/event_engine/slice_buffer.cc',
@ -2178,16 +2198,28 @@ Pod::Spec.new do |s|
'src/core/lib/debug/stats_data.h',
'src/core/lib/debug/trace.h',
'src/core/lib/event_engine/channel_args_endpoint_config.h',
'src/core/lib/event_engine/common_closures.h',
'src/core/lib/event_engine/default_event_engine.h',
'src/core/lib/event_engine/default_event_engine_factory.h',
'src/core/lib/event_engine/executor/executor.h',
'src/core/lib/event_engine/forkable.h',
'src/core/lib/event_engine/handle_containers.h',
'src/core/lib/event_engine/poller.h',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.h',
'src/core/lib/event_engine/posix_engine/event_poller.h',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h',
'src/core/lib/event_engine/posix_engine/internal_errqueue.h',
'src/core/lib/event_engine/posix_engine/lockfree_event.h',
'src/core/lib/event_engine/posix_engine/posix_engine.h',
'src/core/lib/event_engine/posix_engine/posix_engine_closure.h',
'src/core/lib/event_engine/posix_engine/timer.h',
'src/core/lib/event_engine/posix_engine/timer_heap.h',
'src/core/lib/event_engine/posix_engine/timer_manager.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h',
'src/core/lib/event_engine/socket_notifier.h',
'src/core/lib/event_engine/thread_pool.h',
'src/core/lib/event_engine/time_util.h',

20
grpc.gemspec generated

@ -963,6 +963,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/debug/trace.h )
s.files += %w( src/core/lib/event_engine/channel_args_endpoint_config.cc )
s.files += %w( src/core/lib/event_engine/channel_args_endpoint_config.h )
s.files += %w( src/core/lib/event_engine/common_closures.h )
s.files += %w( src/core/lib/event_engine/default_event_engine.cc )
s.files += %w( src/core/lib/event_engine/default_event_engine.h )
s.files += %w( src/core/lib/event_engine/default_event_engine_factory.cc )
@ -973,14 +974,33 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/event_engine/handle_containers.h )
s.files += %w( src/core/lib/event_engine/memory_allocator.cc )
s.files += %w( src/core/lib/event_engine/poller.h )
s.files += %w( src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h )
s.files += %w( src/core/lib/event_engine/posix_engine/ev_poll_posix.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/ev_poll_posix.h )
s.files += %w( src/core/lib/event_engine/posix_engine/event_poller.h )
s.files += %w( src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/event_poller_posix_default.h )
s.files += %w( src/core/lib/event_engine/posix_engine/internal_errqueue.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/internal_errqueue.h )
s.files += %w( src/core/lib/event_engine/posix_engine/lockfree_event.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/lockfree_event.h )
s.files += %w( src/core/lib/event_engine/posix_engine/posix_engine.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/posix_engine.h )
s.files += %w( src/core/lib/event_engine/posix_engine/posix_engine_closure.h )
s.files += %w( src/core/lib/event_engine/posix_engine/timer.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/timer.h )
s.files += %w( src/core/lib/event_engine/posix_engine/timer_heap.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/timer_heap.h )
s.files += %w( src/core/lib/event_engine/posix_engine/timer_manager.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/timer_manager.h )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc )
s.files += %w( src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h )
s.files += %w( src/core/lib/event_engine/resolved_address.cc )
s.files += %w( src/core/lib/event_engine/slice.cc )
s.files += %w( src/core/lib/event_engine/slice_buffer.cc )

16
grpc.gyp generated

@ -808,10 +808,18 @@
'src/core/lib/event_engine/default_event_engine_factory.cc',
'src/core/lib/event_engine/forkable.cc',
'src/core/lib/event_engine/memory_allocator.cc',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.cc',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc',
'src/core/lib/event_engine/posix_engine/internal_errqueue.cc',
'src/core/lib/event_engine/posix_engine/lockfree_event.cc',
'src/core/lib/event_engine/posix_engine/posix_engine.cc',
'src/core/lib/event_engine/posix_engine/timer.cc',
'src/core/lib/event_engine/posix_engine/timer_heap.cc',
'src/core/lib/event_engine/posix_engine/timer_manager.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc',
'src/core/lib/event_engine/resolved_address.cc',
'src/core/lib/event_engine/slice.cc',
'src/core/lib/event_engine/slice_buffer.cc',
@ -1259,10 +1267,18 @@
'src/core/lib/event_engine/default_event_engine_factory.cc',
'src/core/lib/event_engine/forkable.cc',
'src/core/lib/event_engine/memory_allocator.cc',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.cc',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc',
'src/core/lib/event_engine/posix_engine/internal_errqueue.cc',
'src/core/lib/event_engine/posix_engine/lockfree_event.cc',
'src/core/lib/event_engine/posix_engine/posix_engine.cc',
'src/core/lib/event_engine/posix_engine/timer.cc',
'src/core/lib/event_engine/posix_engine/timer_heap.cc',
'src/core/lib/event_engine/posix_engine/timer_manager.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc',
'src/core/lib/event_engine/resolved_address.cc',
'src/core/lib/event_engine/slice.cc',
'src/core/lib/event_engine/slice_buffer.cc',

20
package.xml generated

@ -945,6 +945,7 @@
<file baseinstalldir="/" name="src/core/lib/debug/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/channel_args_endpoint_config.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/channel_args_endpoint_config.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/common_closures.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/default_event_engine.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/default_event_engine.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/default_event_engine_factory.cc" role="src" />
@ -955,14 +956,33 @@
<file baseinstalldir="/" name="src/core/lib/event_engine/handle_containers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/memory_allocator.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/poller.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/ev_poll_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/ev_poll_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/event_poller.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/event_poller_posix_default.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/internal_errqueue.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/internal_errqueue.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/lockfree_event.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/lockfree_event.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/posix_engine.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/posix_engine.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/posix_engine_closure.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/timer.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/timer.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/timer_heap.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/timer_heap.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/timer_manager.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/timer_manager.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/resolved_address.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/slice.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/event_engine/slice_buffer.cc" role="src" />

@ -556,7 +556,7 @@ void Epoll1Poller::Kick() {
GPR_ASSERT(wakeup_fd_->Wakeup().ok());
}
Epoll1Poller* GetEpoll1Poller(Scheduler* scheduler) {
Epoll1Poller* MakeEpoll1Poller(Scheduler* scheduler) {
static bool kEpoll1PollerSupported = InitEpoll1PollerLinux();
if (kEpoll1PollerSupported) {
return new Epoll1Poller(scheduler);
@ -608,7 +608,7 @@ void Epoll1Poller::Kick() { GPR_ASSERT(false && "unimplemented"); }
// If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
// nullptr.
Epoll1Poller* GetEpoll1Poller(Scheduler* /*scheduler*/) { return nullptr; }
Epoll1Poller* MakeEpoll1Poller(Scheduler* /*scheduler*/) { return nullptr; }
} // namespace posix_engine
} // namespace grpc_event_engine

@ -58,7 +58,13 @@ class Epoll1Poller : public PosixEventPoller {
void Kick() override;
Scheduler* GetScheduler() { return scheduler_; }
void Shutdown() override;
bool CanTrackErrors() const override { return KernelSupportsErrqueue(); }
bool CanTrackErrors() const override {
#ifdef GRPC_POSIX_SOCKET_TCP
return KernelSupportsErrqueue();
#else
return false;
#endif
}
~Epoll1Poller() override;
private:
@ -115,7 +121,7 @@ class Epoll1Poller : public PosixEventPoller {
// Return an instance of a epoll1 based poller tied to the specified event
// engine.
Epoll1Poller* GetEpoll1Poller(Scheduler* scheduler);
Epoll1Poller* MakeEpoll1Poller(Scheduler* scheduler);
} // namespace posix_engine
} // namespace grpc_event_engine

@ -706,7 +706,14 @@ Poller::WorkResult PollPoller::Work(
}
mu_.Unlock();
if (!use_phony_poll_ || timeout_ms == 0) {
if (!use_phony_poll_ || timeout_ms == 0 || pfd_count == 1) {
// If use_phony_poll is true and pfd_count == 1, it implies only the
// wakeup_fd is present. Allow the call to get blocked in this case as
// well instead of crashing. This is because the poller::Work is called
// right after an event enging is constructed. Even if phony poll is
// expected to be used, we dont want to check for it until some actual
// event handles are registered. Otherwise the event engine construction
// may crash.
r = poll(pfds, pfd_count, timeout_ms);
} else {
gpr_log(GPR_ERROR,
@ -829,7 +836,7 @@ void PollPoller::Shutdown() {
Unref();
}
PollPoller* GetPollPoller(Scheduler* scheduler, bool use_phony_poll) {
PollPoller* MakePollPoller(Scheduler* scheduler, bool use_phony_poll) {
static bool kPollPollerSupported = InitPollPollerPosix();
if (kPollPollerSupported) {
return new PollPoller(scheduler, use_phony_poll);
@ -871,7 +878,8 @@ void PollPoller::Kick() { GPR_ASSERT(false && "unimplemented"); }
// If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
// nullptr.
PollPoller* GetPollPoller(Scheduler* /*scheduler*/, bool /* use_phony_poll */) {
PollPoller* MakePollPoller(Scheduler* /*scheduler*/,
bool /* use_phony_poll */) {
return nullptr;
}

@ -89,7 +89,7 @@ class PollPoller : public PosixEventPoller {
// It use_phony_poll is true, it implies that the poller is declared
// non-polling and any attempt to schedule a blocking poll will result in a
// crash failure.
PollPoller* GetPollPoller(Scheduler* scheduler, bool use_phony_poll);
PollPoller* MakePollPoller(Scheduler* scheduler, bool use_phony_poll);
} // namespace posix_engine
} // namespace grpc_event_engine

@ -22,12 +22,16 @@
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
#include "src/core/lib/gprpp/global_config.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SOCKET_TCP
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy);
#endif
namespace grpc_event_engine {
namespace posix_engine {
#ifdef GRPC_POSIX_SOCKET_TCP
namespace {
bool PollStrategyMatches(absl::string_view strategy, absl::string_view want) {
@ -36,7 +40,7 @@ bool PollStrategyMatches(absl::string_view strategy, absl::string_view want) {
} // namespace
PosixEventPoller* GetDefaultPoller(Scheduler* scheduler) {
PosixEventPoller* MakeDefaultPoller(Scheduler* scheduler) {
static const char* poll_strategy =
GPR_GLOBAL_CONFIG_GET(grpc_poll_strategy).release();
PosixEventPoller* poller = nullptr;
@ -44,19 +48,27 @@ PosixEventPoller* GetDefaultPoller(Scheduler* scheduler) {
for (auto it = strings.begin(); it != strings.end() && poller == nullptr;
it++) {
if (PollStrategyMatches(*it, "epoll1")) {
poller = GetEpoll1Poller(scheduler);
poller = MakeEpoll1Poller(scheduler);
}
if (poller == nullptr && PollStrategyMatches(*it, "poll")) {
// If epoll1 fails and if poll strategy matches "poll", use Poll poller
poller = GetPollPoller(scheduler, /*use_phony_poll=*/false);
poller = MakePollPoller(scheduler, /*use_phony_poll=*/false);
} else if (poller == nullptr && PollStrategyMatches(*it, "none")) {
// If epoll1 fails and if poll strategy matches "none", use phony poll
// poller.
poller = GetPollPoller(scheduler, /*use_phony_poll=*/true);
poller = MakePollPoller(scheduler, /*use_phony_poll=*/true);
}
}
return poller;
}
#else // GRPC_POSIX_SOCKET_TCP
PosixEventPoller* MakeDefaultPoller(Scheduler* /*scheduler*/) {
return nullptr;
}
#endif // GRPC_POSIX_SOCKET_TCP
} // namespace posix_engine
} // namespace grpc_event_engine

@ -25,7 +25,7 @@ class Scheduler;
// Return an instance of an event poller which is tied to the specified
// scheduler.
PosixEventPoller* GetDefaultPoller(Scheduler* scheduler);
PosixEventPoller* MakeDefaultPoller(Scheduler* scheduler);
} // namespace posix_engine
} // namespace grpc_event_engine

@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <grpc/support/port_platform.h>
#include "src/core/lib/event_engine/posix_engine/posix_endpoint.h"
@ -33,7 +32,6 @@
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/event_engine/memory_request.h>
#include <grpc/event_engine/slice.h>
#include <grpc/event_engine/slice_buffer.h>
@ -92,8 +90,8 @@ namespace posix_engine {
namespace {
using ::grpc_event_engine::experimental::EndpointConfig;
using ::grpc_event_engine::experimental::EventEngine;
using ::grpc_event_engine::experimental::MemoryAllocator;
using ::grpc_event_engine::experimental::Slice;
using ::grpc_event_engine::experimental::SliceBuffer;
@ -1167,6 +1165,7 @@ PosixEndpointImpl ::~PosixEndpointImpl() {
PosixEndpointImpl::PosixEndpointImpl(EventHandle* handle,
PosixEngineClosure* on_done,
std::shared_ptr<EventEngine> engine,
MemoryAllocator&& /*allocator*/,
const PosixTcpOptions& options)
: sock_(PosixSocketWrapper(handle->WrappedFd())),
on_done_(on_done),
@ -1249,10 +1248,11 @@ PosixEndpointImpl::PosixEndpointImpl(EventHandle* handle,
std::unique_ptr<PosixEndpoint> CreatePosixEndpoint(
EventHandle* handle, PosixEngineClosure* on_shutdown,
std::shared_ptr<EventEngine> engine, const EndpointConfig& config) {
std::shared_ptr<EventEngine> engine, MemoryAllocator&& allocator,
const PosixTcpOptions& options) {
GPR_DEBUG_ASSERT(handle != nullptr);
return std::make_unique<PosixEndpoint>(handle, on_shutdown, std::move(engine),
config);
std::move(allocator), options);
}
} // namespace posix_engine
@ -1268,7 +1268,8 @@ using ::grpc_event_engine::experimental::EventEngine;
std::unique_ptr<PosixEndpoint> CreatePosixEndpoint(
EventHandle* /*handle*/, PosixEngineClosure* /*on_shutdown*/,
std::shared_ptr<EventEngine> /*engine*/, const EndpointConfig& /*config*/) {
std::shared_ptr<EventEngine> /*engine*/,
const PosixTcpOptions& /*options*/) {
GPR_ASSERT(false && "Cannot create PosixEndpoint on this platform");
}

@ -32,7 +32,6 @@
#include "absl/meta/type_traits.h"
#include "absl/status/status.h"
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/event_engine/slice_buffer.h>
@ -467,6 +466,7 @@ class PosixEndpointImpl : public grpc_core::RefCounted<PosixEndpointImpl> {
PosixEndpointImpl(
EventHandle* handle, PosixEngineClosure* on_done,
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine,
grpc_event_engine::experimental::MemoryAllocator&& allocator,
const PosixTcpOptions& options);
~PosixEndpointImpl() override;
void Read(
@ -592,9 +592,10 @@ class PosixEndpoint
PosixEndpoint(
EventHandle* handle, PosixEngineClosure* on_shutdown,
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine,
const grpc_event_engine::experimental::EndpointConfig& config)
grpc_event_engine::experimental::MemoryAllocator&& allocator,
const PosixTcpOptions& options)
: impl_(new PosixEndpointImpl(handle, on_shutdown, std::move(engine),
TcpOptionsFromEndpointConfig(config))) {}
std::move(allocator), options)) {}
void Read(
absl::AnyInvocable<void(absl::Status)> on_read,
@ -672,8 +673,9 @@ class PosixEndpoint
// of the EventHandle is transferred to the endpoint.
std::unique_ptr<PosixEndpoint> CreatePosixEndpoint(
EventHandle* handle, PosixEngineClosure* on_shutdown,
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine,
const grpc_event_engine::experimental::EndpointConfig& config);
std::shared_ptr<EventEngine> engine,
grpc_event_engine::experimental::MemoryAllocator&& allocator,
const PosixTcpOptions& options);
} // namespace posix_engine
} // namespace grpc_event_engine

@ -15,23 +15,133 @@
#include "src/core/lib/event_engine/posix_engine/posix_engine.h"
#include <atomic>
#include <chrono>
#include <string>
#include <utility>
#include "absl/container/flat_hash_set.h"
#include "absl/functional/any_invocable.h"
#include "absl/status/status.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/support/log.h>
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/event_engine/poller.h"
#include "src/core/lib/event_engine/posix_engine/timer.h"
#include "src/core/lib/event_engine/trace.h"
#include "src/core/lib/event_engine/utils.h"
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/gprpp/sync.h"
#ifdef GRPC_POSIX_SOCKET_TCP
#include "src/core/lib/event_engine/posix_engine/event_poller_posix_default.h"
#endif // GRPC_POSIX_SOCKET_TCP
using namespace std::chrono_literals;
namespace grpc_event_engine {
namespace experimental {
#ifdef GRPC_POSIX_SOCKET_TCP
using grpc_event_engine::posix_engine::PosixEventPoller;
PosixEnginePollerManager::PosixEnginePollerManager(
std::shared_ptr<ThreadPool> executor)
: poller_(grpc_event_engine::posix_engine::MakeDefaultPoller(this)),
executor_(std::move(executor)) {}
PosixEnginePollerManager::PosixEnginePollerManager(PosixEventPoller* poller)
: poller_(poller),
poller_state_(PollerState::kExternal),
executor_(nullptr) {
GPR_DEBUG_ASSERT(poller_ != nullptr);
}
void PosixEnginePollerManager::Run(
experimental::EventEngine::Closure* closure) {
if (executor_ != nullptr) {
executor_->Run(closure);
}
}
void PosixEnginePollerManager::Run(absl::AnyInvocable<void()> cb) {
if (executor_ != nullptr) {
executor_->Run(std::move(cb));
}
}
void PosixEnginePollerManager::TriggerShutdown() {
// If the poller is external, dont try to shut it down. Otherwise
// set poller state to PollerState::kShuttingDown.
if (poller_state_.exchange(PollerState::kShuttingDown) ==
PollerState::kExternal) {
poller_ = nullptr;
return;
}
poller_->Kick();
}
PosixEnginePollerManager::~PosixEnginePollerManager() {
if (poller_ != nullptr) {
poller_->Shutdown();
}
}
PosixEventEngine::PosixEventEngine(PosixEventPoller* poller)
: executor_(std::make_shared<ThreadPool>()) {
poller_manager_ = std::make_shared<PosixEnginePollerManager>(poller);
}
PosixEventEngine::PosixEventEngine()
: executor_(std::make_shared<ThreadPool>()) {
if (grpc_core::IsPosixEventEngineEnablePollingEnabled()) {
poller_manager_ = std::make_shared<PosixEnginePollerManager>(executor_);
if (poller_manager_->Poller() != nullptr) {
executor_->Run([poller_manager = poller_manager_]() {
PollerWorkInternal(poller_manager);
});
}
}
}
void PosixEventEngine::PollerWorkInternal(
std::shared_ptr<PosixEnginePollerManager> poller_manager) {
// TODO(vigneshbabu): The timeout specified here is arbitrary. For instance,
// this can be improved by setting the timeout to the next expiring timer.
PosixEventPoller* poller = poller_manager->Poller();
ThreadPool* executor = poller_manager->Executor();
auto result = poller->Work(24h, [executor, &poller_manager]() {
executor->Run([poller_manager]() mutable {
PollerWorkInternal(std::move(poller_manager));
});
});
if (result == Poller::WorkResult::kDeadlineExceeded) {
// The event engine is not shutting down but the next asynchronous
// PollerWorkInternal did not get scheduled. Schedule it now.
executor->Run([poller_manager = std::move(poller_manager)]() {
PollerWorkInternal(poller_manager);
});
} else if (result == Poller::WorkResult::kKicked &&
poller_manager->IsShuttingDown()) {
// The Poller Got Kicked and poller_state_ is set to
// PollerState::kShuttingDown. This can currently happen only from the
// EventEngine destructor. Sample the use_count of poller_manager. If the
// sampled use_count is > 1, there is one more instance of Work(...)
// which hasn't returned yet. Send another Kick to be safe to ensure the
// pending instance of Work(..) also breaks out. Its possible that the other
// instance of Work(..) had already broken out before this Kick is sent. In
// that case, the Kick is spurious but it shouldn't cause any side effects.
if (poller_manager.use_count() > 1) {
poller->Kick();
}
}
}
#endif // GRPC_POSIX_SOCKET_TCP
struct PosixEventEngine::ClosureData final : public EventEngine::Closure {
absl::AnyInvocable<void()> cb;
posix_engine::Timer timer;
@ -51,17 +161,25 @@ struct PosixEventEngine::ClosureData final : public EventEngine::Closure {
};
PosixEventEngine::~PosixEventEngine() {
grpc_core::MutexLock lock(&mu_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_event_engine_trace)) {
for (auto handle : known_handles_) {
gpr_log(GPR_ERROR,
"(event_engine) PosixEventEngine:%p uncleared TaskHandle at "
"shutdown:%s",
this, HandleToString(handle).c_str());
{
grpc_core::MutexLock lock(&mu_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_event_engine_trace)) {
for (auto handle : known_handles_) {
gpr_log(GPR_ERROR,
"(event_engine) PosixEventEngine:%p uncleared "
"TaskHandle at "
"shutdown:%s",
this, HandleToString(handle).c_str());
}
}
GPR_ASSERT(GPR_LIKELY(known_handles_.empty()));
}
#ifdef GRPC_POSIX_SOCKET_TCP
if (poller_manager_ != nullptr) {
poller_manager_->TriggerShutdown();
}
GPR_ASSERT(GPR_LIKELY(known_handles_.empty()));
executor_.Quiesce();
#endif // GRPC_POSIX_SOCKET_TCP
executor_->Quiesce();
}
bool PosixEventEngine::Cancel(EventEngine::TaskHandle handle) {
@ -85,11 +203,11 @@ EventEngine::TaskHandle PosixEventEngine::RunAfter(
}
void PosixEventEngine::Run(absl::AnyInvocable<void()> closure) {
executor_.Run(std::move(closure));
executor_->Run(std::move(closure));
}
void PosixEventEngine::Run(EventEngine::Closure* closure) {
executor_.Run(closure);
executor_->Run(closure);
}
EventEngine::TaskHandle PosixEventEngine::RunAfterInternal(
@ -125,7 +243,7 @@ bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle /*handle*/) {
EventEngine::ConnectionHandle PosixEventEngine::Connect(
OnConnectCallback /*on_connect*/, const ResolvedAddress& /*addr*/,
const EndpointConfig& /*args*/, MemoryAllocator /*memory_allocator*/,
Duration /*deadline*/) {
Duration /*timeout*/) {
GPR_ASSERT(false && "unimplemented");
}

@ -29,17 +29,52 @@
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/event_engine/slice_buffer.h>
#include "src/core/lib/event_engine/handle_containers.h"
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
#include "src/core/lib/event_engine/posix_engine/timer_manager.h"
#include "src/core/lib/event_engine/thread_pool.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/surface/init_internally.h"
namespace grpc_event_engine {
namespace experimental {
#ifdef GRPC_POSIX_SOCKET_TCP
// A helper class to manager lifetime of the poller associated with the
// posix event engine.
class PosixEnginePollerManager
: public grpc_event_engine::posix_engine::Scheduler {
public:
explicit PosixEnginePollerManager(std::shared_ptr<ThreadPool> executor);
explicit PosixEnginePollerManager(
grpc_event_engine::posix_engine::PosixEventPoller* poller);
grpc_event_engine::posix_engine::PosixEventPoller* Poller() {
return poller_;
}
ThreadPool* Executor() { return executor_.get(); }
void Run(experimental::EventEngine::Closure* closure) override;
void Run(absl::AnyInvocable<void()>) override;
bool IsShuttingDown() {
return poller_state_.load(std::memory_order_acquire) ==
PollerState::kShuttingDown;
}
void TriggerShutdown();
~PosixEnginePollerManager() override;
private:
enum class PollerState { kExternal, kOk, kShuttingDown };
grpc_event_engine::posix_engine::PosixEventPoller* poller_ = nullptr;
std::atomic<PollerState> poller_state_{PollerState::kOk};
std::shared_ptr<ThreadPool> executor_;
};
#endif // GRPC_POSIX_SOCKET_TCP
// An iomgr-based Posix EventEngine implementation.
// All methods require an ExecCtx to already exist on the thread's stack.
// TODO(ctiller): KeepsGrpcInitialized is an interim measure to ensure that
@ -47,22 +82,6 @@ namespace experimental {
class PosixEventEngine final : public EventEngine,
public grpc_core::KeepsGrpcInitialized {
public:
class PosixEndpoint : public EventEngine::Endpoint {
public:
~PosixEndpoint() override;
void Read(absl::AnyInvocable<void(absl::Status)> on_read,
SliceBuffer* buffer, const ReadArgs* args) override;
void Write(absl::AnyInvocable<void(absl::Status)> on_writable,
SliceBuffer* data, const WriteArgs* args) override;
const ResolvedAddress& GetPeerAddress() const override;
const ResolvedAddress& GetLocalAddress() const override;
};
class PosixListener : public EventEngine::Listener {
public:
~PosixListener() override;
absl::StatusOr<int> Bind(const ResolvedAddress& addr) override;
absl::Status Start() override;
};
class PosixDNSResolver : public EventEngine::DNSResolver {
public:
~PosixDNSResolver() override;
@ -79,7 +98,17 @@ class PosixEventEngine final : public EventEngine,
bool CancelLookup(LookupTaskHandle handle) override;
};
#ifdef GRPC_POSIX_SOCKET_TCP
// Constructs an event engine which does not own the poller. Do not call this
// constructor directly. Instead use the MakeTestOnlyPosixEventEngine static
// method. Its expected to be used only in tests.
explicit PosixEventEngine(
grpc_event_engine::posix_engine::PosixEventPoller* poller);
PosixEventEngine();
#else // GRPC_POSIX_SOCKET_TCP
PosixEventEngine() = default;
#endif // GRPC_POSIX_SOCKET_TCP
~PosixEventEngine() override;
absl::StatusOr<std::unique_ptr<Listener>> CreateListener(
@ -106,16 +135,36 @@ class PosixEventEngine final : public EventEngine,
absl::AnyInvocable<void()> closure) override;
bool Cancel(TaskHandle handle) override;
#ifdef GRPC_POSIX_SOCKET_TCP
// The posix event engine returned by this method would not own the poller
// and would not be in-charge of driving the poller by calling its Work(..)
// method. Instead its upto the test to drive the poller. The returned posix
// event engine will also not attempt to shutdown the poller since it does not
// own it.
static std::shared_ptr<PosixEventEngine> MakeTestOnlyPosixEventEngine(
grpc_event_engine::posix_engine::PosixEventPoller* test_only_poller) {
return std::make_shared<PosixEventEngine>(test_only_poller);
}
#endif // GRPC_POSIX_SOCKET_TCP
private:
struct ClosureData;
EventEngine::TaskHandle RunAfterInternal(Duration when,
absl::AnyInvocable<void()> cb);
#ifdef GRPC_POSIX_SOCKET_TCP
static void PollerWorkInternal(
std::shared_ptr<PosixEnginePollerManager> poller_manager);
#endif // GRPC_POSIX_SOCKET_TCP
grpc_core::Mutex mu_;
TaskHandleSet known_handles_ ABSL_GUARDED_BY(mu_);
std::atomic<intptr_t> aba_token_{0};
posix_engine::TimerManager timer_manager_;
ThreadPool executor_;
std::shared_ptr<ThreadPool> executor_;
#ifdef GRPC_POSIX_SOCKET_TCP
std::shared_ptr<PosixEnginePollerManager> poller_manager_;
#endif // GRPC_POSIX_SOCKET_TCP
};
} // namespace experimental

@ -51,6 +51,8 @@ const char* const description_monitoring_experiment =
const char* const description_promise_based_client_call =
"If set, use the new gRPC promise based call code when it's appropriate "
"(ie when all filters in a stack are promise based)";
const char* const description_posix_event_engine_enable_polling =
"If set, enables polling on the default posix event engine.";
#ifdef NDEBUG
const bool kDefaultForDebugOnly = false;
#else
@ -77,6 +79,8 @@ const ExperimentMetadata g_experiment_metadata[] = {
{"event_engine_client", description_event_engine_client, false},
{"monitoring_experiment", description_monitoring_experiment, true},
{"promise_based_client_call", description_promise_based_client_call, false},
{"posix_event_engine_enable_polling",
description_posix_event_engine_enable_polling, kDefaultForDebugOnly},
};
} // namespace grpc_core

@ -45,6 +45,9 @@ inline bool IsMonitoringExperimentEnabled() { return IsExperimentEnabled(10); }
inline bool IsPromiseBasedClientCallEnabled() {
return IsExperimentEnabled(11);
}
inline bool IsPosixEventEngineEnablePollingEnabled() {
return IsExperimentEnabled(12);
}
struct ExperimentMetadata {
const char* name;
@ -52,7 +55,7 @@ struct ExperimentMetadata {
bool default_value;
};
constexpr const size_t kNumExperiments = 12;
constexpr const size_t kNumExperiments = 13;
extern const ExperimentMetadata g_experiment_metadata[kNumExperiments];
} // namespace grpc_core

@ -127,3 +127,10 @@
expiry: 2023/01/01
owner: ctiller@google.com
test_tags: ["core_end2end_test", "lame_client_test"]
- name: posix_event_engine_enable_polling
description:
If set, enables polling on the default posix event engine.
default: debug
expiry: 2023/01/01
owner: vigneshbabu@google.com
test_tags: ["event_engine_client_test"]

@ -451,10 +451,18 @@ CORE_SOURCE_FILES = [
'src/core/lib/event_engine/default_event_engine_factory.cc',
'src/core/lib/event_engine/forkable.cc',
'src/core/lib/event_engine/memory_allocator.cc',
'src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc',
'src/core/lib/event_engine/posix_engine/ev_poll_posix.cc',
'src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc',
'src/core/lib/event_engine/posix_engine/internal_errqueue.cc',
'src/core/lib/event_engine/posix_engine/lockfree_event.cc',
'src/core/lib/event_engine/posix_engine/posix_engine.cc',
'src/core/lib/event_engine/posix_engine/timer.cc',
'src/core/lib/event_engine/posix_engine/timer_heap.cc',
'src/core/lib/event_engine/posix_engine/timer_manager.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc',
'src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc',
'src/core/lib/event_engine/resolved_address.cc',
'src/core/lib/event_engine/slice.cc',
'src/core/lib/event_engine/slice_buffer.cc',

@ -69,6 +69,7 @@
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy);
using ::grpc_event_engine::experimental::PosixEventEngine;
using ::grpc_event_engine::posix_engine::PosixEventPoller;
static gpr_mu g_mu;
@ -387,7 +388,10 @@ class EventPollerTest : public ::testing::Test {
std::make_unique<grpc_event_engine::posix_engine::TestScheduler>(
engine_.get());
EXPECT_NE(scheduler_, nullptr);
g_event_poller = GetDefaultPoller(scheduler_.get());
g_event_poller = MakeDefaultPoller(scheduler_.get());
engine_ = PosixEventEngine::MakeTestOnlyPosixEventEngine(g_event_poller);
EXPECT_NE(engine_, nullptr);
scheduler_->ChangeCurrentEventEngine(engine_.get());
if (g_event_poller != nullptr) {
gpr_log(GPR_INFO, "Using poller: %s", g_event_poller->Name().c_str());
}
@ -403,7 +407,7 @@ class EventPollerTest : public ::testing::Test {
TestScheduler* Scheduler() { return scheduler_.get(); }
private:
std::unique_ptr<grpc_event_engine::experimental::PosixEventEngine> engine_;
std::shared_ptr<grpc_event_engine::experimental::PosixEventEngine> engine_;
std::unique_ptr<grpc_event_engine::posix_engine::TestScheduler> scheduler_;
};

@ -126,15 +126,20 @@ std::list<Connection> CreateConnectedEndpoints(
server_signal->WaitForNotification();
EXPECT_NE(server_endpoint, nullptr);
++g_num_active_connections;
PosixTcpOptions options = TcpOptionsFromEndpointConfig(config);
connections.push_back(Connection{
CreatePosixEndpoint(handle,
PosixEngineClosure::TestOnlyToClosure(
[&poller](absl::Status /*status*/) {
if (--g_num_active_connections == 0) {
poller.Kick();
}
}),
posix_ee, config),
CreatePosixEndpoint(
handle,
PosixEngineClosure::TestOnlyToClosure(
[&poller](absl::Status /*status*/) {
if (--g_num_active_connections == 0) {
poller.Kick();
}
}),
posix_ee,
options.resource_quota->memory_quota()->CreateMemoryAllocator(
"test"),
options),
std::move(server_endpoint)});
delete server_signal;
server_signal = new grpc_core::Notification();
@ -196,12 +201,14 @@ class Worker : public grpc_core::DualRefCounted<Worker> {
class PosixEndpointTest : public ::testing::TestWithParam<bool> {
void SetUp() override {
oracle_ee_ = std::make_shared<PosixOracleEventEngine>();
posix_ee_ = std::make_shared<PosixEventEngine>();
scheduler_ =
std::make_unique<grpc_event_engine::posix_engine::TestScheduler>(
posix_ee_.get());
EXPECT_NE(scheduler_, nullptr);
poller_ = GetDefaultPoller(scheduler_.get());
poller_ = MakeDefaultPoller(scheduler_.get());
posix_ee_ = PosixEventEngine::MakeTestOnlyPosixEventEngine(poller_);
EXPECT_NE(posix_ee_, nullptr);
scheduler_->ChangeCurrentEventEngine(posix_ee_.get());
if (poller_ != nullptr) {
gpr_log(GPR_INFO, "Using poller: %s", poller_->Name().c_str());
}

@ -27,13 +27,25 @@ class TestScheduler : public Scheduler {
public:
explicit TestScheduler(grpc_event_engine::experimental::EventEngine* engine)
: engine_(engine) {}
void Run(
grpc_event_engine::experimental::EventEngine::Closure* closure) override {
engine_->Run(closure);
TestScheduler() : engine_(nullptr){};
void ChangeCurrentEventEngine(
grpc_event_engine::experimental::EventEngine* engine) {
engine_ = engine;
}
void Run(experimental::EventEngine::Closure* closure) override {
if (engine_ != nullptr) {
engine_->Run(closure);
} else {
closure->Run();
}
}
void Run(absl::AnyInvocable<void()> cb) override {
engine_->Run(std::move(cb));
if (engine_ != nullptr) {
engine_->Run(std::move(cb));
} else {
cb();
}
}
private:

@ -77,6 +77,9 @@ grpc_cc_library(
grpc_cc_test(
name = "posix_event_engine_test",
srcs = ["posix_event_engine_test.cc"],
tags = [
"no_windows",
],
uses_polling = False,
deps = [
"//:posix_event_engine",

@ -60,6 +60,7 @@ grpc_cc_test(
srcs = ["bm_event_engine_run.cc"],
args = ["--benchmark_min_time=0.1"],
external_deps = [
"absl/debugging:leak_check",
"benchmark",
],
tags = [

@ -15,9 +15,13 @@
#include <atomic>
#include <cmath>
#include <memory>
#include <vector>
#include <benchmark/benchmark.h>
#include "absl/debugging/leak_check.h"
#include "absl/functional/any_invocable.h"
#include <grpc/event_engine/event_engine.h>
#include <grpcpp/impl/grpc_library.h>
@ -95,15 +99,20 @@ void BM_EventEngine_RunClosure(benchmark::State& state) {
int cb_count = state.range(0);
grpc_core::Notification* signal = new grpc_core::Notification();
std::atomic_int count{0};
AnyInvocableClosure closure([signal_holder = &signal, cb_count, &count]() {
if (++count == cb_count) {
(*signal_holder)->Notify();
}
});
// Ignore leaks from this closure. For simplicty, this closure is not deleted
// because the closure may still be executing after the event engine is
// destroyed. This is because the default posix event engine's thread pool may
// get destroyed separately from the event engine.
AnyInvocableClosure* closure = absl::IgnoreLeak(
new AnyInvocableClosure([signal_holder = &signal, cb_count, &count]() {
if (++count == cb_count) {
(*signal_holder)->Notify();
}
}));
auto engine = GetDefaultEventEngine();
for (auto _ : state) {
for (int i = 0; i < cb_count; i++) {
engine->Run(&closure);
engine->Run(closure);
}
signal->WaitForNotification();
state.PauseTiming();

@ -1948,6 +1948,7 @@ src/core/lib/debug/trace.cc \
src/core/lib/debug/trace.h \
src/core/lib/event_engine/channel_args_endpoint_config.cc \
src/core/lib/event_engine/channel_args_endpoint_config.h \
src/core/lib/event_engine/common_closures.h \
src/core/lib/event_engine/default_event_engine.cc \
src/core/lib/event_engine/default_event_engine.h \
src/core/lib/event_engine/default_event_engine_factory.cc \
@ -1958,14 +1959,33 @@ src/core/lib/event_engine/forkable.h \
src/core/lib/event_engine/handle_containers.h \
src/core/lib/event_engine/memory_allocator.cc \
src/core/lib/event_engine/poller.h \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h \
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc \
src/core/lib/event_engine/posix_engine/ev_poll_posix.h \
src/core/lib/event_engine/posix_engine/event_poller.h \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.h \
src/core/lib/event_engine/posix_engine/internal_errqueue.cc \
src/core/lib/event_engine/posix_engine/internal_errqueue.h \
src/core/lib/event_engine/posix_engine/lockfree_event.cc \
src/core/lib/event_engine/posix_engine/lockfree_event.h \
src/core/lib/event_engine/posix_engine/posix_engine.cc \
src/core/lib/event_engine/posix_engine/posix_engine.h \
src/core/lib/event_engine/posix_engine/posix_engine_closure.h \
src/core/lib/event_engine/posix_engine/timer.cc \
src/core/lib/event_engine/posix_engine/timer.h \
src/core/lib/event_engine/posix_engine/timer_heap.cc \
src/core/lib/event_engine/posix_engine/timer_heap.h \
src/core/lib/event_engine/posix_engine/timer_manager.cc \
src/core/lib/event_engine/posix_engine/timer_manager.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h \
src/core/lib/event_engine/resolved_address.cc \
src/core/lib/event_engine/slice.cc \
src/core/lib/event_engine/slice_buffer.cc \

@ -1736,6 +1736,7 @@ src/core/lib/debug/trace.cc \
src/core/lib/debug/trace.h \
src/core/lib/event_engine/channel_args_endpoint_config.cc \
src/core/lib/event_engine/channel_args_endpoint_config.h \
src/core/lib/event_engine/common_closures.h \
src/core/lib/event_engine/default_event_engine.cc \
src/core/lib/event_engine/default_event_engine.h \
src/core/lib/event_engine/default_event_engine_factory.cc \
@ -1746,14 +1747,33 @@ src/core/lib/event_engine/forkable.h \
src/core/lib/event_engine/handle_containers.h \
src/core/lib/event_engine/memory_allocator.cc \
src/core/lib/event_engine/poller.h \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc \
src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h \
src/core/lib/event_engine/posix_engine/ev_poll_posix.cc \
src/core/lib/event_engine/posix_engine/ev_poll_posix.h \
src/core/lib/event_engine/posix_engine/event_poller.h \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc \
src/core/lib/event_engine/posix_engine/event_poller_posix_default.h \
src/core/lib/event_engine/posix_engine/internal_errqueue.cc \
src/core/lib/event_engine/posix_engine/internal_errqueue.h \
src/core/lib/event_engine/posix_engine/lockfree_event.cc \
src/core/lib/event_engine/posix_engine/lockfree_event.h \
src/core/lib/event_engine/posix_engine/posix_engine.cc \
src/core/lib/event_engine/posix_engine/posix_engine.h \
src/core/lib/event_engine/posix_engine/posix_engine_closure.h \
src/core/lib/event_engine/posix_engine/timer.cc \
src/core/lib/event_engine/posix_engine/timer.h \
src/core/lib/event_engine/posix_engine/timer_heap.cc \
src/core/lib/event_engine/posix_engine/timer_heap.h \
src/core/lib/event_engine/posix_engine/timer_manager.cc \
src/core/lib/event_engine/posix_engine/timer_manager.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc \
src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h \
src/core/lib/event_engine/resolved_address.cc \
src/core/lib/event_engine/slice.cc \
src/core/lib/event_engine/slice_buffer.cc \

@ -5315,8 +5315,7 @@
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
@ -5328,8 +5327,7 @@
"platforms": [
"linux",
"mac",
"posix",
"windows"
"posix"
],
"uses_polling": false
},

Loading…
Cancel
Save