Skip to content

Fix publisher threading model#86

Merged
gsmetal merged 3 commits intomasterfrom
fix/publisher-process-all-models
Mar 30, 2026
Merged

Fix publisher threading model#86
gsmetal merged 3 commits intomasterfrom
fix/publisher-process-all-models

Conversation

@gsmetal
Copy link
Copy Markdown
Member

@gsmetal gsmetal commented Mar 30, 2026

Problem: The publisher dedicated one permanent thread per model. When the number of models exceeded the thread pool size, excess models were never processed (thread starvation).

Solution: Replaced the one-thread-per-model design with a shared thread pool and one-shot tasks:

  • Discovery (every 30s) — detects new models in artery_model_infos, initializes them once; removes models that no longer exist.
  • Polling (every 0.5s) — submits a finite process_model task for each idle model. The task drains all pending batches, then returns the thread to the pool.
  • @busy_models set prevents double-submission; ensure guarantees cleanup on errors.

All models now get fair scheduling regardless of pool size. Busy models still process consecutive batches without latency penalty.

@gsmetal gsmetal self-assigned this Mar 30, 2026
@gsmetal gsmetal marked this pull request as ready for review March 30, 2026 08:53
@gsmetal gsmetal merged commit 2bb2cf6 into master Mar 30, 2026
2 checks passed
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