Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance discrepancy between macOS and Ubuntu #1711

Open
2 of 5 tasks
rsoaresd opened this issue Sep 13, 2024 · 0 comments
Open
2 of 5 tasks

performance discrepancy between macOS and Ubuntu #1711

rsoaresd opened this issue Sep 13, 2024 · 0 comments

Comments

@rsoaresd
Copy link

rsoaresd commented Sep 13, 2024

Describe the bug
We have noticed a significant performance discrepancy when using some of the functions of gopsutil/process on macOS compared to Ubuntu. Precisely, functions related to collecting process information, such as the process name, command line, and CPU usage, are taking considerably longer to execute on macOS than on Ubuntu.

To Reproduce

func TestOneProcessCPUTime(t *testing.T) {
	start := time.Now()
	processes, err := process.ProcessesWithContext(context.TODO())
	require.NoError(t, err)
	t.Log("collect processes took: ", time.Since(start))

	start = time.Now()
	proc := processes[0]
	_, err = proc.Name()
	require.NoError(t, err)
	t.Log("take the name took: ", time.Since(start))

	start = time.Now()
	_, err = proc.Cmdline()
	require.NoError(t, err)
	t.Log("take the cmd line took: ", time.Since(start))

	start = time.Now()
	_, err = proc.CPUPercent()
	require.NoError(t, err)
	t.Log("calculate CPU took: ", time.Since(start))
}

ubuntu

=== RUN   TestOneProcessCPUTime
    scanner_test.go:27: collect processes took:  8.819014ms
    scanner_test.go:33: take the name took:  32.28µs
    scanner_test.go:38: take the cmd line took:  24.727µs
    scanner_test.go:43: calculate CPU took:  110.146µs

macos

=== RUN   TestOneProcessCPUTime
    scanner_test.go:27: collect processes took:  1.4936445s
    scanner_test.go:33: take the name took:  80.5µs
    scanner_test.go:38: take the cmd line took:  3.218542ms
    scanner_test.go:43: calculate CPU took:  6.1055ms

Expected behavior
The functions should perform similarly across different operating systems. Or, at least, macos performance should be better than the current one.

Environment (please complete the following information):

  • Windows: [paste the result of ver]
  • Linux: [paste contents of /etc/os-release and the result of uname -a]
uname -a
Linux fv-az1079-[4](https://github.com/codeready-toolchain/workload-analyzer/actions/runs/10847921906/job/30104001193?pr=27#step:2:5)30 6.5.0-1025-azure #26~22.04.1-Ubuntu SMP Thu Jul 11 22:33:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Ubuntu 22.0[4](https://github.com/codeready-toolchain/workload-analyzer/actions/runs/10847921906/job/30104001193?pr=27#step:3:5).4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
  • Mac OS: [paste the result of sw_vers and uname -a
uname -a
Darwin Mac-172622[4](https://github.com/codeready-toolchain/workload-analyzer/actions/runs/10847921906/job/30104000821?pr=27#step:2:5)488179.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:03 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_VMAPPLE arm64
sw_vers
ProductName:		macOS
ProductVersion:		1[4](https://github.com/codeready-toolchain/workload-analyzer/actions/runs/10847921906/job/30104000821?pr=27#step:3:5).6.1
BuildVersion:		23G93
  • FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • OpenBSD: [paste the result of uname -a]

Additional context
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding go env]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant