#2160·gopsutil

[disk][windows]: IOCounters ReadTime and WriteTime look like seconds, not milliseconds

Author: LudwigJMarxCreated Sep 24, 2026Updated Sep 27, 2026

Describe the bug

On Windows, IOCountersWithContext converts DISK_PERFORMANCE.ReadTime and WriteTime like this (disk_windows.go L349-L350):

go
ReadTime:   uint64(dPerformance.ReadTime / 10000 / 1000), // convert to ms: https://github.com/giampaolo/psutil/issues/1012
WriteTime:  uint64(dPerformance.WriteTime / 10000 / 1000),

This divides by 10^7. If the raw values are in 100 ns units, the result is in seconds. The comment says milliseconds, and the Linux, macOS and FreeBSD code returns milliseconds.

The Microsoft documentation of DISK_PERFORMANCE gives no unit for ReadTime and WriteTime. The only public implementation I found is the diskperf filter driver sample from the WDK 7.1 (storage/filters/diskperf/diskperf.c). It measures each request with KeQueryPerformanceCounter. The IOCTL_DISK_PERFORMANCE handler then converts the sum with DiskPerfAddCounters:

c
TotalCounters->ReadTime.QuadPart +=
    NewCounters->ReadTime.QuadPart * 10000000 / Frequency.QuadPart;

That is 100 ns units. Without a performance counter frequency, the sample uses KeQuerySystemTime, which also counts in 100 ns units. The sample is not the in-box driver, so this is evidence for the unit and not a proof.

To Reproduce

I have no Windows host, so I did not run gopsutil on Windows. The numbers in psutil#1012 are a plausibility check. At that time psutil computed raw * 10 / 1000, and the report shows read_time=1987935564 for read_count=4196177. So the raw value was about 1.99e11.

Divisor ReadTime Time per read
10^4 (100 ns to ms) 19,879,356 ms 4.7 ms
10^7 (current code) 19,879 4.7 µs if read as ms

4.7 ms per read fits a hard disk in 2017. With the current code, a disk that is busy for 50 ms per second makes ReadTime go up by 1 only every 20 s.

Expected behavior

ReadTime and WriteTime in milliseconds, as on the other platforms. With 100 ns units, that is a division by 10^4.

Environment

  • Windows: no Windows host available. The finding comes from the source code at 3588a7738f3d and the documents above.

Additional context

psutil divides by 10^7 too (psutil/arch/windows/disk.c, with the same link to #1012). So the reference in the comment does not settle the unit. In the #1012 thread, one report compares the value with the perfmon counter "Avg. Disk sec/Read". That counter is seconds per operation, and ReadTime is a cumulative time, so the two do not measure the same thing.

A measurement on Windows could settle it: read ReadTime twice, 10 s apart, while one process reads from the disk all the time. The increase should then be close to 10,000 ms for one outstanding request. I can send a PR for the division if someone confirms the unit on Windows.