Important
Planned breaking change: mem.SwapMemory vmstat values on Linux
This release includes #2188. In a future release, four Linux values of SwapMemory will change. The API will not change.
These values are wrong now. They are multiplied by 4096 by mistake.
| Field | Now | After the change |
|---|---|---|
PgIn, PgOut
| KiB × 4096 | bytes (1/4 of now) |
PgFault, PgMajFault
| count × 4096 | count (1/4096 of now) |
- In February 2027, the fixed values will become the default.
- The Windows
disk.IOCounterschange from v4.26.10 (#2164) will happen in the same release.
You can switch to the fixed values now with the new context key mem.WillBeDeletedOptInLinuxSwapVmstatUnits:
ctx := context.WithValue(context.Background(), mem.WillBeDeletedOptInLinuxSwapVmstatUnits, true)
stat, err := mem.SwapMemoryWithContext(ctx)- Without this key, nothing changes in this release.
- Other platforms ignore this key.
- This key will be removed when the fixed values become the default.
Remove it from your code at that time.
(#2188)
Important
Behaviour change: disk.Usage Used on macOS APFS
On APFS, Used is now the space used by the volume itself (#2229).
Before, it was the space used by the whole APFS container.
- On
/,UsedPercentdrops a lot (for example, from about 90% to about 10–20%). Used + Freeis no longer equal toTotal.- The new values match
dfand psutil. The old values were wrong. - Other file systems (exFAT, NFS, ...) do not change. On HFS+,
Usedincludes reserved blocks, asdfdoes.
If you alert on UsedPercent for macOS, please check your thresholds.
Note
Other changes in returned values
These are bug fixes. They change values right away, without any opt-in.
If your code works around the old values, please remove the workaround.
cpu
- darwin/arm64, Apple M4 and later:
Info().Mhzis about 1000x larger (for example, 4 → 4464). M3 and older, and Intel Macs, do not change. (#2215) - FreeBSD:
Counts(false)returns physical cores. Before, it returned logical CPUs. (#2172) - AIX (cgo):
Times()returns seconds, not clock ticks (about 1/100 of before).Percent()does not change. (#2222)
disk
- Windows:
Partitionsno longer returns empty entries for not-ready removable, remote and CD-ROM drives. RAM disks are now returned. (#2187) - Linux
Partitions()mount points, andUsage().Pathon Linux, darwin, FreeBSD and AIX: only\oooescapes are decoded. Other backslashes are kept as they are. (#2190)
host
- Linux with systemd 256 or later and no utmp:
Users()now returns SSH sessions, also sessions without a tty (for example,ssh host cmd). TheirTerminalissshd. (#2217, #2231)
mem
- Linux with a page size other than 4 KiB (for example, 64 KiB arm64 kernels):
SwapMemory().Sin/Soutare now correct (4x or 16x larger than before). 4 KiB pages do not change. (#2206)
process
- Linux:
Nice()returns the nice value itself. Before, it returned20 - nice(nice 0 returned 20, now 0). (#2192) - Linux:
MemoryInfoEx().Datais the real data size.Dirtyis always 0, as the kernel reports. Before,Dirtyheld the data size. (#2202) - Linux:
CmdlineSlice()keeps trailing empty arguments, as psutil does. Processes that pad their title with NULs (for example,sshmux) can return many""at the end. (#2205) - darwin:
Uids()returns 3 values (real, effective, saved), like other platforms.Username()now uses the real uid. Before, it used the effective uid. (#2185) - Windows:
Kill,Terminate,SuspendandResumereturnErrorProcessNotRunningwhen the PID was reused by another process. Before, they acted on the other process. (#2220)
What's Changed
cpu
- [cpu][freebsd]: return physical cores from Counts(false) by @fredrikblau in #2172
- cpu/linux: recognize the uppercase CPU MHz fallback field by @omrzk in #2184
- cpu/linux: recognize the LoongArch CPU Family field by @omrzk in #2199
- fix(cpu): scale Apple M4 and later clocks from kHz by @SebTardif in #2215
- cpu/aix: Convert clock ticks to seconds by @sswamy48 in #2222
disk
- [disk][linux]: take IOCounters device numbers from /proc/diskstats by @TastyHeadphones in #2183
- [disk][windows]: don't report an empty partition for not-ready removable/remote/CD-ROM drives by @pjanotti in #2187
- [disk][linux]: decode only \ooo escapes in mount points by @hsdfat in #2190
- [net][disk]: don't split lsof and mountinfo fields on Unicode spaces by @shamsManna in #2213
- [disk][darwin]: report the volume's used space on APFS by @sohailshk in #2229
- disk/linux: resolve sysfs serials from the requested disk by @anishpentyala in #2218
host
- Use uname syscall instead of uname command on AIX and Solaris by @pgimalac in #2195
- Fix utmp layouts on Linux to fix UsersWithContext by @pgimalac in #2200
- [host][linux]: keep remote loginctl sessions without tty by @nook24 in #2217
- [host][linux]: pin apt to snapshot.debian.org in godefs Dockerfile by @shirou in #2230
- [host][linux]: keep tty-less loginctl sessions by Type, as who does by @shirou in #2231
mem
- mem/linux: fix PgFault/PgMajFault and PgIn/PgOut scaling in SwapMemory by @debnon in #2188
- Use native page size for swap I/O counters by @pgimalac in #2206
- [mem][linux]: clarify swap vmstat scaling comment by @shirou in #2224
- [mem]: skip TestSwapDevices when the host has no swap by @shirou in #2232
net
- [net][linux]: skip unparsable lines in /proc/net/unix by @shamsManna in #2180
- [net][linux]: fix IPv6 address decoding on big-endian hosts by @hsdfat in #2191
- Preserve whitespaces in Unix socket paths when parsing net/unix by @pgimalac in #2203
process
- [process][darwin]: implement MemoryInfoEx with PhysFootprint by @ag3ntsc4rn in #2177
- [process][linux]: use splitProcStat in ForegroundWithContext by @shamsManna in #2181
- [process][darwin]: return real, effective and saved uids from Uids by @spicysharkco in #2185
- process: fix Nice() reporting 20-nice on Linux by @abcdlsj in #2192
- Fix MemoryInfoEx statm Data and Dirty fields on Linux by @pgimalac in #2202
- Preserve trailing empty command-line process arguments by @pgimalac in #2205
- [process][freebsd][openbsd]: compare argv[0] with comm in Name by @shamsManna in #2214
- [process][windows]: check create time before kill, terminate, suspend and resume by @shamsManna in #2220
- [process][linux]: read the boot time only for the create time by @g4lb in #2226
Other Changes
- [ci][darwin]: drop macos-14 runner by @shirou in #2212
- Update perfstat to benefit from upstream fixes by @pgimalac in #2207
New Contributors
- @fredrikblau made their first contribution in #2172
- @ag3ntsc4rn made their first contribution in #2177
- @shamsManna made their first contribution in #2180
- @omrzk made their first contribution in #2184
- @spicysharkco made their first contribution in #2185
- @pjanotti made their first contribution in #2187
- @debnon made their first contribution in #2188
- @abcdlsj made their first contribution in #2192
- @SebTardif made their first contribution in #2215
- @nook24 made their first contribution in #2217
- @sswamy48 made their first contribution in #2222
- @g4lb made their first contribution in #2226
- @sohailshk made their first contribution in #2229
- @anishpentyala made their first contribution in #2218
Full Changelog: v4.26.10...v4.26.11