mon: Do not truncate per-OSD iops before summing them #224

Merged
vitalif merged 1 commits from koolkhel/vitastor:mon-iops-precision into master 2026-12-04 00:18:52 +03:00
Contributor

Description

When an image's I/O is spread over many OSDs and each OSD serves less than 1 op/s of it, vitastor-cli ls -l, vitastor-cli df -l and vitastor-cli status show 0 iops and 0 latency for it. Under more load they show too little, losing up to 1 op/s per OSD. For example, one image read at 40 op/s over 48 OSDs shows 11–17 iops; at 3 op/s it shows 0. Bytes per second are right.

Cause: derive_osd_stats() divides each OSD's op count by that OSD's report interval in BigInt integer arithmetic (mon/stats.js:20,29,38,55 on master 027ef85d). sum_op_stats() (mon/stats.js:76-108) and sum_inode_stats() (mon/stats.js:280-309) then add up the already truncated rates, and their latency average is weighted by them. An OSD reports every etcd_stats_interval (30 s by default), so an OSD that served 29 ops of an image in that window adds 0. Summing rates rather than counters is right, because OSDs report at different moments, so the summing stays as it is.

Fix: keep per-OSD iops in 1/1000 op/s and round each sum up once. The iops-weighted latency becomes right as well. /stats and /inode/stats keep their format (integers).

What changes for readers of these stats:

  • iops are rounded up, so any I/O shows as at least 1 op/s, and a value can exceed the true rate by less than 1 op/s.
  • A reader that takes non-zero iops as "the image is in use" now sees light I/O that it used to miss.

Overlap: #190 changes the counter parts of the same two functions, sum_op_stats() and sum_inode_stats(); this PR changes only the rate parts. The two PRs do not depend on each other. Whichever is merged second needs a small rebase.

Found: seen on a cluster, where an image's iops in ls -l showed 14–17 while fio read it at 40 op/s over 48 OSDs. The cause was found by reading the code and reproduced by feeding the same layout to sum_op_stats() and sum_inode_stats().

Tested: node mon/test-stats-iops.js (new; fails on master with 0n == 39n), node mon/test-sticky-primaries.js.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description When an image's I/O is spread over many OSDs and each OSD serves less than 1 op/s of it, `vitastor-cli ls -l`, `vitastor-cli df -l` and `vitastor-cli status` show 0 iops and 0 latency for it. Under more load they show too little, losing up to 1 op/s per OSD. For example, one image read at 40 op/s over 48 OSDs shows 11–17 iops; at 3 op/s it shows 0. Bytes per second are right. Cause: `derive_osd_stats()` divides each OSD's op count by that OSD's report interval in BigInt integer arithmetic (`mon/stats.js:20,29,38,55` on master 027ef85d). `sum_op_stats()` (`mon/stats.js:76-108`) and `sum_inode_stats()` (`mon/stats.js:280-309`) then add up the already truncated rates, and their latency average is weighted by them. An OSD reports every `etcd_stats_interval` (30 s by default), so an OSD that served 29 ops of an image in that window adds 0. Summing rates rather than counters is right, because OSDs report at different moments, so the summing stays as it is. Fix: keep per-OSD iops in 1/1000 op/s and round each sum up once. The iops-weighted latency becomes right as well. `/stats` and `/inode/stats` keep their format (integers). What changes for readers of these stats: - iops are rounded up, so any I/O shows as at least 1 op/s, and a value can exceed the true rate by less than 1 op/s. - A reader that takes non-zero iops as "the image is in use" now sees light I/O that it used to miss. Overlap: #190 changes the counter parts of the same two functions, `sum_op_stats()` and `sum_inode_stats()`; this PR changes only the rate parts. The two PRs do not depend on each other. Whichever is merged second needs a small rebase. Found: seen on a cluster, where an image's iops in `ls -l` showed 14–17 while fio read it at 40 op/s over 48 OSDs. The cause was found by reading the code and reproduced by feeding the same layout to `sum_op_stats()` and `sum_inode_stats()`. Tested: `node mon/test-stats-iops.js` (new; fails on master with `0n == 39n`), `node mon/test-sticky-primaries.js`. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-12-03 10:02:58 +03:00
derive_osd_stats() divided every OSD's op count by its report interval
in integer arithmetic, and sum_op_stats() and sum_inode_stats() added up
the truncated rates. An OSD reports every etcd_stats_interval (30 s by
default), so an OSD serving less than 1 op/s of an image added nothing:
an image spread over many OSDs lost up to 1 op/s per OSD and showed 0
iops and 0 latency under light load. Total client iops lost the same.

Keep per-OSD iops in 1/1000 op/s and round each sum up once, so that any
I/O shows as at least 1 op/s. The format of /stats and /inode/stats does
not change.
vitalif merged commit def62d401d into master 2026-12-04 00:18:52 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#224
No description provided.