TANK icon indicating copy to clipboard operation
TANK copied to clipboard

Consider use of multiple threads

Open markpapadakis opened this issue 9 years ago • 7 comments

In practice, this will only benefit latency if we are going to be dealing with a lot of compressed batch message sets, which could keep a thread busy for a long time, blocking it from processing incoming input and scheduling outgoing requests.

It should be fairly trivial to implement this, though we need to be careful about retain/release semantics, and about costs of shared access. We should probably delay this until we absolute need it, so that we 'll be better informed, and have a more evolved codebase.

markpapadakis avatar Jul 05 '16 07:07 markpapadakis

Actually, that's silly. Tank (service) doesn't compress or decompress anything whatsoever (the client does) so the above remarks are mostly irrelevant, and the case for multiple threads is very weak.

markpapadakis avatar Jul 05 '16 09:07 markpapadakis

  • [x] We should actually remove all locks and atomic ops from service.

markpapadakis avatar Jul 05 '16 16:07 markpapadakis

We may actually have to use multiple threads anyway, because both sendfile() and writev() may block. See #14 If we can implement an asynchronous I/O scheme where we won't both for either calls, we can and should stick to the single thread design for simplicity.

markpapadakis avatar Jul 12 '16 09:07 markpapadakis

See https://github.com/phaistos-networks/TANK/issues/14#issuecomment-232483098 for writev() timings. Considering that, and the cost for blocking sendfile() calls, it would make a lot of sense to use threads, eventually.

markpapadakis avatar Jul 14 '16 07:07 markpapadakis

We are talking microseconds here, and I am on the fence about multiple threads. It should be trivial to do this anyway, just think we 'll get some performance drop due to cache coherency semantics and kernel-levels serialisation to FDS and other resources.

markpapadakis avatar Aug 13 '16 05:08 markpapadakis

A forthcoming update (TANK2) will rely on c++20 coroutines and io_uring for disk I/O and other blocking operations.

markpapadakis avatar Nov 07 '19 14:11 markpapadakis

We will use coroutines for each consume request, so that we suspend the coroutine if the await_ready() of the awaitable returned by Service::open_partition_log() returns false.

open_partition_log() is the only function that may block for a "a long time", depending on the structure of the partition, so ti should be very beneficial.

markpapadakis avatar Nov 10 '19 11:11 markpapadakis