251116.2 · f8029ee7819a11399236c655163425aa08e257fe
darwin/arm64: use the number of perf cores as the default number of workers (#68)
Starting around macOS v15 the parallel performance of the APFS file system appears slightly improved and now the ideal number of fastwalk workers is generally the number of performance cores currently available.
Therefore, this commit changes the default number of workers on darwin/arm64 to be the value of sysctl("hw.perflevel0.physicalcpu") which is the number of currently available performance cores (link to xnu source below).
https://github.com/apple-oss-distributions/xnu/blob/43a90889846e00bfb5cf1d255cdc0a701a1e05a4/bsd/sys/sysctl.h#L1244
reading declarations
Changes to numcpu_darwin_arm64.go. All files
@@ -0,0 +1,25 @@+//go:build darwin && arm64++package fastwalk++import "syscall"++// darwinNumPerfCores returns the number of performance cores currently+// available on macOS/arm64.+func darwinNumPerfCores() int {+ // "hw.physicalcpu" is the number of physical processors available in+ // the current power management mode.+ //+ // https://github.com/apple-oss-distributions/xnu/blob/43a90889846e00bfb5cf1d255cdc0a701a1e05a4/bsd/sys/sysctl.h#L1244+ //+ // NB: We do not cache this value since it could change with the power+ // management mode.+ //+ // TODO: Find someone with a Mac Studio or MacPro to see if this still+ // holds true when the CPU is basically two "fused" ones.+ n, err := syscall.SysctlUint32("hw.perflevel0.physicalcpu")+ if err != nil {+ return -1+ }+ return int(n)+}