Skip to content

Commit

Permalink
thinp: Extend drive immediately on events
Browse files Browse the repository at this point in the history
Expose periodic.dispatch() function allowing immediate dispatching of
calls on the periodic executor. This is useful when you want to handle
libvirt events on the periodic executor.

The first user of this facility is the thinp volume monitor. Now when we
receive a block threshold or enospc events we use the periodic dispatch
to extend the relevant drive immediately. This eliminates the 0-2
seconds wait after receiving an event.

Here are test results from 4 runs, each writing 50 GiB to think disk at
~1300 MiB/s. Each run extends the disk 20 times. The VM was not paused
during the test.

| time        |  min  |  avg  |  max  |
|-------------|-------|-------|-------|
| total       |  0.77 |  1.15 |  1.39 |
| extend      |  0.55 |  0.92 |  1.14 |
| refresh     |  0.16 |  0.22 |  0.31 |
| wait        |  0.01 |  0.01 |  0.03 |

Fixes: #85
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed May 9, 2022
1 parent 78a65ff commit e6f62ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/vdsm/virt/periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ def stop():
_executor.stop(wait=False)


def dispatch(callable, timeout=None, discard=True):
"""
Dispatch callable on the periodic executor.
Should be used when a periodic operation should run as soon as possible
instead of waiting for the next cycle.
Raises:
- vdsm.exception.ResourceExhausted if the executor queue is full
- vdsm.executor.NotRunning if the executor is not running
"""
_executor.dispatch(callable, timeout=timeout, discard=discard)


class Operation(object):
"""
Operation runs a callable with a given period until
Expand Down
3 changes: 2 additions & 1 deletion lib/vdsm/virt/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
from vdsm.virt import libvirtxml
from vdsm.virt import metadata
from vdsm.virt import migration
from vdsm.virt import periodic
from vdsm.virt import sampling
from vdsm.virt import saslpasswd2
from vdsm.virt import thinp
Expand Down Expand Up @@ -437,7 +438,7 @@ def __init__(self, cif, params, recover=False):
self._hotunplugged_devices = {} # { alias: device_object }

self.volume_monitor = thinp.VolumeMonitor(
self, self.log, enabled=False)
self, self.log, dispatch=periodic.dispatch, enabled=False)
self._connection = libvirtconnection.get(cif)
if (recover and
# status retrieved from the recovery file (legacy style)
Expand Down

0 comments on commit e6f62ab

Please sign in to comment.