Commit bad93c53 authored by Fedor Sheremetyev's avatar Fedor Sheremetyev

Set LWM to half of HWL.

This reduces chances of race between writer deactivation and activation.

Reader sends activation command to writer when number or messages is
multiple of LWM. In situation with high throughput (millions of messages
per second) and correspondingly large HWM (e.g. 10M) the difference
between HWM needs to be large enough - so that activation command is
received before pipe becomes full.
parent 234018d7
...@@ -460,14 +460,9 @@ int zmq::pipe_t::compute_lwm (int hwm_) ...@@ -460,14 +460,9 @@ int zmq::pipe_t::compute_lwm (int hwm_)
// result in low performance. // result in low performance.
// //
// Given the 3. it would be good to keep HWM and LWM as far apart as // Given the 3. it would be good to keep HWM and LWM as far apart as
// possible to reduce the thread switching overhead to almost zero, // possible to reduce the thread switching overhead to almost zero.
// say HWM-LWM should be max_wm_delta. // Let's make LWM 1/2 of HWM.
// int result = (hwm_ + 1) / 2;
// That done, we still we have to account for the cases where
// HWM < max_wm_delta thus driving LWM to negative numbers.
// Let's make LWM 1/2 of HWM in such cases.
int result = (hwm_ > max_wm_delta * 2) ?
hwm_ - max_wm_delta : (hwm_ + 1) / 2;
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment