Page MenuHomeFreeBSD

usr.sbin/gstat: add microsecond precision for disk latency
Needs ReviewPublic

Authored by mizhka on Sep 27 2023, 12:57 PM.

Details

Reviewers
araujo
imp
Summary

In short, gstat shows the disk latency in 0.1 milliseconds, although modern NVMe drives have even lower latency on the order of tens of microseconds. For instance, actual timing of disks is 140us for read and 50us for write, so gstat shows it like "0.1ms" and "0.1ms".

This patch makes gstat to show latency in microseconds if actual latency is less than 1ms.

Test Plan

Use NVMe / SSD disk with good latency and run gstat with flags:

  1. -C
  2. -Cd
  3. without any flags
  4. -d
  5. -Co
  6. -o
  7. -Cdo

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

mizhka created this revision.

gstat -C (CSV mode)

Before patch

timestamp,name,q-depth,total_ops/s,read/s,read-KiB/s,ms/read,write/s,write-KiB/s,ms/write,%busy
2023-09-27 13:16:10.917166035,nda4,0,275,2,19,0.1,273,13071,0.0,1.1
2023-09-27 13:16:10.917166035,nda5,0,276,3,19,0.1,273,13071,0.0,1.1
2023-09-27 13:16:10.917166035,nda6,0,440,4,23,0.1,436,23979,0.0,1.9
2023-09-27 13:16:10.917166035,nda7,0,437,1,4,0.1,436,23979,0.1,2.1
2023-09-27 13:16:10.917166035,nda8,0,259,2,11,0.1,257,15038,0.0,1.2
2023-09-27 13:16:10.917166035,nda9,0,258,1,8,0.1,257,15038,0.0,1.1
2023-09-27 13:16:10.917166035,nda10,0,393,3,30,0.1,390,28558,0.1,1.9
2023-09-27 13:16:10.917166035,nda11,0,393,3,19,0.1,390,28558,0.1,1.9

after patch

timestamp,name,q-depth,total_ops/s,read/s,read-KiB/s,ms/read,write/s,write-KiB/s,ms/write,%busy
2023-09-27 17:03:23.056176622,nda4,0,506,163,4986,0.148,344,14788,0.040,2.3
2023-09-27 17:03:23.056176622,nda5,0,503,159,4946,0.157,345,14788,0.040,2.4
2023-09-27 17:03:23.056176622,nda6,0,595,130,3971,0.148,465,22909,0.045,3.0
2023-09-27 17:03:23.056176622,nda7,0,640,160,4839,0.121,481,22909,0.042,3.0
2023-09-27 17:03:23.056176622,nda8,0,528,150,4649,0.155,379,15434,0.039,2.5
2023-09-27 17:03:23.056176622,nda9,0,573,184,5703,0.122,388,15434,0.039,2.6
2023-09-27 17:03:23.056176622,nda10,0,570,133,4094,0.159,437,17816,0.039,2.8
2023-09-27 17:03:23.056176622,nda11,0,575,140,4344,0.158,435,17816,0.038,2.7

Examples of changes (nda4 line):

  • read: 0.1 -> 0.148
  • write: 0.0 -> 0.040
mizhka retitled this revision from usr.sbin/gstat: add microsecond resolution to usr.sbin/gstat: add microsecond precision for disk latency .Sep 28 2023, 11:22 AM

I will appreciate any review.
If no objectives, I would like to commit this patch.

Seems interesting. No brainer yes(with the one tweak i have) for csv. How is the visual display affected?

usr.sbin/gstat/gstat.c
414

Why not do this all the time? Or at least make the cut off 10ms so you always get at least 3 significant digits?