Skip to content

poc: job control#298

Draft
kxxt wants to merge 1 commit into
mainfrom
jc
Draft

poc: job control#298
kxxt wants to merge 1 commit into
mainfrom
jc

Conversation

@kxxt

@kxxt kxxt commented Jul 19, 2026

Copy link
Copy Markdown
Owner

PoC for #32.

tracexec can be used to control parallelism of sub-processes to help avoiding pressure stalls or even OOM.

I think I will become willing to merge this if it could exceed the native performance of make -j$(nproc) in a kernel build.

Currently it is slightly slower than it.

# 1:17.77 total
make -j32
# 1:20.69 total
~/repos/tracexec/target/release/tracexec log --output=/dev/null --job-control=auto -- make -j  

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tracexec Ready Ready Preview, Comment Jul 19, 2026 8:06am

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 6620e689-a598-43ba-be0e-d5b4d978cd1a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an automatic subprocess job control feature for the ptrace backend, allowing dynamic control of subprocess parallelism based on system resource pressure (CPU and memory stalls via Linux PSI, with fallbacks). It adds a new --job-control auto CLI option, a corresponding configuration parameter, and the core AutoJobController logic along with extensive tests. A critical race condition was identified in the thread registration logic of the job control wakeup state, which could cause the wakeup thread to block indefinitely if a job is queued before registration completes. A code suggestion has been provided to resolve this issue.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +47 to +52
pub(super) fn register_worker(&self, worker: Thread) {
assert!(
self.worker.set(worker).is_ok(),
"job-control wakeup worker was registered twice"
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a race condition between the tracer thread registering the worker thread and the worker thread parking itself.

  1. The jc-wakeup thread is spawned and starts running. It checks has_waiting_jobs(), which is false, so it prepares to park.
  2. Before the tracer thread calls register_worker, a job is paused, calling set_waiting_jobs(true).
  3. set_waiting_jobs(true) sees that self.worker.get() is None (since register_worker hasn't run yet), so it does not call unpark().
  4. The tracer thread then calls register_worker(thread).
  5. The jc-wakeup thread calls std::thread::park() and blocks forever, because the unpark() signal was lost.

To fix this, register_worker should check if there are already waiting jobs, and if so, immediately unpark the worker.

Suggested change
pub(super) fn register_worker(&self, worker: Thread) {
assert!(
self.worker.set(worker).is_ok(),
"job-control wakeup worker was registered twice"
);
}
pub(super) fn register_worker(&self, worker: Thread) {
assert!(
self.worker.set(worker).is_ok(),
"job-control wakeup worker was registered twice"
);
if self.has_waiting_jobs() {
if let Some(worker) = self.worker.get() {
worker.unpark();
}
}
}

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.04819% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.61%. Comparing base (939083b) to head (9f80dbd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../tracexec-backend-ptrace/src/ptrace/job_control.rs 95.24% 29 Missing ⚠️
...rates/tracexec-backend-ptrace/src/ptrace/tracer.rs 70.27% 22 Missing ⚠️
...tracexec-backend-ptrace/src/ptrace/tracer/inner.rs 80.76% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #298      +/-   ##
==========================================
+ Coverage   82.25%   82.61%   +0.35%     
==========================================
  Files          84       85       +1     
  Lines       21026    21873     +847     
==========================================
+ Hits        17295    18070     +775     
- Misses       3731     3803      +72     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant