Commit Graph

20 Commits

Author SHA1 Message Date
AJ Heller 3fb738b9b1
[EventEngine] Implement work-stealing in the EventEngine ThreadPool (#32869)
This PR implements a work-stealing thread pool for use inside
EventEngine implementations. Because of historical risks here, I've
guarded the new implementation behind an experiment flag:
`GRPC_EXPERIMENTS=work_stealing`. Current default behavior is the
original thread pool implementation.

Benchmarks look very promising:

```
bazel test \
--test_timeout=300 \
--config=opt -c opt \
--test_output=streamed \
--test_arg='--benchmark_format=csv' \
--test_arg='--benchmark_min_time=0.15' \
--test_arg='--benchmark_filter=_FanOut' \
--test_arg='--benchmark_repetitions=15' \
--test_arg='--benchmark_report_aggregates_only=true' \
test/cpp/microbenchmarks:bm_thread_pool
```

2023-05-04: `bm_thread_pool` benchmark results on my local machine (64
core ThreadRipper PRO 3995WX, 256GB memory), comparing this PR to
master:


![image](https://user-images.githubusercontent.com/295906/236315252-35ed237e-7626-486c-acfa-71a36f783d22.png)

2023-05-04: `bm_thread_pool` benchmark results in the Linux RBE
environment (unsure of machine configuration, likely small), comparing
this PR to master.


![image](https://user-images.githubusercontent.com/295906/236317164-2c5acbeb-fdac-4737-9b2d-4df9c41cb825.png)

---------

Co-authored-by: drfloob <drfloob@users.noreply.github.com>
2023-05-08 13:38:23 -07:00
AJ Heller 1548038a09
[EventEngine] Windows endpoints keep their EventEngines alive (#32560)
Discovered via `bazel test
--test_env=GRPC_EXPERIMENTS=event_engine_client
//test/core/iomgr:endpoint_pair_test`. CI experiments can be enabled
generally on Windows once a few fixes and improvements are completed.
2023-03-08 08:04:35 -08:00
Vignesh Babu 8fdc82f33d
[EventEngine] Update Endpoint API to return true if read/write succeeds immediately (#32370)
Requires cherrypick
2023-02-23 09:51:21 -08:00
AJ Heller b53f6fde67
Reland "[EventEngine] WindowsEventEngine Endpoint and Socket fixes" (#32440)
Relands #32385 (reverted in #32419) with fixes.

The Windows build is clean on a test cherrypick: cl/511291828

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->

---------

Co-authored-by: drfloob <drfloob@users.noreply.github.com>
2023-02-21 16:00:14 -08:00
Craig Tiller 8d5559d713
Revert "[EventEngine] WindowsEventEngine Endpoint and Socket fixes" (#32419)
Reverts grpc/grpc#32385

Co-authored-by: Yijie Ma <yijiem.main@gmail.com>
2023-02-16 11:36:39 -08:00
AJ Heller a879544a65
[EventEngine] WindowsEventEngine Endpoint and Socket fixes (#32385)
A handful of problems were identified while writing the
WindowsEventEngine Listener. To make the listener review easier, these
fixes can be landed separately.

This is built upon https://github.com/grpc/grpc/pull/32376

Problems that are fixed in this PR:
* `OnConnectCompleted` held a Mutex while calling the user callback,
which can deadlock.
* The WinSocket and some associated data needs to remain alive after the
Endpoint destroyed, since Windows IOCP still needs to use some of that
data. Endpoint destruction and socket shutdown are now decoupled, with
the socket managed by a shared_ptr.

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->

---------

Co-authored-by: drfloob <drfloob@users.noreply.github.com>
2023-02-15 15:58:38 -08:00
AJ Heller b453af1ecf
[EventEngine] Fix IOCP test under load (#32328) 2023-02-08 15:11:53 -08:00
AJ Heller 557e558825
[EventEngine] WindowsEndpoint (#31735)
* [EventEngine] WindowsEndpoint

Initial sketch, all tests passing

* Port fix from #28432

* GPR_WINDOWS guard

* use MemoryAllocator::MakeReservation for allocated buffers

* better logging (respect slice length)

* Automated change: Fix sanity tests

* improvements

* Automated change: Fix sanity tests

* InlinedVector<WSABUF, kMaxWSABUFCount>

* initial attempt at socket util reunification

* posix fixes + local run of sanitize.sh

* posix socket includes

* fix

* Automated change: Fix sanity tests

* remove unused include (breaks windows)

* remove stale comment

Co-authored-by: drfloob <drfloob@users.noreply.github.com>
2022-11-28 14:13:10 -08:00
AJ Heller 0c5a17ce62
Improve Windows network error logging in IOCP test (#31742)
* Improve Windows network error logging in IOCP test

* reviewer feedback
2022-11-22 12:39:15 -08:00
AJ Heller b66829429e
Return unique_ptrs from IOCP::Watch (#31731)
* Return unique_ptrs from IOCP::Work

* Automated change: Fix sanity tests

* fix banned function

Co-authored-by: drfloob <drfloob@users.noreply.github.com>
2022-11-21 15:40:18 -08:00
Yash Tibrewal 5f6c357e74
Move some targets from //: to //src/core: (#31402)
* temp

* temp

* temp

* top BUILD builds

* everything builds

* buildify

* temp fix_build_deps change

* fix gpr_atm

* additional changes

* fix build files

* nofixdeps

* Generate projects

* json_args

* fix context

* Generate projects

* Sprinkle some avoid_dep tags

* Run fix_build_deps

* Remove additional avoid_dep

* Revert some targets

* grpc_mock_cel
2022-10-20 20:12:53 -07:00
Craig Tiller 0a8948ca2a
Add a quiesce to threadpool (#31380)
* Add a quiesce to threadpool

* fix

* Automated change: Fix sanity tests

* fix

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2022-10-18 13:31:54 -07:00
Craig Tiller 2d00d50c59
[event_engine] Improve scaling in threadpool (#31234)
* fixes

* Automated change: Fix sanity tests

* fix

* fix

* fix

* fix

* fixes

* fixes

* fix

* fix-win

* fix iwyu

* fix

* fix

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2022-10-05 00:17:23 -07:00
AJ Heller c0e5e35c7a
Replace EventEngine::Promise with grpc_core::Notification (#31027)
* Replace EventEngine::Promise with grpc_core::Notification

* remove promise.h

* Automated change: Fix sanity tests

* fix windows

* fix iocp

* fix client_test

Co-authored-by: drfloob <drfloob@users.noreply.github.com>
2022-09-21 09:30:23 -07:00
Vignesh Babu 4e7f0e1eac
Update to the event engine poller interface (#30828)
* change poller interface for posix event engine

* update event_poller_posix_test

* windows ee changes

* update comment

* remove unused deps

* review comments

* fix build issue

* fix sanity

* fix build

* Automated change: Fix sanity tests

* review comments

* remove unused dep

* sanity

* fix typo and address review comments

* review comments

* Automated change: Fix sanity tests

* fix typo in comment

Co-authored-by: Vignesh2208 <Vignesh2208@users.noreply.github.com>
2022-09-15 14:04:08 -07:00
Craig Tiller 14c3839749
[event_engine] More robust ee::Promise<> implementation (#30977)
* fix promise

* iocp

* iwyu

* Automated change: Fix sanity tests

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2022-09-14 10:16:28 -07:00
Craig Tiller 266d41d4d6
[fixit] Scale down large tests (#30674)
We have many tests that create 100 threads or more, and mounting evidence that
this is harmful to our CI environment.

When the original code for many of these tests was written we ran our tests
under run_tests, which had explicit handling for tracking the number of threads
each test needed and making sure that we weren't over subscribing the test
runner. Bazel has no such facility (and the facility in run_tests has since
been removed) and so we need to adjust.

This PR adjusts down a single test and is part of a series so that we can
review and roll back easily if required.
2022-08-22 10:15:02 -07:00
AJ Heller c752a6b25e
Reland: Windows IOCP implementation for the WindowsEventEngine (#30480)
Reverts #30466, relanding #30389. Requires a cherrypick.
2022-08-03 15:18:57 -07:00
AJ Heller 9d4e0e17fe
Revert "Windows IOCP implementation for the WindowsEventEngine (#30389)" (#30466)
This reverts commit 52402afdd4.
2022-08-02 12:27:13 -07:00
AJ Heller 52402afdd4
Windows IOCP implementation for the WindowsEventEngine (#30389)
This is a partial fork of the windows iomgr code - specifically the IOCP and Socket pieces - with some improved architecture and encapsulation. And the start of a WindowsEventEngine.

Once this code is used in a gRPC TCP context, I imagine a few issues will shake out. Also, getting sanitizers set up with MSVC will take a bit of work (see a commit referencing abseil and MSVC bugs to hack around).

I forked the IomgrEventEngine's posix poller interfaces in the hope of negotiating compatibility between the platforms, but the interfaces diverged a fair bit, and I'm doubtful we'll be able to use these "pollers" generically in the same TCP code. Reunification might not happen, and that's probably fine, we'll see how similar the TCP code looks once it's fleshed out.

I also extracted the IomgrEventEngine's timer piece into a separate component, usable by both engines.
2022-08-01 17:06:03 -07:00