mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-22 18:28:39 +01:00
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.
This commit is contained in:
parent
234018d749
commit
bad93c536a
11
src/pipe.cpp
11
src/pipe.cpp
@ -460,14 +460,9 @@ int zmq::pipe_t::compute_lwm (int hwm_)
|
||||
// result in low performance.
|
||||
//
|
||||
// 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,
|
||||
// say HWM-LWM should be max_wm_delta.
|
||||
//
|
||||
// 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;
|
||||
// possible to reduce the thread switching overhead to almost zero.
|
||||
// Let's make LWM 1/2 of HWM.
|
||||
int result = (hwm_ + 1) / 2;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user