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

[process][posix] Fix #1049 check if procfs is mounted before checking if pid exists there #1051

Merged
merged 1 commit into from Mar 21, 2021

Conversation

Lomanic
Copy link
Collaborator

@Lomanic Lomanic commented Mar 18, 2021

[process][posix] Fix #1049 check if procfs is mounted before checking if pid exists there

Benchmark before this change (process.NewProcess() calls process.PidExistsWithContext()
internally)

go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
goos: linux
goarch: amd64
pkg: github.com/shirou/gopsutil/process
BenchmarkNewProcess-4              14722             78751 ns/op
PASS
ok      github.com/shirou/gopsutil/process      3.685s

Benchmark with this change applied

go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
goos: linux
goarch: amd64
pkg: github.com/shirou/gopsutil/process
BenchmarkNewProcess-4              14835             80180 ns/op
PASS
ok      github.com/shirou/gopsutil/process      3.761s

…ecking if pid exists there

Benchmark before this change (process.NewProcess() calls process.PidExistsWithContext()
internally)

    go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
    goos: linux
    goarch: amd64
    pkg: github.com/shirou/gopsutil/process
    BenchmarkNewProcess-4              14722             78751 ns/op
    PASS
    ok      github.com/shirou/gopsutil/process      3.685s

Benchmark with this change applied

    go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
    goos: linux
    goarch: amd64
    pkg: github.com/shirou/gopsutil/process
    BenchmarkNewProcess-4              14835             80180 ns/op
    PASS
    ok      github.com/shirou/gopsutil/process      3.761s
Copy link
Owner

@shirou shirou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have confirmed this works on my FreeBSD which I unmount the procfs. Thank you so much!

@shirou shirou merged commit 76779af into shirou:master Mar 21, 2021
@Lomanic Lomanic deleted the issue1049 branch March 22, 2021 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Freebsd(jail): process.NewProcess doesnt work if no procfs mounted
2 participants