Add `--in-process` runner mode for environments without subprocess support
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 962
- Forks
- 106
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 4
Description
Problem Statement
pyperf currently requires subprocess spawning (subprocess.Popen) for every benchmark run. This makes pyperf unusable in environments where subprocess is not available.
The primary motivating environment is WebAssembly. WebAssembly platform has no subprocess support due to the fundamental platform level limitations of the WebAssembly sandbox. We (Pyodide maintainers) have an interest in running pyperformance benchmarks in WebAssembly to track the Python performance in the browser over time, and also benchmark the recent advancements such as tail call interpreter (https://github.com/pyodide/pyodide/issues/6102).
Proposed Solution
Add a new --in-process flag in the runner that runs the entire benchmark in the current process.
Implementation Plans
I think subclassing the Manager with an InProcessManager that overrides only spawn_worker() to execute WorkerProcessTask.create_run() directly instead of spawning a child process would work
Caveats
In-process mode will not provide the isolation benefits of subprocess:
- No clean memory state per run
- No OS-level CPU affinity control
For environments like Pyodide, this tradeoff is acceptable — subprocess is not an option at all. Results may have slightly different characteristics, but the benchmark values themselves are produced by the exact same timing code path.
Implementation
I am willing to implement this and submit a PR. Feedback on the approach is welcome before I proceed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pyperf/_manager.py at spawn_worker() and trace how WorkerProcessTask.create_run() is invoked. Add the --in-process runner path so the benchmark runs in the current process without subprocess spawning, then verify that it works in WebAssembly-compatible environments while retaining the documented isolation tradeoffs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, wasm
- Domain
- cli, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100