[event_engine] Introduce a event_engine_poller_for_python experiment#40243
[event_engine] Introduce a event_engine_poller_for_python experiment#40243eugeneo wants to merge 12 commits intogrpc:masterfrom
Conversation
d801812 to
f578b7a
Compare
|
Discussed yesterday: let's split this PR up into (1) a cleanup/code reorganization PR, and (2) the changes required to introduce the experiment. Bundling them together means a rollback of both if there would otherwise only need to be a rollback of one. |
c984ee6 to
8cae4bd
Compare
| PosixError err; | ||
| int connect_errno; | ||
| PosixEventPoller* poller = poller_manager_.Poller(); | ||
| CHECK(poller_manager_.has_value()); |
There was a problem hiding this comment.
This runtime check needed to be added 7 times, which feels like a code smell, and is error-prone if we forget to add it to any function (now or later). I know you're interested in removing PollerManager. If we're going to take this approach of having an optional PollerManager that is checked every time it's used, we need a short finite timeline before these checks are removed. Please add a TODO and explain what's needed before we can remove the need for this to be an optional type / remove the checks / delete the PollerManager.
| OnConnectCallback on_connect, const ResolvedAddress& addr, | ||
| const EndpointConfig& args, MemoryAllocator memory_allocator, | ||
| Duration timeout) { | ||
| CHECK(poller_manager_.has_value()); |
There was a problem hiding this comment.
Won't this crash if the experiment is disabled?
There was a problem hiding this comment.
It is supposed to crash. See CreateEndpointFromUnconnectedFdInternal. I just made it more explicit and sooner.
8cae4bd to
b4d011b
Compare
754c44b to
648631f
Compare
964aec9 to
3a0acf9
Compare
Vignesh2208
left a comment
There was a problem hiding this comment.
Mostly looks good. Left some minor comments
| bool EventEngineExperimentDisabledForPython() { | ||
| #ifdef GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER | ||
| return true; | ||
| return !grpc_core::IsEventEnginePollerForPythonEnabled(); |
There was a problem hiding this comment.
nit: change the comment of this function. It doesn't always return true if GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER is defined.
There was a problem hiding this comment.
Tried using Gemini to improve the comment...
| #ifdef GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER | ||
| bool poller_enabled = grpc_core::IsEventEnginePollerForPythonEnabled(); | ||
| #else // GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER | ||
| bool poller_enabled = true; |
There was a problem hiding this comment.
nit: rename local variable to event_engine_poller_enabled
|
|
||
| void grpc_client_channel_global_init_backup_polling() { | ||
| #ifndef GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER | ||
| #ifdef GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER |
There was a problem hiding this comment.
nit: consider renaming this macro to GRPC_BUILD_FOR_PYTHON to make the intention clear
There was a problem hiding this comment.
Need to discuss with Python team
| #endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING | ||
| } | ||
| AfterForkInChild(); | ||
| } |
There was a problem hiding this comment.
Why is the check on IsEventEngineForkEnabled() removed ?
should there be an else if (poller_ != nullptr) { poller_->HandleForkInChild(); } here if the IsEventEngineForkEnabled() returned false ?
There was a problem hiding this comment.
I added a CHECK.
Fork handlers should not be called if the fork is not enabled
This reverts commit b09b9cd.
|
Looks like this broke Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 592, in run
self._callTestMethod(testMethod)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
method()
File "/Volumes/BuildData/tmpfs/altsrc/github/grpc/workspace_python_macos_opt_native/src/python/grpcio_tests/tests/unit/_reconnect_test.py", line 240, in test_reconnect
self.fail(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 676, in fail
raise self.failureException(msg)
AssertionError: [TEST] Recovery verification failed: didn't receive 3 good calls in sequence. Failed calls: 16 out of 16https://source.cloud.google.com/results/invocations/c1ba0a1f-f81a-48d6-9047-45cc88f09e0b |
…eriment (grpc#40243)" This reverts commit 7949731.
…periment (grpc#40243)" This reverts commit 59e8124.
…rpc#40243) This commit introduces the `event_engine_poller_for_python` experiment, allowing for controlled rollout and testing of the EventEngine's Posix poller specifically within gRPC Python bindings. **Crucially, this change does *not* alter the default behavior for builds where `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` is *not* defined.** In such configurations, the Posix EventEngine poller will continue to be enabled unconditionally, preserving existing functionality. The primary impact of this change is when `GRPC_DO_NOT_INSTANTIATE_POSIX_POLLER` *is* defined (e.g., in gRPC Python's build system). In this scenario, the enablement of the Posix poller transitions from being implicitly disabled to being configurable via the `event_engine_poller_for_python` experiment flag. This enables a controlled, experimental rollout of the EventEngine poller in environments that previously opted out of its direct instantiation. Closes grpc#40243 COPYBARA_INTEGRATE_REVIEW=grpc#40243 from eugeneo:python-no-backup-poller-experiment 17906e6 PiperOrigin-RevId: 804472655
This commit introduces the
event_engine_poller_for_pythonexperiment, allowing for controlled rollout and testing of the EventEngine's Posix poller specifically within gRPC Python bindings.Crucially, this change does not alter the default behavior for builds where
GRPC_DO_NOT_INSTANTIATE_POSIX_POLLERis not defined. In such configurations, the Posix EventEngine poller will continue to be enabled unconditionally, preserving existing functionality.The primary impact of this change is when
GRPC_DO_NOT_INSTANTIATE_POSIX_POLLERis defined (e.g., in gRPC Python's build system). In this scenario, the enablement of the Posix poller transitions from being implicitly disabled to being configurable via theevent_engine_poller_for_pythonexperiment flag. This enables a controlled, experimental rollout of the EventEngine poller in environments that previously opted out of its direct instantiation.