sociomantic-tsunami / swarm

Asynchronous client/node framework library
Boost Software License 1.0
14 stars 26 forks source link

Neo connection handler slowdown with high number of scheduler worker fibers #376

Open gavin-norman-sociomantic opened 5 years ago

gavin-norman-sociomantic commented 5 years ago

(Moved to swarm from https://github.com/sociomantic-tsunami/dhtproto/issues/183.)

An application that has been recently converted to use DHT neo Put instead of legacy Put is reportedly performing noticeably worse than before.

Tests with the affected app indicate that the task scheduler's number of worker fibers seems to be the key thing here: it was set high, and if it is reduced to 10 or 20 the time per Put request is greatly reduced. The likely reason is that with too high a number of worker fibers, it is hard to resume the send and receive fibers of the neo swarm client, hence data throughput is greatly reduced.

A simple test that spawns a Task for each request confirms this: the number of worker fibers definitely impacts the speed at which neo requests complete:

This problem is not specific to the DHT or to Put requests, of course, but indicates a general interaction between the connection send/receive fibers in swarm and the scheduler's worker fibers.

In practice, this only has a significant impact in test systems where the number of nodes in the DHT (hence the number of connections and send/receive fibers) is small relative to the number of worker fibers.