Repository navigation
[MOD-13617] [Agg] Coordinator handle return-strict - #9234
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
94a9a63 to
018020b
Compare
(cherry picked from commit 94a9a63)
c382c6e to
dfe6450
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9234 +/- ##
==========================================
+ Coverage 81.22% 81.27% +0.05%
==========================================
Files 487 492 +5
Lines 66412 66847 +435
Branches 23392 23562 +170
==========================================
+ Hits 53940 54328 +388
- Misses 12234 12280 +46
- Partials 238 239 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Classify the coordinator result-processor chain as trivial when it is exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at most a LIMIT, no sort / group / buffering). Profile queries are excluded because RPProfile wraps each RP. The flag is consumed in a subsequent commit to decide whether the RETURN-STRICT timeout callback may safely drain queued shard replies on the main thread after the background pipeline aborts.
After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut before invoking the pipeline. Handles the narrow race where the RETURN-STRICT timeout callback set the flag and woke the abort channel between our CAS and the first Next() — in that case the timeout callback is already blocked in AREQ_WaitForAggregateResultsComplete and expects to read whatever we store. Skipping the pipeline leaves the stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the main thread will honor.
Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout
callback on the main thread once the background pipeline has aborted
and exited. In this mode rpnetNext:
* skips the wall-clock TimedOut check (the deadline has by
definition already passed); and
* treats an empty channel pop as RS_RESULT_EOF rather than
RS_RESULT_TIMEDOUT.
MRChannel_PopWithTimeout already returns NULL immediately when the
abort flag is set and the channel is empty, so no new channel
primitive is needed - the drain loop simply keeps calling the
existing pop path until it returns EOF.
Safe as a plain bool: set by the main thread only after the
background thread is guaranteed to have exited the pipeline.
When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's accumulation phase and the effective timeout policy is RETURN-STRICT, return TIMEDOUT immediately instead of transitioning to the yield phase and draining the already-buffered results. This matches the behavior already in RPSorter, RPMaxScoreNormalizer, and RPSafeLoader (via their "rc != RS_RESULT_OK" fallthrough which only consumes TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT requires a strict empty-results response on timeout for pipelines that contain buffering result processors.
When the RETURN-STRICT timeout callback observes that the background thread has already claimed the aggregation results, it now waits for the background pipeline to exit (as before) and then — for pipelines classified as trivial (`RPNet -> RPPager -> end`) — resumes the pipeline on the main thread to harvest shard replies that were already queued in the channel before the deadline. The pager's internal `remaining` and `qctx->resultLimit` were both decremented by the background's partial run, so the drain loop naturally respects the user's LIMIT and terminates when either the budget is exhausted or RPNet reports EOF (empty channel under `drainOnly`). `storedReplyState.results` may be NULL in the post-claim bail path (background exited before allocating the results array); the drain allocates a fresh array in that case so downstream serialization has a valid pointer. Non-trivial pipelines are unaffected: the drain is a no-op and the callback continues to reply with whatever the background stored.
be3b485 to
1f34be5
Compare
98a1094 to
06871d1
Compare
Automated performance analysis summaryThis comment was automatically generated given there is performance data available. Environment:
Architecture:
|
| Test Case | Baseline master (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| ftsb-10K-multivalue-numeric-json | 5140 +- 2.0% (14 datapoints) | 7022 | 36.6% | IMPROVEMENT |
| ftsb-10K-enwiki_abstract-hashes-term-prefix | 11256 +- 7.3% (20 datapoints) | 12626 | 12.2% | IMPROVEMENT |
| search-expire-doc-10-milliseconds | 14 +- 1.6% (10 datapoints) | 16 | 10.1% | IMPROVEMENT |
| search-numeric-sortby | 16228 +- 8.2% (20 datapoints) | 17732 | 9.3% | waterline=8.2%. IMPROVEMENT |
Performance Regressions and Issues - Comparison between master and omerl-agg-coord-return-strict.
Time Period from a month ago. (environment used: oss-standalone)
| Test Case | Baseline master (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| search-high-cardinality-negation-term-comparison_union_all_other_terms | 208 +- 17.8% UNSTABLE (20 datapoints) | 157.0 | -24.2% | UNSTABLE (baseline high variance); server: p50 latency stable; client: Latency decreased 20.9% (baseline CV=1.7%); neither server nor client side confirms regression |
| search-numeric | 16200 +- 10.1% UNSTABLE (20 datapoints) | 12370.0 | -23.6% | UNSTABLE (baseline high variance); server: FT.SEARCH p50 decreased 10.8% (baseline CV=19.5%); client: Latency increased 5.6% (baseline CV=4.1%); neither server nor client side confirms regression |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query-non-sortable | 47 +- 26.0% UNSTABLE (20 datapoints) | 36.0 | -23.1% | UNSTABLE (baseline high variance); server: FT.SEARCH p50 increased 5.5% (baseline CV=5.4%); client: client latency stable; neither server nor client side confirms regression |
| search-high-cardinality-negation-term-baseline | 395 +- 17.7% UNSTABLE (20 datapoints) | 304.0 | -22.9% | UNSTABLE (baseline high variance); server: FT.SEARCH p50 decreased 8.0% (baseline CV=19.6%); client: Latency decreased 5.7% (baseline CV=17.5%); neither server nor client side confirms regression |
| search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-one-indexed-field | 13583 +- 5.6% (20 datapoints) | 10505.0 | -22.7% | REGRESSION |
| ftsb-10K-enwiki_abstract-hashes-term-suffix | 13758 +- 4.8% (20 datapoints) | 10701.0 | -22.2% | REGRESSION |
| ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query | 10246 +- 6.2% (20 datapoints) | 8316.0 | -18.8% | REGRESSION |
| search-numeric-optimize | 8847 +- 6.9% (20 datapoints) | 7467.0 | -15.6% | REGRESSION |
| search-expire-doc-1000-seconds | 18 +- 8.7% (13 datapoints) | 15.0 | -14.9% | waterline=8.7%. REGRESSION |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query-non-sortable | 1412 +- 14.1% UNSTABLE (20 datapoints) | 1218.0 | -13.7% | UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression |
| search-ftsb-5200K-docs-union-iterators-q1 | 3.9 +- 5.2% (20 datapoints) | 3.5 | -11.1% | REGRESSION |
| search-expire-numeric-field-1000-seconds | 17 +- 10.9% UNSTABLE (10 datapoints) | 15.0 | -10.8% | UNSTABLE (baseline high variance); server: p50 latency stable; client: Latency increased 6.0% (baseline CV=5.7%); neither server nor client side confirms regression |
| search-numeric-sortby-desc-optimize | 536 +- 9.3% (20 datapoints) | 484.0 | -9.7% | waterline=9.3%. REGRESSION |
| search-numeric-sortby-desc | 17193 +- 7.2% (20 datapoints) | 15647.0 | -9.0% | REGRESSION |
| hybrid-arxiv-titles-384-angular-rrf-text-vector | 1725 +- 37.0% UNSTABLE (8 datapoints) | 1592.0 | -7.7% | UNSTABLE (baseline high variance); server: FT.HYBRID p50 increased 19.3% (baseline CV=36.4%); client: Latency increased 7.9% (baseline CV=28.0%); only server side confirms regression (client side stable) - insufficient evidence |
| hybrid-arxiv-titles-384-angular-linear-numeric-vector | 1695 +- 32.8% UNSTABLE (8 datapoints) | 1581.0 | -6.7% | UNSTABLE (baseline high variance); server: FT.HYBRID p50 increased 16.5% (baseline CV=35.7%); client: Latency increased 11.1% (baseline CV=26.8%); confidence=LOW (FT.HYBRID baseline CV=20.4%; FT.HYBRID p99 +9.0% (stable baseline, minor change); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable)) |
| hybrid-arxiv-titles-384-angular-rrf-tag-range | 4.6 +- 40.5% UNSTABLE (8 datapoints) | 4.5 | -3.0% | UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression |
| hybrid-arxiv-titles-384-angular-linear-text-range | 4.1 +- 20.4% UNSTABLE (8 datapoints) | 4.2 | 1.7% | UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression |
| search-ftsb-1M-enwiki_abstract-hashes-gc | 138 +- 20.4% UNSTABLE (20 datapoints) | 180.0 | 30.1% | UNSTABLE (baseline high variance); server: hset p50 increased 12.4% (baseline CV=9.7%); client: Latency decreased 23.4% (baseline CV=16.9%); only server side confirms regression (client side stable) - insufficient evidence |
Tests with No Significant Changes (30 tests)
Tests with No Significant Changes
| Test Case | Baseline master (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| ftsb-10K-enwiki_abstract-hashes-fulltext-sortby | 1557 +- 4.4% (20 datapoints) | 1518.0 | -2.5% | No Change |
| ftsb-10K-enwiki_abstract-hashes-term-suffix-withsuffixtrie | 16128 +- 4.3% (20 datapoints) | 16553.0 | 2.6% | No Change |
| ftsb-10K-enwiki_abstract-hashes-term-wildcard | 13760 +- 6.5% (20 datapoints) | 14634.0 | 6.4% | potential IMPROVEMENT |
| ftsb-10K-enwiki_pages-hashes-fulltext-mixed_simple-1word-query_write_1_to_read_20.yml | 1695 +- 6.5% (20 datapoints) | 1648.0 | -2.7% | No Change |
| ftsb-10K-enwiki_pages-hashes-load | 65715 +- 8.4% (20 datapoints) | 66754.0 | 1.6% | waterline=8.4%. No Change |
| ftsb-10K-singlevalue-numeric-json | 3006 +- 1.8% (14 datapoints) | 3033.0 | 0.9% | No Change |
| ftsb-1K-enwiki_abstract-hashes-term-contains | 11183 +- 2.5% (20 datapoints) | 11374.0 | 1.7% | No Change |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query | 5570 +- 6.5% (20 datapoints) | 5614.0 | 0.8% | No Change |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query | 11559 +- 6.4% (20 datapoints) | 11914.0 | 3.1% | potential IMPROVEMENT |
| ftsb-1M-enwiki_abstract-hashes-load | 24900 +- 5.7% (20 datapoints) | 24638.0 | -1.1% | No Change |
| ftsb-1M-nyc_taxis-ftadd-load | 33695 +- 5.7% (20 datapoints) | 35823.0 | 6.3% | potential IMPROVEMENT |
| ftsb-1M-nyc_taxis-hashes-load | 34347 +- 4.1% (20 datapoints) | 34527.0 | 0.5% | No Change |
| search-aggregate-post-filter-simple.yml | 17833 +- 5.0% (20 datapoints) | 19172.0 | 7.5% | potential IMPROVEMENT |
| search-expire-numeric-field-10-milliseconds | 16 +- 7.5% (10 datapoints) | 15.0 | -5.9% | potential REGRESSION |
| search-filtering-tag-numeric | 3942 +- 8.5% (20 datapoints) | 3728.0 | -5.4% | waterline=8.5%. potential REGRESSION |
| search-filtering-tag-numeric-filter-pipeline | 11643 +- 5.0% (20 datapoints) | 12085.0 | 3.8% | potential IMPROVEMENT |
| search-ftsb-10K-enwiki_abstract-hashes-fulltext-aggregate-sortby-limit-0-100 | 5702 +- 4.4% (20 datapoints) | 6008.0 | 5.4% | potential IMPROVEMENT |
| search-ftsb-10K-enwiki_abstract-hashes-fulltext-search-sortby-limit-0-100 | 5646 +- 4.4% (20 datapoints) | 5863.0 | 3.8% | potential IMPROVEMENT |
| search-ftsb-10K-enwiki_abstract-hashes-term-withoutsuffix-trie | 13621 +- 4.8% (20 datapoints) | 14304.0 | 5.0% | potential IMPROVEMENT |
| search-ftsb-10K-enwiki_abstract-hashes-term-withsuffix-trie | 13284 +- 7.4% (20 datapoints) | 14214.0 | 7.0% | potential IMPROVEMENT |
| search-ftsb-1700K-docs-union-iterators-q3 | 36 +- 5.5% (20 datapoints) | 36.0 | -1.3% | No Change |
| search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-non-sortable | 179 +- 8.4% (20 datapoints) | 179.0 | 0.0% | waterline=8.4%. No Change |
| search-ftsb-370K-docs-union-iterators-q4 | 37 +- 4.8% (20 datapoints) | 35.0 | -4.7% | potential REGRESSION |
| search-ftsb-5500K-docs-union-iterators-q2 | 5.4 +- 1.9% (14 datapoints) | 5.4 | 1.2% | No Change |
| search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load | 4903 +- 7.2% (20 datapoints) | 5053.0 | 3.1% | potential IMPROVEMENT |
| search-geo | 2698 +- 4.8% (14 datapoints) | 2657.0 | -1.5% | No Change |
| search-numeric-sortby-optimize | 503 +- 9.1% (20 datapoints) | 484.0 | -3.6% | waterline=9.1%. potential REGRESSION |
| vecsim-arxiv-titles-384-angular-filters-m16-ef-128-fulltext-filter | 7402 +- 2.7% (20 datapoints) | 7389.0 | -0.2% | No Change |
| vecsim-arxiv-titles-384-angular-filters-m16-ef-128-numeric-filter | 2622 +- 4.5% (20 datapoints) | 2777.0 | 5.9% | potential IMPROVEMENT |
| vecsim-arxiv-titles-384-angular-filters-m16-ef-128-tag-filter | 15805 +- 6.1% (20 datapoints) | 15816.0 | 0.1% | No Change |
Architecture: aarch64 — branch-over-branch
Deployment: oss-standalone
In summary:
- Detected a total of 44 stable tests between versions.
- Detected a total of 2 highly unstable benchmarks (2 baseline).
You can check a comparison in detail via the grafana link
Performance Regressions and Issues - Comparison between master and omerl-agg-coord-return-strict.
Time Period from a month ago. (environment used: oss-standalone)
| Test Case | Baseline master (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| search-ftsb-1M-enwiki_abstract-hashes-gc | 126 +- 13.0% UNSTABLE (14 datapoints) | 116 | -8.2% | UNSTABLE (baseline high variance); server: hset p50 increased 21.7% (baseline CV=12.3%); client: Latency increased 9.3% (baseline CV=12.8%); only server side confirms regression (client side stable) - insufficient evidence |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query-non-sortable | 35 +- 29.4% UNSTABLE (14 datapoints) | 36 | 4.2% | UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression |
Tests with No Significant Changes (44 tests)
Tests with No Significant Changes
| Test Case | Baseline master (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| ftsb-10K-enwiki_abstract-hashes-fulltext-sortby | 1137 +- 3.6% (14 datapoints) | 1142.0 | 0.4% | No Change |
| ftsb-10K-enwiki_abstract-hashes-term-prefix | 9517 +- 2.1% (14 datapoints) | 9655.0 | 1.4% | No Change |
| ftsb-10K-enwiki_abstract-hashes-term-suffix | 10725 +- 1.5% (14 datapoints) | 10701.0 | -0.2% | No Change |
| ftsb-10K-enwiki_abstract-hashes-term-suffix-withsuffixtrie | 11569 +- 0.7% (14 datapoints) | 11441.0 | -1.1% | No Change |
| ftsb-10K-enwiki_abstract-hashes-term-wildcard | 10872 +- 1.6% (14 datapoints) | 10851.0 | -0.2% | No Change |
| ftsb-10K-enwiki_pages-hashes-fulltext-mixed_simple-1word-query_write_1_to_read_20.yml | 1620 +- 2.4% (14 datapoints) | 1648.0 | 1.7% | No Change |
| ftsb-10K-enwiki_pages-hashes-load | 57565 +- 4.3% (14 datapoints) | 61929.0 | 7.6% | potential IMPROVEMENT |
| ftsb-10K-multivalue-numeric-json | 5140 +- 2.0% (14 datapoints) | 5071.0 | -1.4% | No Change |
| ftsb-10K-singlevalue-numeric-json | 3006 +- 1.8% (14 datapoints) | 3033.0 | 0.9% | No Change |
| ftsb-1K-enwiki_abstract-hashes-term-contains | 9116 +- 1.5% (14 datapoints) | 9222.0 | 1.2% | No Change |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query | 4340 +- 4.8% (14 datapoints) | 4479.0 | 3.2% | potential IMPROVEMENT |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query | 9542 +- 1.7% (14 datapoints) | 9613.0 | 0.7% | No Change |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query-non-sortable | 1225 +- 7.7% (14 datapoints) | 1218.0 | -0.6% | No Change |
| ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query | 8111 +- 2.8% (14 datapoints) | 8316.0 | 2.5% | No Change |
| ftsb-1M-enwiki_abstract-hashes-load | 22660 +- 3.6% (14 datapoints) | 23276.0 | 2.7% | No Change |
| ftsb-1M-nyc_taxis-ftadd-load | 26106 +- 2.9% (14 datapoints) | 26927.0 | 3.1% | potential IMPROVEMENT |
| ftsb-1M-nyc_taxis-hashes-load | 27402 +- 2.5% (14 datapoints) | 27728.0 | 1.2% | No Change |
| search-aggregate-post-filter-simple.yml | 12600 +- 1.2% (14 datapoints) | 12652.0 | 0.4% | No Change |
| search-expire-doc-10-milliseconds | 14 +- 1.6% (10 datapoints) | 14.0 | -2.1% | No Change |
| search-expire-doc-1000-seconds | 14 +- 2.5% (10 datapoints) | 14.0 | 0.6% | No Change |
| search-expire-numeric-field-10-milliseconds | 14 +- 3.2% (10 datapoints) | 15.0 | 2.6% | No Change |
| search-expire-numeric-field-1000-seconds | 14 +- 1.9% (10 datapoints) | 14.0 | -3.9% | potential REGRESSION |
| search-filtering-tag-numeric | 3521 +- 9.5% (14 datapoints) | 3653.0 | 3.8% | waterline=9.5%. potential IMPROVEMENT |
| search-filtering-tag-numeric-filter-pipeline | 9305 +- 1.1% (14 datapoints) | 9316.0 | 0.1% | No Change |
| search-ftsb-10K-enwiki_abstract-hashes-fulltext-aggregate-sortby-limit-0-100 | 4952 +- 1.4% (14 datapoints) | 5016.0 | 1.3% | No Change |
| search-ftsb-10K-enwiki_abstract-hashes-fulltext-search-sortby-limit-0-100 | 4922 +- 2.8% (14 datapoints) | 4969.0 | 0.9% | No Change |
| search-ftsb-10K-enwiki_abstract-hashes-term-withoutsuffix-trie | 10332 +- 1.1% (14 datapoints) | 10561.0 | 2.2% | No Change |
| search-ftsb-10K-enwiki_abstract-hashes-term-withsuffix-trie | 10315 +- 0.9% (14 datapoints) | 10442.0 | 1.2% | No Change |
| search-ftsb-1700K-docs-union-iterators-q3 | 32 +- 1.2% (14 datapoints) | 32.0 | -1.2% | No Change |
| search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-non-sortable | 164 +- 5.1% (14 datapoints) | 173.0 | 5.4% | potential IMPROVEMENT |
| search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-one-indexed-field | 10366 +- 1.6% (14 datapoints) | 10505.0 | 1.3% | No Change |
| search-ftsb-370K-docs-union-iterators-q4 | 33 +- 1.0% (14 datapoints) | 33.0 | -1.2% | No Change |
| search-ftsb-5200K-docs-union-iterators-q1 | 3.5 +- 1.8% (14 datapoints) | 3.5 | -1.4% | No Change |
| search-ftsb-5500K-docs-union-iterators-q2 | 5.4 +- 1.9% (14 datapoints) | 5.4 | 1.2% | No Change |
| search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load | 3659 +- 5.4% (14 datapoints) | 3563.0 | -2.6% | No Change |
| search-geo | 2698 +- 4.8% (14 datapoints) | 2657.0 | -1.5% | No Change |
| search-high-cardinality-negation-term-baseline | 309 +- 1.2% (14 datapoints) | 304.0 | -1.6% | No Change |
| search-high-cardinality-negation-term-comparison_union_all_other_terms | 159 +- 1.8% (14 datapoints) | 157.0 | -0.9% | No Change |
| search-numeric | 13062 +- 4.0% (14 datapoints) | 12370.0 | -5.3% | potential REGRESSION |
| search-numeric-optimize | 7414 +- 0.8% (14 datapoints) | 7467.0 | 0.7% | No Change |
| search-numeric-sortby | 12495 +- 3.5% (14 datapoints) | 12063.0 | -3.5% | potential REGRESSION |
| search-numeric-sortby-desc | 12228 +- 4.2% (14 datapoints) | 12973.0 | 6.1% | potential IMPROVEMENT |
| search-numeric-sortby-desc-optimize | 482 +- 5.9% (14 datapoints) | 482.0 | -0.1% | No Change |
| search-numeric-sortby-optimize | 475 +- 6.3% (14 datapoints) | 484.0 | 2.0% | No Change |
Cross-arch delta on omerl-agg-coord-return-strict (x86_64 → aarch64)
Same commit (
omerl-agg-coord-return-strict) compared across architectures. Positive deltas =aarch64outperformsx86_64.
In summary:
- Detected a total of 21 stable tests between versions.
- Detected a total of 7 highly unstable benchmarks (7 baseline).
- Latency analysis confirmed regressions in 3 of the unstable tests:
- ftsb-10K-multivalue-numeric-json: FT.SEARCH +49.0% 🔴
- search-ftsb-1M-enwiki_abstract-hashes-gc: hset +55.3%
⚠️ - search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load: json.set +36.2% 🔴
- Detected a total of 18 regressions bellow the regression water line 8.0%.
You can check a comparison in detail via the grafana link
Performance Regressions and Issues - Comparison between omerl-agg-coord-return-strict and omerl-agg-coord-return-strict.
Time Period from a month ago. (environment used: oss-standalone)
| Test Case | Baseline omerl-agg-coord-return-strict (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| search-aggregate-post-filter-simple.yml | 17650 +- 9.3% (10 datapoints) | 12652 | -28.3% | waterline=9.3%. REGRESSION |
| search-ftsb-arxiv-titles-384-angular-filters-m16-ef-128-json-load | 4915 +- 10.4% UNSTABLE (10 datapoints) | 3563 | -27.5% | UNSTABLE (baseline high variance); server: json.set p50 increased 36.2% (baseline CV=10.7%); client: OverallQuantiles.allCommands.q50 increased 39.5% (baseline CV=11.3%); confidence=HIGH (json.set baseline CV=9.4%; json.set p99 +23.9% (stable baseline); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable)) |
| ftsb-10K-enwiki_abstract-hashes-term-suffix-withsuffixtrie | 15509 +- 7.1% (10 datapoints) | 11441 | -26.2% | REGRESSION |
| ftsb-10K-multivalue-numeric-json | 6760 +- 10.0% UNSTABLE (10 datapoints) | 5071 | -25.0% | UNSTABLE (baseline high variance); server: FT.SEARCH p50 increased 49.0% (baseline CV=13.6%); client: OverallQuantiles.allCommands.q50 increased 38.5% (baseline CV=11.7%); confidence=HIGH (FT.SEARCH baseline CV=8.5%; FT.SEARCH p99 +23.6% (stable baseline); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable)) |
| search-numeric-sortby | 16056 +- 10.9% UNSTABLE (10 datapoints) | 12063 | -24.9% | UNSTABLE (baseline high variance); server: FT.SEARCH p50 increased 56.6% (baseline CV=18.2%); client: client latency stable; only server side confirms regression (client side stable) - insufficient evidence |
| ftsb-10K-enwiki_abstract-hashes-fulltext-sortby | 1517 +- 2.6% (10 datapoints) | 1142 | -24.7% | REGRESSION |
| search-ftsb-1M-enwiki_abstract-hashes-gc | 151 +- 17.9% UNSTABLE (10 datapoints) | 116 | -23.1% | UNSTABLE (baseline high variance); server: hset p50 increased 55.3% (baseline CV=11.3%); client: Latency increased 30.2% (baseline CV=18.0%); confidence=LOW (hset baseline CV=5.7%; hset p99 0.0% (stable baseline, minor change); CV=coefficient of variation (data stability: <30% stable, 30-50% moderate, >50% unstable)) |
| search-ftsb-10K-enwiki_abstract-hashes-term-withsuffix-trie | 13367 +- 7.9% (10 datapoints) | 10442 | -21.9% | REGRESSION |
| ftsb-10K-enwiki_abstract-hashes-term-wildcard | 13805 +- 6.9% (10 datapoints) | 10851 | -21.4% | REGRESSION |
| search-ftsb-10K-enwiki_abstract-hashes-term-withoutsuffix-trie | 13439 +- 10.4% UNSTABLE (10 datapoints) | 10561 | -21.4% | UNSTABLE (baseline high variance); server: FT.SEARCH p50 decreased 20.0% (baseline CV=27.4%); client: Latency increased 50.0% (baseline CV=16.6%); only client side confirms regression (server side stable) - insufficient evidence |
| search-numeric-sortby-desc | 16491 +- 7.7% (10 datapoints) | 12973 | -21.3% | REGRESSION |
| ftsb-1M-nyc_taxis-hashes-load | 34459 +- 6.3% (10 datapoints) | 27728 | -19.5% | REGRESSION |
| ftsb-1M-nyc_taxis-ftadd-load | 33363 +- 8.8% (10 datapoints) | 26927 | -19.3% | waterline=8.8%. REGRESSION |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query | 5435 +- 4.7% (10 datapoints) | 4479 | -17.6% | REGRESSION |
| ftsb-1K-enwiki_abstract-hashes-term-contains | 11138 +- 4.4% (10 datapoints) | 9222 | -17.2% | REGRESSION |
| search-filtering-tag-numeric-filter-pipeline | 11248 +- 10.3% UNSTABLE (11 datapoints) | 9316 | -17.2% | UNSTABLE (baseline high variance); server: FT.AGGREGATE p50 decreased 30.0% (baseline CV=20.5%); client: client latency stable; neither server nor client side confirms regression |
| ftsb-10K-enwiki_abstract-hashes-term-prefix | 11613 +- 8.4% (10 datapoints) | 9655 | -16.9% | waterline=8.4%. REGRESSION |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query | 11452 +- 6.5% (10 datapoints) | 9613 | -16.1% | REGRESSION |
| search-ftsb-10K-enwiki_abstract-hashes-fulltext-aggregate-sortby-limit-0-100 | 5663 +- 7.8% (10 datapoints) | 5016 | -11.4% | REGRESSION |
| search-expire-doc-10-milliseconds | 16 +- 9.3% (5 datapoints) | 14 | -11.1% | waterline=9.3%. REGRESSION |
| search-ftsb-10K-enwiki_abstract-hashes-fulltext-search-sortby-limit-0-100 | 5563 +- 7.2% (10 datapoints) | 4969 | -10.7% | REGRESSION |
| search-expire-numeric-field-1000-seconds | 15 +- 8.2% (5 datapoints) | 14 | -9.6% | waterline=8.2%. REGRESSION |
| search-expire-doc-1000-seconds | 16 +- 7.1% (5 datapoints) | 14 | -8.5% | REGRESSION |
| search-ftsb-1700K-docs-union-iterators-q3 | 35 +- 4.8% (11 datapoints) | 32 | -8.3% | REGRESSION |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-intersection-query-non-sortable | 36 +- 22.3% UNSTABLE (5 datapoints) | 36 | 0.0% | UNSTABLE (baseline high variance); server: p50 latency stable; client: client latency stable; neither server nor client side confirms regression |
Tests with No Significant Changes (21 tests)
Tests with No Significant Changes
| Test Case | Baseline omerl-agg-coord-return-strict (median obs. +- std.dev) | Comparison omerl-agg-coord-return-strict (median obs. +- std.dev) | % change (higher-better) | Note |
|---|---|---|---|---|
| ftsb-10K-enwiki_abstract-hashes-term-suffix | 10707 +- 1.1% (5 datapoints) | 10701.0 | -0.1% | No Change |
| ftsb-10K-enwiki_pages-hashes-fulltext-mixed_simple-1word-query_write_1_to_read_20.yml | 1569 +- 4.2% (5 datapoints) | 1648.0 | 5.0% | potential IMPROVEMENT |
| ftsb-10K-enwiki_pages-hashes-load | 66534 +- 7.1% (10 datapoints) | 61929.0 | -6.9% | potential REGRESSION |
| ftsb-10K-singlevalue-numeric-json | 3007 +- 1.3% (5 datapoints) | 3033.0 | 0.9% | No Change |
| ftsb-1M-enwiki_abstract-hashes-fulltext-2word-union-query-non-sortable | 1218 +- 5.1% (5 datapoints) | 1218.0 | 0.0% | |
| ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query | 7896 +- 4.4% (5 datapoints) | 8316.0 | 5.3% | potential IMPROVEMENT |
| ftsb-1M-enwiki_abstract-hashes-load | 23715 +- 6.6% (10 datapoints) | 23276.0 | -1.9% | No Change |
| search-expire-numeric-field-10-milliseconds | 14 +- 2.4% (5 datapoints) | 15.0 | 3.9% | potential IMPROVEMENT |
| search-filtering-tag-numeric | 3729 +- 8.8% (11 datapoints) | 3653.0 | -2.0% | waterline=8.8%. No Change |
| search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-non-sortable | 169 +- 9.3% (10 datapoints) | 173.0 | 2.1% | waterline=9.3%. No Change |
| search-ftsb-1M-enwiki_abstract-hashes-fulltext-simple-1word-query-one-indexed-field | 10402 +- 1.4% (5 datapoints) | 10505.0 | 1.0% | No Change |
| search-ftsb-370K-docs-union-iterators-q4 | 35 +- 1.2% (10 datapoints) | 33.0 | -6.2% | potential REGRESSION |
| search-ftsb-5200K-docs-union-iterators-q1 | 3.5 +- 0.8% (5 datapoints) | 3.5 | -1.4% | No Change |
| search-ftsb-5500K-docs-union-iterators-q2 | 5.4 +- 1.6% (5 datapoints) | 5.4 | -0.2% | No Change |
| search-geo | 2622 +- 2.2% (5 datapoints) | 2657.0 | 1.3% | No Change |
| search-high-cardinality-negation-term-baseline | 296 +- 1.4% (5 datapoints) | 304.0 | 2.6% | No Change |
| search-high-cardinality-negation-term-comparison_union_all_other_terms | 156 +- 1.0% (5 datapoints) | 157.0 | 1.0% | No Change |
| search-numeric | 12920 +- 3.7% (5 datapoints) | 12370.0 | -4.3% | potential REGRESSION |
| search-numeric-optimize | 7430 +- 0.6% (5 datapoints) | 7467.0 | 0.5% | No Change |
| search-numeric-sortby-desc-optimize | 510 +- 7.2% (10 datapoints) | 482.0 | -5.5% | potential REGRESSION |
| search-numeric-sortby-optimize | 468 +- 6.8% (5 datapoints) | 484.0 | 3.6% | potential IMPROVEMENT |
| if (!abstimeMono) { | ||
| return MRChannel_Pop(chan); | ||
| } | ||
| void *MRChannel_PopWithTimeout(MRChannel *chan, const struct timespec *abstimeMono, |
There was a problem hiding this comment.
consider asserting the pointers are not NULL, if we don't need this variants
| return NULL; | ||
| } | ||
| } else { | ||
| pthread_cond_wait(&chan->cond, &chan->lock); |
There was a problem hiding this comment.
redundant (we have MRChannel_Pop for that)
| qctx->endProc && qctx->endProc->type == RP_PAGER_LIMITER && | ||
| qctx->endProc->upstream == qctx->rootProc; |
There was a problem hiding this comment.
lets make it clear that the cases we handle are
- last is pager, and its upstream is the RPNet
- The last is the RPNet
| return; | ||
| } | ||
|
|
||
| RPNet *rpnet = (RPNet *)qctx->rootProc; |
There was a problem hiding this comment.
consider asserting the type
| // Set post-construction on the coordinator AREQ. Used by the RETURN-STRICT | ||
| // timeout path to drain queued shard replies on the main thread after the | ||
| // background pipeline has aborted. | ||
| bool yieldsPartialResults; |
There was a problem hiding this comment.
Consider renaming "canYield...` or something similar
| if (self->last_rc == RS_RESULT_TIMEDOUT && | ||
| base->parent->timeoutPolicy == TimeoutPolicy_ReturnStrict) { |
There was a problem hiding this comment.
Shouldn't fail behave the same way?
There was a problem hiding this comment.
BUG, will backport the fix
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 84f5c97. Configure here.
| #define SYNC_POINT_AFTER_ITERATOR_CREATE "AfterIteratorCreate" | ||
| #define SYNC_POINT_BEFORE_FIRST_READ "BeforeFirstRead" | ||
| #define SYNC_POINT_BEFORE_DIST_HYBRID_PROMOTE "BeforeDistHybridPromote" | ||
| #define SYNC_POINT_BEFORE_SPEC_LOCK "BeforeSpecLock" | ||
| #define SYNC_POINT_BEFORE_CURSOR_READ_SEND_CHUNK "BeforeCursorReadSendChunk" |
|
RPSorter (rpsortNext_innerLoop) now handles all three timeout policies
explicitly:
- FAIL: propagate TIMEDOUT in O(1) (no yield transition).
- RETURN: existing behavior (switch to yield, surface buffered rows).
- RETURN_STRICT: switch to yield (so the main-thread drain can pop the
buffered, sorted prefix) and propagate TIMEDOUT immediately so the BG
abort path is not delayed by per-row yields.
pipelineCanYieldPartialResults is consolidated from a per-shape boolean
enumeration to a peel chain: optional RPPager_Limiter, optional RPSorter,
then RPNet root. Adds the two SORTBY shapes (RPSorter -> RPNet and
RPPager_Limiter -> RPSorter -> RPNet) without changing behavior for the
shapes already supported in #9234.
Adds three pytest cases mirroring the trivial-pipeline coverage:
SORTBY one-shard-paused (sync-pointed for exact partial count),
all-shards-paused, and post-store.
…o SORTBY pipelines (RediSearch#9366) * Setup callback and mechanism * Implement Abort Channel Pop + Use (cherry picked from commit 94a9a63) * Add test for no-tail Case * Expand * Cover before RPNET * Remove timeout check from RETURN polcy * refactor comments * Reset claim of aggregate results * Make test more accurate and robust * Add isTrivialPipeline classifier on coordinator Classify the coordinator result-processor chain as trivial when it is exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at most a LIMIT, no sort / group / buffering). Profile queries are excluded because RPProfile wraps each RP. The flag is consumed in a subsequent commit to decide whether the RETURN-STRICT timeout callback may safely drain queued shard replies on the main thread after the background pipeline aborts. * startPipeline: bail post-claim when already timed out After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut before invoking the pipeline. Handles the narrow race where the RETURN-STRICT timeout callback set the flag and woke the abort channel between our CAS and the first Next() — in that case the timeout callback is already blocked in AREQ_WaitForAggregateResultsComplete and expects to read whatever we store. Skipping the pipeline leaves the stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the main thread will honor. * Add drainOnly mode to RPNet Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout callback on the main thread once the background pipeline has aborted and exited. In this mode rpnetNext: * skips the wall-clock TimedOut check (the deadline has by definition already passed); and * treats an empty channel pop as RS_RESULT_EOF rather than RS_RESULT_TIMEDOUT. MRChannel_PopWithTimeout already returns NULL immediately when the abort flag is set and the channel is empty, so no new channel primitive is needed - the drain loop simply keeps calling the existing pop path until it returns EOF. Safe as a plain bool: set by the main thread only after the background thread is guaranteed to have exited the pipeline. * RPDepleter: O(1) TIMEDOUT abort under RETURN-STRICT When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's accumulation phase and the effective timeout policy is RETURN-STRICT, return TIMEDOUT immediately instead of transitioning to the yield phase and draining the already-buffered results. This matches the behavior already in RPSorter, RPMaxScoreNormalizer, and RPSafeLoader (via their "rc != RS_RESULT_OK" fallthrough which only consumes TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT requires a strict empty-results response on timeout for pipelines that contain buffering result processors. * Coordinator: drain trivial pipelines on main after timeout When the RETURN-STRICT timeout callback observes that the background thread has already claimed the aggregation results, it now waits for the background pipeline to exit (as before) and then — for pipelines classified as trivial (`RPNet -> RPPager -> end`) — resumes the pipeline on the main thread to harvest shard replies that were already queued in the channel before the deadline. The pager's internal `remaining` and `qctx->resultLimit` were both decremented by the background's partial run, so the drain loop naturally respects the user's LIMIT and terminates when either the budget is exhausted or RPNet reports EOF (empty channel under `drainOnly`). `storedReplyState.results` may be NULL in the post-claim bail path (background exited before allocating the results array); the drain allocates a fresh array in that case so downstream serialization has a valid pointer. Non-trivial pipelines are unaffected: the drain is a no-op and the callback continues to reply with whatever the background stored. * Improve + Tests * cursor comment * Improve * More fixes * Review comment fixes * Use the new SyncPointfunctionality * Fix no results * Fix format * MOD-13617: extend RETURN_STRICT partial results to SORTBY pipelines RPSorter (rpsortNext_innerLoop) now handles all three timeout policies explicitly: - FAIL: propagate TIMEDOUT in O(1) (no yield transition). - RETURN: existing behavior (switch to yield, surface buffered rows). - RETURN_STRICT: switch to yield (so the main-thread drain can pop the buffered, sorted prefix) and propagate TIMEDOUT immediately so the BG abort path is not delayed by per-row yields. pipelineCanYieldPartialResults is consolidated from a per-shape boolean enumeration to a peel chain: optional RPPager_Limiter, optional RPSorter, then RPNet root. Adds the two SORTBY shapes (RPSorter -> RPNet and RPPager_Limiter -> RPSorter -> RPNet) without changing behavior for the shapes already supported in RediSearch#9234. Adds three pytest cases mirroring the trivial-pipeline coverage: SORTBY one-shard-paused (sync-pointed for exact partial count), all-shards-paused, and post-store. * MOD-13617: WIP add APPLY+SORTBY tests for partial results * Update tests * Merge * Shorten Comments * Fix
* Setup callback and mechanism * Implement Abort Channel Pop + Use (cherry picked from commit 94a9a63) * Add test for no-tail Case * Expand * Cover before RPNET * Remove timeout check from RETURN polcy * refactor comments * Reset claim of aggregate results * Make test more accurate and robust * Add isTrivialPipeline classifier on coordinator Classify the coordinator result-processor chain as trivial when it is exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at most a LIMIT, no sort / group / buffering). Profile queries are excluded because RPProfile wraps each RP. The flag is consumed in a subsequent commit to decide whether the RETURN-STRICT timeout callback may safely drain queued shard replies on the main thread after the background pipeline aborts. * startPipeline: bail post-claim when already timed out After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut before invoking the pipeline. Handles the narrow race where the RETURN-STRICT timeout callback set the flag and woke the abort channel between our CAS and the first Next() — in that case the timeout callback is already blocked in AREQ_WaitForAggregateResultsComplete and expects to read whatever we store. Skipping the pipeline leaves the stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the main thread will honor. * Add drainOnly mode to RPNet Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout callback on the main thread once the background pipeline has aborted and exited. In this mode rpnetNext: * skips the wall-clock TimedOut check (the deadline has by definition already passed); and * treats an empty channel pop as RS_RESULT_EOF rather than RS_RESULT_TIMEDOUT. MRChannel_PopWithTimeout already returns NULL immediately when the abort flag is set and the channel is empty, so no new channel primitive is needed - the drain loop simply keeps calling the existing pop path until it returns EOF. Safe as a plain bool: set by the main thread only after the background thread is guaranteed to have exited the pipeline. * RPDepleter: O(1) TIMEDOUT abort under RETURN-STRICT When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's accumulation phase and the effective timeout policy is RETURN-STRICT, return TIMEDOUT immediately instead of transitioning to the yield phase and draining the already-buffered results. This matches the behavior already in RPSorter, RPMaxScoreNormalizer, and RPSafeLoader (via their "rc != RS_RESULT_OK" fallthrough which only consumes TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT requires a strict empty-results response on timeout for pipelines that contain buffering result processors. * Coordinator: drain trivial pipelines on main after timeout When the RETURN-STRICT timeout callback observes that the background thread has already claimed the aggregation results, it now waits for the background pipeline to exit (as before) and then — for pipelines classified as trivial (`RPNet -> RPPager -> end`) — resumes the pipeline on the main thread to harvest shard replies that were already queued in the channel before the deadline. The pager's internal `remaining` and `qctx->resultLimit` were both decremented by the background's partial run, so the drain loop naturally respects the user's LIMIT and terminates when either the budget is exhausted or RPNet reports EOF (empty channel under `drainOnly`). `storedReplyState.results` may be NULL in the post-claim bail path (background exited before allocating the results array); the drain allocates a fresh array in that case so downstream serialization has a valid pointer. Non-trivial pipelines are unaffected: the drain is a no-op and the callback continues to reply with whatever the background stored. * Improve + Tests * cursor comment * Improve * More fixes * Review comment fixes * Use the new SyncPointfunctionality * Fix no results * Fix format
…o SORTBY pipelines (RediSearch#9366) * Setup callback and mechanism * Implement Abort Channel Pop + Use (cherry picked from commit 94a9a63) * Add test for no-tail Case * Expand * Cover before RPNET * Remove timeout check from RETURN polcy * refactor comments * Reset claim of aggregate results * Make test more accurate and robust * Add isTrivialPipeline classifier on coordinator Classify the coordinator result-processor chain as trivial when it is exactly RPNet -> RPPager_Limiter -> end (i.e. a plain query with at most a LIMIT, no sort / group / buffering). Profile queries are excluded because RPProfile wraps each RP. The flag is consumed in a subsequent commit to decide whether the RETURN-STRICT timeout callback may safely drain queued shard replies on the main thread after the background pipeline aborts. * startPipeline: bail post-claim when already timed out After a successful AREQ_TryClaimAggregateResults, re-check AREQ_TimedOut before invoking the pipeline. Handles the narrow race where the RETURN-STRICT timeout callback set the flag and woke the abort channel between our CAS and the first Next() — in that case the timeout callback is already blocked in AREQ_WaitForAggregateResultsComplete and expects to read whatever we store. Skipping the pipeline leaves the stored state with zero results and rc=RS_RESULT_TIMEDOUT, which the main thread will honor. * Add drainOnly mode to RPNet Add a drainOnly flag on RPNet, set by the RETURN-STRICT timeout callback on the main thread once the background pipeline has aborted and exited. In this mode rpnetNext: * skips the wall-clock TimedOut check (the deadline has by definition already passed); and * treats an empty channel pop as RS_RESULT_EOF rather than RS_RESULT_TIMEDOUT. MRChannel_PopWithTimeout already returns NULL immediately when the abort flag is set and the channel is empty, so no new channel primitive is needed - the drain loop simply keeps calling the existing pop path until it returns EOF. Safe as a plain bool: set by the main thread only after the background thread is guaranteed to have exited the pipeline. * RPDepleter: O(1) TIMEDOUT abort under RETURN-STRICT When the upstream signals RS_RESULT_TIMEDOUT during RPDepleter's accumulation phase and the effective timeout policy is RETURN-STRICT, return TIMEDOUT immediately instead of transitioning to the yield phase and draining the already-buffered results. This matches the behavior already in RPSorter, RPMaxScoreNormalizer, and RPSafeLoader (via their "rc != RS_RESULT_OK" fallthrough which only consumes TimeoutPolicy_Return on the yield-transition path). RETURN-STRICT requires a strict empty-results response on timeout for pipelines that contain buffering result processors. * Coordinator: drain trivial pipelines on main after timeout When the RETURN-STRICT timeout callback observes that the background thread has already claimed the aggregation results, it now waits for the background pipeline to exit (as before) and then — for pipelines classified as trivial (`RPNet -> RPPager -> end`) — resumes the pipeline on the main thread to harvest shard replies that were already queued in the channel before the deadline. The pager's internal `remaining` and `qctx->resultLimit` were both decremented by the background's partial run, so the drain loop naturally respects the user's LIMIT and terminates when either the budget is exhausted or RPNet reports EOF (empty channel under `drainOnly`). `storedReplyState.results` may be NULL in the post-claim bail path (background exited before allocating the results array); the drain allocates a fresh array in that case so downstream serialization has a valid pointer. Non-trivial pipelines are unaffected: the drain is a no-op and the callback continues to reply with whatever the background stored. * Improve + Tests * cursor comment * Improve * More fixes * Review comment fixes * Use the new SyncPointfunctionality * Fix no results * Fix format * MOD-13617: extend RETURN_STRICT partial results to SORTBY pipelines RPSorter (rpsortNext_innerLoop) now handles all three timeout policies explicitly: - FAIL: propagate TIMEDOUT in O(1) (no yield transition). - RETURN: existing behavior (switch to yield, surface buffered rows). - RETURN_STRICT: switch to yield (so the main-thread drain can pop the buffered, sorted prefix) and propagate TIMEDOUT immediately so the BG abort path is not delayed by per-row yields. pipelineCanYieldPartialResults is consolidated from a per-shape boolean enumeration to a peel chain: optional RPPager_Limiter, optional RPSorter, then RPNet root. Adds the two SORTBY shapes (RPSorter -> RPNet and RPPager_Limiter -> RPSorter -> RPNet) without changing behavior for the shapes already supported in RediSearch#9234. Adds three pytest cases mirroring the trivial-pipeline coverage: SORTBY one-shard-paused (sync-pointed for exact partial count), all-shards-paused, and post-store. * MOD-13617: WIP add APPLY+SORTBY tests for partial results * Update tests * Merge * Shorten Comments * Fix





Wires coordinator-level
FT.AGGREGATEonto theON_TIMEOUT RETURN_STRICTpath: on a blocked-client timeout, the coordinator returns whatever shard results have already been admitted through a strictly-streaming pipeline, plus atimeoutwarning, instead of failing the query. Mirrors theFT.SEARCHcounterpart shipped in MOD-13831 (#8236) and builds on theFT.AGGREGATEFAILwiring from MOD-14086 (#8752).Parent epic: MOD-8477 Revisit and improve the query engine timeout mechanism.
Why
RETURN_STRICTguarantees the user-requested timeout is honored end-to-end while still surfacing any partial results the pipeline has already accumulated, provided those partial results are valid answers to the query. Before this PR, coordinatorFT.AGGREGATEonly supportedFAILon the blocked-client path.Design
Two concurrent actors, one reply, classified by pipeline shape:
timeout_callback(DistAggregateTimeoutReturnStrictClient). Once entered, it owns the reply (perdocs/redis-blocking-client-internals.md: aftertimeout_callbackfires,bc->clientisNULL, soreply_callbackis skipped).RS_RESULT_TIMEDOUTupward, stores whatever the pipeline has produced so far, and signals the main thread.Pipeline classification:
yieldsPartialResultsThe coordinator pipeline is classified as yielding partial results iff its shape is exactly
RPNet → RPPager_Limiter → end— every admitted row is a final, unmodified shard row, so any prefix of the output is a valid (incomplete) answer. The classifierpipelineYieldsPartialResults(AREQ*)is called at the end ofbuildDistRPChain; the resulting flag lives onQueryProcessingCtx.yieldsPartialResults. Profile is excluded for now (RPProfile wraps every RP and isn't yet supported under the drain path).Future operators that gain partial-correctness (e.g. an incremental sorter that emits ordered batches as input arrives) join this set without renaming — the field describes a semantic property, not a structural shape.
Two protocols, by class:
yieldsPartialResults == true→ drain. After BG aborts and signals, the main thread enablesRPNet.drainOnly = trueand pulls remaining queued shard replies viaendProc->Nextdirectly.drainOnlymode pops non-blocking and maps timeouts toRS_RESULT_EOF. The pager'sremainingandqctx->resultLimithonor the user'sLIMITnaturally. Reply: partial rows +total_results+timeoutwarning.yieldsPartialResults == false→ discard. Buffering operators (RPSorter, RPGroup, RPDepleter) propagateRS_RESULT_TIMEDOUTin O(1) underRETURN_STRICTand drop any rows they had buffered — emitting a "sorted prefix" or partial group counts would be structurally incorrect, not just incomplete. The reply path zeroesqctx->totalResultsto keeptotal_resultsconsistent withresults: [], then calls the standardAREQ_ReplyWithStoredResults. Reply:results: []+total_results: 0+timeoutwarning.Three-region timeout model:
The CAS handshake (
AREQ_TryClaimAggregateResults) splits BG execution into three regions, each handled differently when the timeout fires:TimedOutcheckcoord_aggregate_query_reply_empty(empty + warning)WakeAbortChannel→ BG returnsTIMEDOUTfromgetNextReply, runs discard/store path, signalsAREQ_ReplyWithStoredResults+ (drain foryieldsPartialResults, zero-total_resultsfor the discard class)WaitForAggregateResultsComplete; BG signal releases itAREQ_ReplyWithStoredResults(full or partial set)Synchronization primitives (
RequestSyncCtxonAREQ):requiresAggregateResultsSync— gate (set whentimeoutPolicy == RETURN_STRICT; temporary until shard-level lands).aggregatingResults(atomic) — CAS claim flag. BG winner runs the pipeline and stores results; timeout-callback winner preempts BG and replies empty.aggregateResultsDone+aggregateResultsLock+aggregateResultsCond— completion signal; the loser parks here until the winner finishes.abortWakeChannel+abortWakeLock— single-slot registration so the main thread can wake BG out of a blockingMRChannel_Popwhen a shard is unresponsive.Implementation
1. Synchronization scaffolding (
src/aggregate/aggregate.h,src/aggregate/aggregate_request.c,src/aggregate/aggregate_exec.c,src/coord/dist_aggregate.c,src/module.c)RequestSyncCtxfields andRequestSyncCtx_Init/_Destroy; destroy is wired into bothAREQ_FreeandHybridRequest_Freefor reuse.AREQ_TryClaimAggregateResults,AREQ_SignalAggregateResultsComplete,AREQ_WaitForAggregateResultsComplete,AREQ_ResetAggregateResultsClaim(the last one allows cursor chunks to re-enter the protocol).startPipelinegate: ifrequiresAggregateResultsSyncand CAS loses, BG exits early; otherwise BG runsstartPipelineCommonand unconditionally signals on exit (even on error — the loser must never stick).DistAggregateTimeoutReturnStrictClient: underCoordRequestCtx'ssetReqLock→SetTimedOut→ fetch AREQ → wake the abort channel; if no request or CAS wins, reply empty withTIMED_OUTwarning; otherwise wait for BG's signal, rundrainPartialResultsAfterTimeout(no-op for non-yielding pipelines), then reply fromstoredReplyStateviaAREQ_ReplyWithStoredResults(zeroingtotalResultsfirst if the pipeline doesn't yield partial results and the buffer ended up empty).DistAggregateCommandImppicks the timeout callback by policy (FAIL→ existingDistAggregateTimeoutFailClient;RETURN_STRICT→ new callback). The reply callback is shared —ChunkReplyStateis policy-agnostic.2. Pipeline classification + drain mode (
src/coord/dist_aggregate.c,src/coord/rpnet.{h,c},src/result_processor.h)pipelineYieldsPartialResults(AREQ*)— structural classifier; called at the end ofbuildDistRPChainto setqctx->yieldsPartialResults.RPNet.drainOnly— plainbool(set by main thread after BG has exited the pipeline; no concurrent reader).rpnetNextchecks it on every entry: pop non-blocking, map any timeout signal toRS_RESULT_EOF.drainPartialResultsAfterTimeout(AREQ*)— main-thread helper. Early-returns ifyieldsPartialResults == false. Otherwise setsdrainOnly, then loopsendProc->NextuntilresultLimitis exhausted orNextstops returningOK, appending tostoredReplyState.results.3. Buffering-operator timeout discard (
src/result_processor.c)RPDepleter_Next_Accumulate: afterRPDepleter_Depletereturns, iflast_rc == RS_RESULT_TIMEDOUT && timeoutPolicy == TimeoutPolicy_ReturnStrict, returnRS_RESULT_TIMEDOUTimmediately instead of switching to yield mode and emitting buffered rows.RS_RESULT_TIMEDOUTwithout yielding their buffer (RPSorter via the existingRPSORT_DiscardOnTimeoutpolicy; RPGroup via natural propagation).4. Blocked-reader bailout via MR channel broadcast (
src/coord/rmr/chan.{h,c},src/coord/rmr/rmr.{h,c},src/coord/rpnet.c,src/coord/dist_aggregate.c,src/aggregate/aggregate_request.c)MRChannel_PopWithTimeout(chan, abstime, abortFlag, timedOut)— blocking pop with two independently-optional break conditions: wall-clock deadline and atomic abort flag. NewMRChannel_WakeAbort(chan)completes the abort protocol.MRIterator_NextWithTimeout/MRIterator_GetChannel— thin iterator passthrough.RequestSyncCtxgainsabortWakeChannel(weak pointer) +abortWakeLockand the extern helpersRegister/Unregister/WakeAbortChannel. The lock protects pointer validity;Unregisterblocks until any in-flightWakeAbortChannelcompletes.rpnetNext_Start,rpnetNext_StartWithMappings) register the iterator's channel on creation;rpnetFreeunregisters beforeMRIterator_Release— critical invariant for lifetime safety.getNextReplypasses&areq->syncCtx.timedOutas the abort flag on both pops (steady-state and WITHCOUNT barrier-wait);NULLpop distinguishes abort from EOF by re-readingAREQ_TimedOut(req)and returnsRS_RESULT_TIMEDOUTon abort.DistAggregateTimeoutReturnStrictClientcallsRequestSyncCtx_WakeAbortChannelright afterSetTimedOutso theatomic_load_explicit(memory_order_acquire)on the BG side is guaranteed to observe the flag.Observability
timeoutmetric is incremented onRETURN_STRICTtimeouts (mirrors the assertion added forFAILin [MOD-14086] Coordinator-level FT.AGGREGATE: use blocked-client FAIL timeout mechanism #8752).[]discard replies) carry the sametimeoutwarning shape asFT.SEARCH[MOD-13616] Use new RETURN-STRICT timeout mechanism in FT.SEARCH coordinator #8236.Three debug-only sync points (compiled under
ENABLE_ASSERT) support the race-deterministic coverage and have zero effect in release builds:SYNC_POINT_BEFORE_AGGREGATE_RESULTS_CLAIM(startPipeline) — pre-claim race.SYNC_POINT_BEFORE_RPNET_START(rpnetNext_Start) — post-claim / pre-dispatch race.SYNC_POINT_RPNET_REPLY_ADMITTED(rpnetNext) — mid-pipeline race after a shard reply has been admitted.The post-store race is exercised via
debugPauseStoreResults(BG parks afterAREQ_StoreResultsand pollsAREQ_TimedOutto break out).Test coverage
tests/pytests/test_blocked_client_timeout.py—TestCoordinatorTimeoutclass — covers all three regions plus pipeline-shape variants:test_return_strict_timeout_at_claim_sync_point_aggregate.test_return_strict_timeout_at_rpnet_start_sync_point_aggregate,test_return_strict_timeout_channel_drain_aggregate, plus discard-class coverage intest_return_strict_timeout_sortby_one_shard_paused_aggregate(RPSorter discard) andtest_return_strict_timeout_withcount_one_shard_paused_aggregate(ShardResponseBarrierand RPDepleterRETURN_STRICTdiscard).test_return_strict_timeout_after_store_aggregate.one_shard_paused,all_shards_paused.test_shard_timeout_fail.Related PRs
[MOD-13616]FT.SEARCH coord FAIL[MOD-13616]FT.SEARCH coord RETURN_STRICT (structural template)[MOD-13954]Shard-level FAIL[MOD-14073]FT.HYBRID coord FAIL (CoordRequestCtx)[MOD-14327]reply_callback+ChunkReplyState[MOD-14074]Shard-level FT.HYBRID FAIL[MOD-14086]FT.AGGREGATE coord FAIL (direct precedent)Mark if applicable
Release Notes
If a release note is required (bug fix / new feature / enhancement), describe the user impact of this PR in the title.
Note
High Risk
Touches coordinator timeout/reply behavior and cross-thread synchronization (CAS/condvar/channel wake) in distributed aggregation, where mistakes can cause deadlocks, double replies, or incorrect partial results under timeout.
Overview
Coordinator
FT.AGGREGATEnow supportsON_TIMEOUT RETURN_STRICTon the blocked-client path: the timeout callback can take ownership of the reply, wake a potentially-blocked shard reader, wait for the background pipeline to finish storing results, and then reply with either drained partial rows (for strictly-streaming pipeline shapes) or an empty result set + timeout warning (for buffering/reordering pipelines).This introduces a shared
RequestSyncCtxhandshake (CAS claim + condvar completion + abort-wake MR channel registration) used byAREQ/HybridRequest, wiresRPNet/MRIterator/MRChannelto support abort-flag driven wakeups, adjusts aggregation execution/serialization to not drop stored buffered results underRETURN_STRICT, and adds extensive deterministic cluster timeout tests via new debug sync points.Reviewed by Cursor Bugbot for commit 5f11051. Bugbot is set up for automated code reviews on this repo. Configure here.