zeroc-ice / ice

All-in-one solution for creating networked applications with RPC, pub/sub, server deployment, and more.
https://zeroc.com
GNU General Public License v2.0
2k stars 592 forks source link

Back pressure fix for 3.7 #2270

Closed bentoi closed 2 weeks ago

bentoi commented 1 month ago

Here's a proposal for fixing back pressure on 3.7. The connection/thread pool implementation is now very close to the C++/IOCP implementation. The main difference is that IO operations are now started on the .NET thread pool to ensure it won't be interrupted if the thread exits. I'm undecided on whether or not it's a good idea to commit this large fix. We can use it for 3.8 however.

bentoi commented 3 weeks ago

As I understand it:

  • we read (and write?) from a .NET threal pool thread with Task.Run() in startAsync

Reads and writes are started on the .NET thread pool and when completed, their completion callbacks are also executed on the .NET thread pool.

  • upon completion, we queue a work item in the Ice thread pool

Right.

But then, how do we ensure we read only when the Ice thread pool is not exhausted? Is it because startAsync is called by the work item we queued?

If upon read completion the Ice thread pool is exhausted, the Ice thread pool queued work item won't execute until there's a free thread. So reads and writes won't progress.

bentoi commented 3 weeks ago

I've push additional fixes and add C++/Java tests.