mratsim / weave

A state-of-the-art multithreading runtime: message-passing based, fast, scalable, ultra-low overhead
Other
541 stars 21 forks source link

Mpsc channel v3 #146

Closed mratsim closed 4 years ago

mratsim commented 4 years ago

A rewrite of the core MPSC channel with the following benefits:

This is the revival of the v1 channels that didn't support batching, but with a State Machine twist: https://github.com/mratsim/weave/blob/b796d1a0efb15cad68e2b06ddaa305b08cf5f722/weave/channels/channels_mpsc_unbounded.nim

Trying to add batching support to the tryRecv proc was incredibly hard and ultimately failed due to the moving dummy and the non-trivial control flow, hence the v2 design with a fixed dummy node in front.

Pure queue benchmarks are inconclusive, the v3 seems to be slightly better for single task dequeue but is slower for batch dequeue :/.

image

Impact on actual workload to be measured

mratsim commented 4 years ago

10% overhead measured on fib(40), no impact on matmul.

Unless somehow the deadlock/livelock that happens regularly in CI don't happen, stashing this failed experiment