Skip to content

Add benchmark harness and disable ORT thread pool spinning#785

Draft
xav-ie wants to merge 2 commits intoroyshil:mainfrom
xav-ie:pr/benchmark-and-ort-spinning
Draft

Add benchmark harness and disable ORT thread pool spinning#785
xav-ie wants to merge 2 commits intoroyshil:mainfrom
xav-ie:pr/benchmark-and-ort-spinning

Conversation

@xav-ie
Copy link
Copy Markdown

@xav-ie xav-ie commented Feb 26, 2026

Summary

  • Adds a standalone benchmark harness (benchmark/) with extracted pipeline helpers that exercise the preprocessing and similarity-check hot path using synthetic 1920×1080 BGRA frames and Linux perf_event_open hardware counters
  • Disables ONNX Runtime's intra/inter-op thread pool spin-waiting (allow_spinning = 0) to reduce idle CPU usage when the session is waiting for frames

Benchmark results (300 iterations, best of 3 runs)

Commit Median (µs/frame) Change
Benchmark harness baseline 2532.0
+ Disable ORT spinning (no change to benchmark path) reduces idle CPU

Pull Request Checklist

Please read our latest CONTRIBUTING.md.

  • I have read the latest CONTRIBUTING.md.
  • I have acknowledged the licensing and patent grant policy.
  • I have included the required license headers.
  • I am confident with my code integrity.
  • I have signed off and verified all my commits.

@xav-ie xav-ie force-pushed the pr/benchmark-and-ort-spinning branch from 2eae688 to e46c6d0 Compare February 27, 2026 03:43
@xav-ie
Copy link
Copy Markdown
Author

xav-ie commented Feb 27, 2026

I am happy to split this into two. The second commit really helped my computer a lot.

@umireon
Copy link
Copy Markdown
Collaborator

umireon commented Feb 27, 2026

Can you add a file to describe how we can compile and run the benchmark program?

@umireon
Copy link
Copy Markdown
Collaborator

umireon commented Feb 27, 2026

Thanks for signing the commits. We think supply chain security is important.

@umireon
Copy link
Copy Markdown
Collaborator

umireon commented Feb 27, 2026

I will add CONTRIBUTING.md for clarity of licensing before we merge your pull requests. Please wait for my work, I will start immediately. CONTRIBUTING.md was temporarily removed due to reorganizing this project. Thanks in advance.

Copy link
Copy Markdown
Collaborator

@umireon umireon left a comment

Choose a reason for hiding this comment

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

Working on the CONTRIBUTING.md now. Sorry but wait a moment, please.

@xav-ie xav-ie marked this pull request as draft February 27, 2026 12:39
@umireon
Copy link
Copy Markdown
Collaborator

umireon commented Feb 27, 2026

@xav-ie I've added checklist to your description. Feel free to ask us for question, it is added to this project just now.

@umireon umireon dismissed their stale review February 27, 2026 17:54

Checklist added

xav-ie added 2 commits March 8, 2026 00:04
Extract shared pipeline helper functions (render_write, tick_read,
check_similarity, preprocess_for_inference) into src/pipeline-helpers.h
for use by both the plugin and a standalone benchmark.

The benchmark exercises the same code paths as the plugin:
  1. Render thread writes frame to shared buffer (clone)
  2. Tick thread reads frame from shared buffer (clone)
  3. Similarity check via full-frame PSNR
  4. Preprocessing: cvtColor(BGRA→RGB) then resize

Reports per-frame timing (mean/median/p95), hardware perf counters
(cache-misses, LLC-store-misses via perf_event_open), and optionally
measures CPU utilization with a real ONNX Runtime thread pool at 30fps.

Signed-off-by: Xavier Ruiz <github@xav.ie>
Set session.intra_op.allow_spinning=0 and
session.inter_op.allow_spinning=0 to prevent ORT worker threads
from busy-waiting between inference calls.  This eliminates idle
CPU burn without affecting inference latency.

Signed-off-by: Xavier Ruiz <github@xav.ie>
@xav-ie xav-ie force-pushed the pr/benchmark-and-ort-spinning branch from e46c6d0 to 68d9c8c Compare March 8, 2026 05:07
@umireon umireon added the auto-review Turn on this when PR is ready label Mar 15, 2026
@umireon umireon added this to the 1.4.1 milestone Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-review Turn on this when PR is ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants