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
The sysctl implementation allocates 256 KiB for every invocation.
In go-sysinfo a sync.Pool is used to minimize the amount of memory that is allocated for each call. It uses a buffer from the pool to make the call then allocates only the size required rather than ARG_MAX.
Port this same optimization to the system metrics package. Here is one example where it would apply:
Something else to consider: Instead of allocating a single, large chunk of memory ahead of time, we can use sysctl's own memory allocation reporting to make sure we only allocate what memory we need. For example, on MacOS 12, we will allocate ARG_MAX bytes, which is 1048576 but the average process will actually need something closer to only 600.
The sysctl implementation allocates 256 KiB for every invocation.
In go-sysinfo a sync.Pool is used to minimize the amount of memory that is allocated for each call. It uses a buffer from the pool to make the call then allocates only the size required rather than ARG_MAX.
Port this same optimization to the system metrics package. Here is one example where it would apply:
elastic-agent-system-metrics/metric/system/process/process_darwin.go
Lines 154 to 161 in 5f48574
We could avoid allocating a new slice for every process with this optimization.
The text was updated successfully, but these errors were encountered: