You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Akanksha-kedia (via GitHub)" <gi...@apache.org> on 2026/05/18 10:01:44 UTC

[PR] [multistage] Fast-path empty response when all segments pruned at broker [pinot]

Akanksha-kedia opened a new pull request, #18516:
URL: https://github.com/apache/pinot/pull/18516

   ## Description
   
   When the multi-stage engine's broker-side segment pruning eliminates all segments for a query (i.e., no real servers remain in the dispatch plan), the broker currently still acquires a query-throttler slot and dispatches to servers needlessly. This PR adds a fast-path that detects this condition and returns an empty `BrokerResponseNativeV2` with the correct result schema immediately, skipping dispatch entirely.
   
   ## Problem
   
   In the current flow, even when all segments are pruned at the broker:
   1. The query throttler semaphore is acquired (blocking other queries)
   2. The query is dispatched over the network to servers
   3. Servers process an empty plan and return empty results
   4. The broker reduces the empty results
   
   This wastes query-throttler capacity, network round-trips, and server-side resources for queries that are already known to produce no results.
   
   ## Solution
   
   After `planQuery()` produces the `DispatchableSubPlan`, check if `servers.size() <= 1` (i.e., only the broker itself is present in the plan with no real servers to dispatch to). When this condition holds, call the new `buildEmptyBrokerResponse()` method that:
   
   - Constructs the correct `DataSchema` from the plan's root stage and result fields
   - Returns an empty `ResultTable` with zero rows
   - Reports `numServersQueried = 0` and `numServersResponded = 0`
   - Populates the broker-pruned segment count in stats
   - Logs the query completion and updates metrics as normal
   
   ## Performance Impact
   
   - Eliminates network round-trips for fully-pruned queries
   - Eliminates query-throttler slot acquisition (reduces head-of-line blocking for other queries)
   - Reduces server-side thread/memory allocation for no-op dispatches
   - Latency for pruned queries drops from network-RTT-bounded to sub-millisecond
   
   ## Testing Done
   
   - [x] Unit test added: `testBuildEmptyBrokerResponseWhenAllSegmentsPruned` verifies correct schema, zero rows, zero servers queried/responded, and that the query throttler is never called
   - [x] Verified the optimization is placed after QPS quota validation (so quota is still enforced)
   - [x] Verified backward compatibility: queries with actual segments are unaffected
   
   ## Checklist
   - [x] Code follows project style guidelines
   - [x] Self-review completed
   - [x] No new warnings introduced
   - [x] Unit test covers the new fast-path behavior


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [multistage] Fast-path empty response when all segments pruned at broker [pinot]

Posted by "Akanksha-kedia (via GitHub)" <gi...@apache.org>.
Akanksha-kedia commented on PR #18516:
URL: https://github.com/apache/pinot/pull/18516#issuecomment-4669869633

   Closing as superseded by apache/pinot#18538 which landed a more complete short-circuit implementation. That PR correctly runs `QueryDispatcher.runReducer` for the broker-reduce stage (handling e.g. `COUNT(*)` on pruned segments), whereas this PR's early return bypassed the reduce stage entirely. The core optimization — skipping server dispatch when all segments are pruned — is now in master.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [multistage] Fast-path empty response when all segments pruned at broker [pinot]

Posted by "Akanksha-kedia (via GitHub)" <gi...@apache.org>.
Akanksha-kedia commented on PR #18516:
URL: https://github.com/apache/pinot/pull/18516#issuecomment-4476551494

   @xiangfu0 
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [multistage] Fast-path empty response when all segments pruned at broker [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #18516:
URL: https://github.com/apache/pinot/pull/18516#issuecomment-4477029016

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/18516?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 55.77%. Comparing base ([`2910445`](https://app.codecov.io/gh/apache/pinot/commit/29104455383b5b81581db6098cd9bf34020c64b9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f4f2b8c`](https://app.codecov.io/gh/apache/pinot/commit/f4f2b8c63045d3d800b9d7d07d0c93a72841ef7f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (2910445) and HEAD (f4f2b8c). Click for more details.
   > 
   > <details><summary>HEAD has 16 uploads less than BASE</summary>
   >
   >| Flag | BASE (2910445) | HEAD (f4f2b8c) |
   >|------|------|------|
   >|java-21|5|1|
   >|unittests|2|1|
   >|temurin|5|1|
   >|unittests2|1|0|
   >|integration|3|0|
   >|integration1|1|0|
   >|integration2|1|0|
   >|custom-integration1|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18516      +/-   ##
   ============================================
   - Coverage     63.75%   55.77%   -7.98%     
   + Complexity     1932      815    -1117     
   ============================================
     Files          3292     2561     -731     
     Lines        201470   148532   -52938     
     Branches      31316    24013    -7303     
   ============================================
   - Hits         128442    82842   -45600     
   + Misses        62735    58591    -4144     
   + Partials      10293     7099    -3194     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-21](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.77% <ø> (-7.98%)` | :arrow_down: |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.77% <ø> (-7.98%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.77% <ø> (-7.98%)` | :arrow_down: |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.77% <ø> (-0.03%)` | :arrow_down: |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/18516/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/18516?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [multistage] Fast-path empty response when all segments pruned at broker [pinot]

Posted by "Akanksha-kedia (via GitHub)" <gi...@apache.org>.
Akanksha-kedia commented on PR #18516:
URL: https://github.com/apache/pinot/pull/18516#issuecomment-4661293405

   @xiangfu0 @Jackie-Jiang — friendly ping. This PR adds a fast-path early return in MSE when all segments are pruned at broker, avoiding unnecessary fanout. Would appreciate a review when you have bandwidth.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] [multistage] Fast-path empty response when all segments pruned at broker [pinot]

Posted by "Akanksha-kedia (via GitHub)" <gi...@apache.org>.
Akanksha-kedia closed pull request #18516: [multistage] Fast-path empty response when all segments pruned at broker
URL: https://github.com/apache/pinot/pull/18516


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org