← Back to Pull requests

Bound per-shard content in FT.SEARCH fan-out #1684

Open
unknown opened this pull request with 584 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 10, 2026 23:55 UTC
Author

Bound per-shard content in FT.SEARCH fan-out

Implements #1324.

A cluster FT.SEARCH bounded to K results (KNN K, or LIMIT offset+count) currently has
every shard return K results with content: N × K records read and serialized to return K.

With search.fanout-bounded-content enabled, each shard returns K candidates (keys and
scores) with content for only its first E_i. The coordinator ranks all candidates as
before, then fetches the content of winners that arrived without it from their owning
shard: a new FetchContent RPC, or in-process for its own shard. Fetched keys are
revalidated against the query; a winner that no longer matches is replaced by the next
candidate, so the reply is the same as without the setting.

E_i is the smallest per-shard limit that keeps the probability of a fetch round at or
below search.fanout-content-recovery-rate, modeling each shard's share of the winners as
binomial in its share of the slots.

Applies to FT.SEARCH with content, no SORTBY or INKEYS, across two or more shards.

Configuration

| Name | Default | Description |
|---|---|---|
| search.fanout-bounded-content | no | Enables bounded content fan-out |
| search.fanout-content-recovery-rate | 0.1 | Target fraction of queries that need a fetch round; lower is more conservative |

The default recovery rate was chosen from a sweep of 0.01, 0.1, 0.3 and 1.0 (N=4):

| Recovery rate | Field RPS (1000 conns) | HNSW RPS (1000 conns) | HNSW RPS (1 conn) |
|---|---|---|---|
| 0.01 | +77% | +4% | 0% |
| 0.1 | +107% | +9% | −1% |
| 0.3 | +107% | +10% | +1% |
| 1.0 | +143% | +6% | −15% |

0.1 matches 0.3, the best HNSW result, with fewer fetch rounds. 1.0 helps field search
further but slows HNSW at low load.

Compatibility

  • Protocol changes are additive (content_limit, content_omitted, FetchContent). A

  • shard without them returns full content and is never asked to fetch.
  • No RDB change.

  • Both settings can be changed at runtime.
  • Testing

  • Unit tests: estimator, planner, shard-side content limit, wire format, client, and

  • fetch rounds (backfill, termination, failures).
  • Integration tests: replies compared with the setting on and off, covering:

  • - HASH and JSON;
    - even and skewed data;
    - LIMIT offsets, RETURN, KNN, hybrid queries and WITHCURSOR;
    - uneven slot ownership and replica targets;
    - shards without content_limit;
    - fetch failures (partial results and consistency);
    - documents changed between rounds.

    The in-flight blocking tests also run with the setting on.

    Performance

    Setup:

  • One x86 host with 64 vCPU. Each shard is pinned to 8 logical CPUs; one client process

  • per shard.
  • io-threads 2, reader-threads 8, writer-threads 8.

  • Each scenario: 60 s warm-up, then 200 s measured.

  • Setting on uses recovery rate 0.1.
  • | Workload | Data | Query |
    |---|---|---|
    | Field | 50,000 docs × 50 TEXT fields of ~1 KB | @field1:<term> (LIMIT 10, and LIMIT 0 100) |
    | Prefix | 10,000 docs, one 50 B TEXT field, WITHSUFFIXTRIE | @field1:<term>* |
    | HNSW | 100,000 docs, 256-d FLOAT32 vector (HNSW, M 16) | (@price:[100 500])=>[KNN 10 @embedding $vec], RETURN 2 |

    Throughput (1000 connections per client process)

    | Workload | N | RPS off | RPS on | RPS improvement |
    |---|---|---|---|---|
    | Field | 2 | 1,072 | 1,558 | +45.3% |
    | Field | 4 | 964 | 1,992 | +106.6% |
    | Field, LIMIT 0 100 | 2 | 103 | 173 | +67.9% |
    | Field, LIMIT 0 100 | 4 | 104 | 253 | +144.3% |
    | HNSW | 2 | 14,890 | 14,794 | −0.6% |
    | HNSW | 4 | 13,593 | 14,786 | +8.8% |
    | Prefix | 2 | 24,841 | 22,433 | −9.7% |
    | Prefix | 4 | 21,364 | 20,075 | −6.0% |

    Latency (1 connection per client process)

    Improvement = (off − on) / off; positive means lower latency with the setting on.

    | Workload | N | p50 ms off → on | p50 improvement | p99 ms off → on | p99 improvement |
    |---|---|---|---|---|---|
    | Field | 2 | 2.95 → 1.76 | +40.3% | 4.12 → 2.86 | +30.6% |
    | Field | 4 | 4.74 → 2.19 | +53.8% | 7.47 → 3.68 | +50.7% |
    | Field, LIMIT 0 100 | 2 | 27.65 → 11.24 | +59.3% | 34.72 → 18.48 | +46.8% |
    | Field, LIMIT 0 100 | 4 | 38.88 → 12.52 | +67.8% | 65.94 → 24.24 | +63.2% |
    | HNSW | 2 | 0.39 → 0.39 | 0.0% | 0.57 → 0.59 | −3.5% |
    | HNSW | 4 | 0.56 → 0.55 | +1.8% | 1.19 → 1.21 | −1.7% |
    | Prefix | 2 | 0.21 → 0.25 | −19.0% | 0.29 → 0.44 | −51.7% |
    | Prefix | 4 | 0.34 → 0.46 | −35.3% | 0.87 → 1.09 | −25.3% |

    Run-to-run variation is within ±5%.

    Queries with small content (prefix) are slower with the setting on, which is why it is off
    by default.

    In progress

    Benchmarks of this branch with the setting off, against its base commit, are running.
    Results will be posted in the comments.

    Diff: 584 lines (+438 / -146) across 7 files Reviewer: greptile-apps[bot] Review duration: 17m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 584 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.381
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1684"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.5% · Safe to merge
    28.5%