vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Event loop thread affinity

Open franz1981 opened this issue 3 years ago • 1 comments

Allow users to define Netty event loop threads cores affinity.

Given that Vert-x use long-living threads bound to specific selectors, being able to bind it to a specific core can increase performance (and its stability) of both I/O and non I/O tasks because of a reduced amount of context-switches and a better usage of cache, given that the event loop data won't "migrate" across cores (and caches) anymore.

This feature, thanks to the symmetric nature of event loop threads, could be implemented by allowing users to specify at startup a preference set of cores and the application will take care to "distribute" such cores to the existing event loop threads. A similar strategy as been used on hazelcast/hazelcast@a7e7def#diff-41c605cf06cabcb23d4cf7c2b39333741976c154934d6de8d9e1d724670310a

A good candidate for a POC implementation is https://github.com/OpenHFT/Java-Thread-Affinity, while a final version can use an ad-hoc JNA affinity util a-la hazelcast/hazelcast#17435 to save "OpenHFT lib to be on the classpath and libffi.so to be loadable too" as mentioned in the HZC PR.

franz1981 avatar Jun 14 '21 08:06 franz1981

I think we should check what hooks are required to make this possible in Vert.x and this would be a small plugin for vertx

vietj avatar Jun 14 '21 12:06 vietj

I think this one should be a nice addons on, Akka has Thread Affinity too.

He-Pin avatar Dec 23 '22 06:12 He-Pin