Open glennhickey opened 3 years ago
This happens in mpmap too. I thought maybe it was a quirk of libvgio?
Apparently the option -t
in any mapper caps the number of OpenMP threads, while vg::io::StreamMultiplexer
uses a single std::thread
for writing the output. The multiplexer runs in a loop, polling the buffers for each mapper thread during each iteration. If there is nothing to write, the multiplexer yields at the end of the iteration. If there are free CPU cores available, this is effectively a busy loop, and the multiplexer occupies the entire core regardless of the amount of data it has to write.
Depending on the scheduler, the multiplexer may also effectively run in a busy loop even when there are no free CPU cores available. At least on my local Ubuntu VM with 8 cores, the speed difference between running 7 and 8 Giraffe mapping threads is negligible. It could be be a bit more efficient to have the multiplexer thread sleep with std::condition_variable::wait()
until a mapper thread notifies it.
command
top
is that why it's so fast?