Skip to content

Resource reduction opportunities for gProfiler agent #990

@prashantbytesyntax

Description

@prashantbytesyntax

When running gProfiler as a systemd service, we observe two key issues:

  1. One Profiler trying to profile for the Same Target PID

Issue:
Multiple gProfiler-related processes are created to profile the same target process ID.
Example: Both PyPerf (each from staticx and pyinstaller) may attempt to profile the same Python process, leading to redundant profiler subprocesses and increased resource usage. Also noticed 2 subprocesses from gProfiler too ( from staticx installer)

Impact:

Wasted system resources (CPU, memory, file handles)
Potential contention or interference between profiler subprocesses
Harder to reason about profiling results and system load

  1. Resource Cleanup: Ensure Profiler Subprocesses Are Properly Killed

Feature Request:
Each profiler subprocess (Java, Python, perf, etc.) is launched with a timeout and kill signal (SIGKILL/SIGTERM). However, we want an additional safety check to guarantee that all profiler subprocesses are actually terminated after each profiling duration.

Proposal:

After each profiling interval, use psutil to check for any lingering profiler subprocesses (e.g., py-spy, async-profiler, perf) that should have exited.
If any are found, forcibly terminate them using psutil.Process(pid).kill() and log the action.
Optionally, add a summary log or metric for "zombie" profiler subprocesses cleaned up in this way.

  1. Multiple process of gProfiler spun up from staticx installer
  2. Two profilers trying to profiler same target process

Metadata

Metadata

Assignees

No one assigned

    Labels

    TriagingNeed to understand the issue more with triagingbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions