You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[receiver/hostmetrics] Cheaper parent PID and number of threads retrieval on Windows (open-telemetry#38589)
(To replace PR open-telemetry#35337)
Reduces the cost of getting number of threads and parent process ID by
calling `CreateToolhelp32Snapshot` to do process enumeration. The data
returned by this function already includes the number of threads and
parent process ID - and avoiding calling `CreateToolhelp32Snapshot` for
every enumerated process.
Fixopen-telemetry#32947
```terminal
> go test -benchmem -run=^$ -bench ^BenchmarkGetProcessMetadata$ -benchtime 10s
goos: windows
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper
cpu: Intel(R) Core(TM) Ultra 7 165H
BenchmarkGetProcessMetadata/Old-IncludeParentPid-22 3 3928594600 ns/op 28357514 B/op 13029 allocs/op
BenchmarkGetProcessMetadata/New-IncludeParentPid-22 171 69861262 ns/op 28222817 B/op 12591 allocs/op
BenchmarkGetProcessMetadata/Old-ExcludeParentPid-22 172 68011864 ns/op 28232550 B/op 12614 allocs/op
BenchmarkGetProcessMetadata/New-ExcludeParentPid-22 169 72172583 ns/op 28351193 B/op 12647 allocs/op
PASS
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper 81.722s
> go test -benchmem -run=^$ -bench ^BenchmarkGetProcessMetadata$ -benchtime 30s
goos: windows
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper
cpu: Intel(R) Core(TM) Ultra 7 165H
BenchmarkGetProcessMetadata/Old-IncludeParentPid-22 8 4115364238 ns/op 28797698 B/op 13220 allocs/op
BenchmarkGetProcessMetadata/New-IncludeParentPid-22 514 70165003 ns/op 28702086 B/op 12800 allocs/op
BenchmarkGetProcessMetadata/Old-ExcludeParentPid-22 552 70230804 ns/op 28558975 B/op 12750 allocs/op
BenchmarkGetProcessMetadata/New-ExcludeParentPid-22 504 73404366 ns/op 28507275 B/op 12707 allocs/op
PASS
ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper 170.587s
```

0 commit comments