Skip to content

perf: hook subprocess fork per tool call #3148

Closed as not planned
Closed as not planned

Description

@csmith49

Problem

Each hook execution spawns a new subprocess via subprocess.Popen (async) or subprocess.run (sync). For a conversation with 3 registered hooks and 50 tool calls, that's 150 process forks. Each fork includes full JSON serialization of the event as stdin.

Location: hooks/executor.py:175, 214

Evidence

Code review of hooks/executor.py. The AsyncProcessManager.cleanup_expired() does a linear scan of all tracked processes before every hook execution.

Severity: High

Impact of fix

Eliminates hundreds of fork+exec cycles per conversation.

Suggested fixes

  • Long-running hook process with stdin/stdout IPC (send events as JSON lines, receive responses).
  • For trusted hooks: in-process execution via importable Python functions.

Related issues and PRs

Discovered during profiling investigation (code review), May 2026. openhands-sdk v1.19.1.

Activity

  1. added
    bug
    performance
    on May 8, 2026
  2. github-actions commented on Jun 18, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 40 days with no activity. Remove the stale label or leave a comment, otherwise it will be closed in 10 days.

  3. github-actions commented on Jun 29, 2026

    @github-actions
    Contributor

    This issue was automatically closed due to 50 days of inactivity. We do this to help keep the issues somewhat manageable and focus on active issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalebugperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions