Skip to content

Performance

SpaceSquare edited this page Aug 3, 2026 · 1 revision

繁體中文:Performance-zh-TW

Performance: Parallel Scanning

cv2.matchTemplate (already native OpenCV code) dominates scan cost, and it releases Python's GIL while running — so scanning many rules across a thread pool gives real multi-core speedup with zero custom C++ (benchmarked ~3–4.6x with 4–16 workers). Opt in with --max-workers N:

python -m core.run rules.json --max-workers 4
python -m core.server --max-workers 4

The GUI server defaults to min(4, cpu_count); the CLI defaults to 1 (sequential) to keep its behaviour simple and predictable. Only worth raising if you have several rules and/or large ROIs — with just a couple of small rules there's nothing to parallelize.

See benchmarks/ in the repo for the scripts backing these numbers, and why a hand-written C++ module was not the right move here.

Clone this wiki locally