Skip to content

perf(indexing): run independent capability groups concurrently - #143

Open
ik020 wants to merge 2 commits into
grayhatdevelopers:mainfrom
ik020:concurrent-capability-groups
Open

perf(indexing): run independent capability groups concurrently#143
ik020 wants to merge 2 commits into
grayhatdevelopers:mainfrom
ik020:concurrent-capability-groups

Conversation

@ik020

@ik020 ik020 commented Sep 4, 2026

Copy link
Copy Markdown

Related issue

Closes #96

Summary

Parallelizes _run_enabled_modalities so independent capability groups (for example, scene and speech) can run concurrently instead of sequentially, using ThreadPoolExecutor.

The implementation also tracks active stages per capability group so concurrent workers cannot overwrite a single shared stage value.

This PR adds regression coverage for concurrent execution and manifest stage preservation.

GPU/CPU resource coordination via ResourceScheduler is intentionally left out of scope. It is not currently wired into the relevant capability indexers, so resource contention should be measured before introducing additional scheduling logic.

No public interfaces or capability contracts are changed. The change is limited to the internal execution of independent capability groups.

Validation

  • PYTHONPATH=src python -m pytest tests/test_runner.py -v

    • 18 passed
  • git diff --check

    • No whitespace errors
  • test_concurrent_capability_groups_do_not_drop_stages

    • Runs concurrent scene + speech indexing repeatedly and verifies that both stages are preserved in the manifest.
  • test_capability_groups_actually_run_concurrently

    • Uses threading.Event synchronization to verify that the two capability groups actually overlap in execution rather than merely being dispatched independently.

Benchmark

Added benchmark_concurrency.py to measure the orchestration behavior using simulated capability latency.

With simulated latencies of 0.40s for scene and 0.55s for speech:

  • Theoretical sequential time: 0.950s
  • Theoretical concurrent ceiling: 0.550s
  • Theoretical maximum speedup: 1.73脳
  • Measured concurrent mean: ~0.565s
  • Measured speedup against the simulated sequential baseline: ~1.68脳

These numbers use artificial delays and do not represent real model-inference performance. The benchmark is intended to demonstrate the concurrency behavior and orchestration overhead. Real-world speedup will depend on model execution, CPU/GPU resources, and workload characteristics.

Parallelizes _run_enabled_modalities using ThreadPoolExecutor so
independent capability groups (e.g. scene, speech) index concurrently
instead of sequentially. Adds a lock to ManifestStore to make its
read-modify-write methods safe under concurrent calls, and replaces
the single shared 'stage' variable with a per-group tracked dict to
avoid one group's status clobbering another's.

GPU/CPU resource coordination between groups (ResourceScheduler) is
left out of scope for this change and can be addressed as a follow-up
if benchmarking shows contention is a real problem in practice.

Benchmark (5 runs, simulated 0.40s/0.55s group latencies):
  sequential (theoretical): 0.950s
  concurrent (measured):    0.565s mean, stdev 0.003s
  speedup:                  1.68x (theoretical ceiling 1.73x)

Refs grayhatdevelopers#96
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.

Performance: Multiprocessing/Multithreading and general speedup

1 participant