Bug 1286278 - dmstats: improve statistics interval estimation
dmstats: improve statistics interval estimation
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2 (Show other bugs)
7.2
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Bryn M. Reeves
cluster-qe@redhat.com
: FutureFeature
Depends On:
Blocks: 1385242
  Show dependency treegraph
 
Reported: 2015-11-27 12:51 EST by Bryn M. Reeves
Modified: 2017-11-01 20:03 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Bryn M. Reeves 2015-11-27 12:51:40 EST
Description of problem:
Currently a single estimate of the sample interval duration (updated when the cycle timer expires) is used as an approximation for all monitored statistics regions.

This is reasonable when the time spent obtaining data is small compared to the overall interval but in the case of large numbers of regions this becomes increasingly inaccurate.

Since each dm ioctl call can now optionally obtain a timestamp this can be used to obtain a more accurate per-region estimate of the actual interval duration:

commit 559ca8bc6593a9ef0b0b012ff0933b80f5d3e367
Author: Alasdair G Kergon <agk@redhat.com>
Date:   Wed Aug 5 08:28:35 2015 +0100

    dmsetup: Report timestamps of ioctls with -vvv.
    
    If enabled, record timestamp immediately after the ioctl() returns.

Version-Release number of selected component (if applicable):
lvm2-2.02.127-*.el7.x86_64

How reproducible:
100%

Steps to Reproduce: ** requires debug build **
1. dmstats create --alldevices
2. dmstats report --count 3 -vvv 2>&1 | grep Interval

Actual results:
Using timerfd for interval timekeeping.
Setting interval timer to: 1s 0ns
Beginning first interval
Interval     #1        time delta:   1000000000ns
Interval     #1       current err:            0ns
End interval #1          duration:   1000000000ns
Adjusted sample interval duration:   1000000000ns
Interval     #1        time delta:       151923ns
Adjusted sample interval duration:   1000000000ns
Interval     #1        time delta:       275569ns
Adjusted sample interval duration:   1000000000ns
Interval     #1        time delta:       417345ns
Adjusted sample interval duration:   1000000000ns
Interval     #1        time delta:       561245ns
Adjusted sample interval duration:   1000000000ns
Interval     #1        time delta:       684515ns
Adjusted sample interval duration:   1000000000ns
Interval     #1        time delta:       799198ns
Adjusted sample interval duration:   1000000000ns
Interval     #2        time delta:    999890331ns
Interval     #2       current err:      -109669ns
End interval #2          duration:    999890331ns
Adjusted sample interval duration:    999890331ns
Adjusted sample interval duration:    999890331ns
Adjusted sample interval duration:    999890331ns
Adjusted sample interval duration:    999890331ns
Adjusted sample interval duration:    999890331ns
Adjusted sample interval duration:    999890331ns
Adjusted sample interval duration:    999890331ns


Expected results:
* "Adjusted sample interval duration" messages should show a unique interval per region.

* A message indicating e.g. "Using per-region sample interval estimates" will also be added when the new feature is in use.

Additional info:
Comment 7 Jonathan Earl Brassow 2017-07-27 16:21:45 EDT
Bryn, is this bug already taken care of?

commit 886b4f755d7f33194f92dafbf2c22517db4de374
Author: Bryn M. Reeves <bmr@redhat.com>
Date:   Sun Dec 18 12:39:26 2016 +0000

    dmstats: use better interval estimate for usleep() timer

    Although the usleep() interval timer is not used if the Linux
    TIMERFD interface is available it should still provide reasonably
    good timing.

    Instead of trying to estimate the error from the duration of the
    last sleep, peg it to the start time of the program, and use the
    value of  ((start_time - now) % interval) to correct the current
    interval duration.

    This always pulls us back into sync at the end of each interval,
    rather than relying on trying to incrementally adjust the time
    duration at each interval start.

    This greatly reduces drift when the usleep() clock is used.
Comment 8 Bryn M. Reeves 2017-07-28 12:45:05 EDT
Not entirely - the patch in comment #7 improves the estimate accuracy for systems that do not support the TIMERFD interface (both RHEL and Fedora have this support already: it gives better control of interval drift and more reliable interval estimates than the sleep timer).

Currently though, both TIMERFD and usleep() when used by dmsetup/dmstats maintain a single interval duration estimate for all regions. This is simple to implement, and reasonable for fairly small numbers of regions (into the 100s).

The next step, which this bug seeks to address, is to use an individual (per-region) estimate: this greatly improves accuracy when scaling to very large numbers of regions (since at this point the time spent in each region's populate ioctl becomes significant).

The downside is that there is considerable extra bookkeeping for per-region timestamps. The plan is to hide this inside the library so that programs monitoring a number of regions simultaneously can have the library fill out interval estimates automatically.

I'm hoping to get to this upstream in the next 3-4 months assuming other priorities don't change in the meantime.

Note You need to log in before you can comment on or make changes to this bug.