← Back to Pull requests

perf(crossseed): one fewer RED/OPS request per unmatched album #4903

Open
unknown opened this pull request with 501 lines diff across 6 files
View on GitHub
unknown unknown commented on Dec 01, 2026 22:35 UTC
Author

Description

Problem: Every music album with no match on Orpheus or Redacted cost 3 requests, and one of them, the old-flag hash (APL on Orpheus, PTH on Redacted), almost never found anything, so a burst of completed albums hit the rate limit sooner.

Fix: A RED/OPS lookup now asks the current-flag hash, then the file-name search, and asks the old-flag hash only when the file-name search cannot decide. An album with no match costs 2 requests, and an old-flag upload is still found.

  • An old-flag upload has the same files and total size as the local torrent, so the file-name search finds it as a size match.

  • qui asks the old-flag hash only when no file name gives a usable search, or no search for a music file comes back with 20 results or fewer (each one returns more, or fails).

  • When a file-name search failed and the old-flag hash then finds nothing, the lookup reports the search error, not "no match". The lookup still stops at the first refusal, in each of the three steps.

  • The OPS/RED docs page lists the new lookup order.
  • Part of #4883. Closes #4891

    Breaking change

    No breaking change.

    Behaviour change

  • An old-flag upload that the file-name search finds shows as a size match (gazelle:size), not a hash match.
  • How has this been tested?

    Evidence: https://bin.getqui.com/e/V6LGAXOKMC34DIUO3OF2376COK

    Live run of a built qui in a network namespace with only loopback, so nothing could reach a real tracker. orpheus.network pointed at a local fake Gazelle site over TLS, and a fake qBittorrent held made-up albums. A manual search with only Orpheus picked, for each album, from the fake site's request log:

    1. no match on the site: 2 requests, qui reports no_match
    GET ajax.php?action=torrent&hash=<OPS hash>          -> miss
    GET ajax.php?action=browse&filelist=08 - Alpha Song Number 8 -> 0 results
    
    2. the site has it only under the APL flag: 2 requests, the APL hash is never asked
    GET ajax.php?action=torrent&hash=<OPS hash>          -> miss
    GET ajax.php?action=browse&filelist=08 - Bravo Song Number 8 -> 1 result, exact size
    qui: match, gazelle:size
    
    3. every file-name search returns 25 results: the APL hash finds it
    GET ajax.php?action=torrent&hash=<OPS hash>          -> miss
    GET ajax.php?action=browse&filelist=... (5 file names) -> 25 results each
    GET ajax.php?action=torrent&hash=<APL hash>          -> hit
    qui: match, gazelle:hash
    

    The requests went about 4.6 seconds apart, the Orpheus pace. The tests in gazellemusic/match_test.go and ratelimit_test.go cover each case of the ticket.

    Merge danger: two-way door, RED/OPS lookups only.

    Performance

    An album with no match on a RED/OPS site costs 2 requests instead of 3, about 4.6 seconds less of the Orpheus pace per album.

    | Path | Requests to the site |
    |---|---|
    | Lookup, no match, a music-file search returns 20 results or fewer | 3 → 2 |
    | Lookup, old-flag upload, a music-file search returns 20 results or fewer | 2 → 2 (found by the file-name search, not the old-flag hash) |
    | Lookup, every file-name search returns more than 20 results, no match | up to 7 → up to 7 |
    | Lookup, every file-name search returns more than 20 results, old-flag upload | 2 → up to 7 (the file-name searches now come first) |

    Counted from the request log of an httptest fake Gazelle site in TestFindMatchDecisiveMissSendsTwoRequests, run on base 62f54e2 (3 requests: current-flag hash, old-flag hash, browse) and on head; the head count matches the live run above. No CPU or memory risk: the change reorders the same calls and adds none.

    Checklist

  • My PR title follows the Conventional Commits format (it becomes the squashed commit message)

  • If this changes the database schema, I have added migrations for both SQLite and PostgreSQL

  • I completed the mandatory performance checks and recorded the outcome in Performance
  • Diff: 501 lines (+375 / -126) across 6 files Reviewer: greptile-apps[bot] Review duration: 9m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.48) × (1 − Review Confidence (0.40)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 501 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 74% · Reviewer familiarity: 35%
    40%
    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.372
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4903"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.2% 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: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    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: 40.2% · Lower = rushed or shallow review
    40.2%
    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.4% · Safe to merge
    28.4%
    Repository