wyxxxcat opened a new pull request, #70752: URL: https://github.com/apache/doris/pull/70752
### Background Doris Cloud uses `SimpleThreadPool` to execute background jobs. The worker count is set when the pool is constructed, and a bounded queue applies backpressure to submissions. ### What problem does this PR solve? Issue Number: TODO(author): the issue is opened with the PR Related PR: None PR Type: Feature Problem Summary: Cloud components need a way to adjust background job concurrency while a pool is running. Add `AdaptiveThreadPool` so callers can resize the pool explicitly. The implementation also adjusts the queue capacity and retires workers during scale-down while keeping queued jobs available to the remaining workers. ### Details - **Change map:** 434 lines of production code in one header. About 75 lines implement the resizable bounded queue, about 310 implement the pool API and worker lifecycle, and the remaining lines cover includes, the license header, and the variant. - **Scope:** Add an internal Cloud thread pool that supports runtime resizing by target size, signed worker-count delta, or multiplier. - **Design:** Clamp the target worker count to the configured bounds and set queue capacity to twice the target. Mark excess workers for retirement and preserve queued jobs during scale-down. - **Usage:** Start the pool, then call `resize(8)`, `adjust_by_count(-2)`, or `adjust_by_ratio(1.5)`. Use `ThreadPoolVariant` with `std::visit` to call the common pool operations. - **Default behavior:** Resizing is caller-driven. The minimum worker count defaults to one, and this change adds no call sites or configuration settings. - **Compatibility:** The new type shares the lifecycle and job-submission API of `SimpleThreadPool`. There are no protocol or persisted metadata changes. ### Testing No build or runtime tests were run as part of this review. ### Notes for Reviewers - Detached workers capture the pool object and can race with its destruction after `terminate()`. ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Not ready: the detached-worker lifetime issue is unresolved. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
