Batch & Partition

Task Batch Partitioning Algorithm & ThreadPoolExecutor Concurrency Throttling

Decrypting batch_runner.py task distribution, dynamic thread pool scaling & exception recovery
Concurrency thread pool structure
📊 Fig 12-1-1: Batch data slicing, thread pool allocation & task channel concurrency limiting structure diagram

⚡ 1. Batch Task Partitioning Algorithm

In batch_runner.py, when facing hundreds or thousands of parallel tasks, the system implements an efficient partitioning algorithm that distributes tasks across concurrent queues based on workload and available hardware threads.

Batch retry backoff
📊 Fig 12-1-2: Batch concurrent API error capture, backoff delay calculation & task channel retry sequence diagram

🚦 2. Thread Pool Concurrency Throttling & Exception Fault Tolerance

The system controls the number of active ThreadPoolExecutor threads via configured concurrency limits, preventing excessive parallelism from overwhelming the LLM server, while automatically spawning new threads to take over remaining batches when a thread crashes.