Skip to content

Commit

Permalink
abstract: reduced increased CPU consumption
Browse files Browse the repository at this point in the history
Due to the fact that queue_state_fiber called box.ctrl.wait_r*
every millisecond, the idle queue consumed more than 10% of CPU.

The proposed solution makes calls to box.ctrl.wait_r* blocking
until the read/write mode is changed. As a result, in idle mode,
the queue_state_faber is in the suspended state, while the main
fiber (for example, interactive in interactive-mode) is in the
running state.
Thus, CPU consumption is reduced to about ~1%.

More detailed measurements are described in [1].

1. #192

Closes #183
  • Loading branch information
GRISHNOV authored and LeonidVas committed Oct 26, 2022
1 parent 462d2ba commit df94d6d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions queue/abstract/queue_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ local function create_state_fiber(on_state_change_cb)
fiber.self():name('queue_state_fiber')
while true do
if current == queue_state.states.WAITING then
local rc = pcall(box.ctl.wait_rw, 0.001)
local rc = pcall(box.ctl.wait_rw)
if rc then
current = queue_state.states.STARTUP
log.info('Queue state changed: STARTUP')
Expand All @@ -76,7 +76,7 @@ local function create_state_fiber(on_state_change_cb)
log.info('Queue state changed: RUNNING')
end
elseif current == queue_state.states.RUNNING then
local rc = pcall(box.ctl.wait_ro, 0.001)
local rc = pcall(box.ctl.wait_ro)
if rc then
current = queue_state.states.ENDING
on_state_change_cb(current)
Expand Down

0 comments on commit df94d6d

Please sign in to comment.