Skip to content

fix(detection): reduce trace selection batch size from 50 to 5#114372

Merged
roggenkemper merged 6 commits intomasterfrom
roggenkemper/fix/reduce-detection-batch-size
Apr 30, 2026
Merged

fix(detection): reduce trace selection batch size from 50 to 5#114372
roggenkemper merged 6 commits intomasterfrom
roggenkemper/fix/reduce-detection-batch-size

Conversation

@roggenkemper
Copy link
Copy Markdown
Member

@roggenkemper roggenkemper commented Apr 29, 2026

Reduces TRANSACTION_BATCH_SIZE from 50 to 5 in the AI issue detection trace selection pipeline. We used to take 10 traces from the 50, now that we are only taking 1 we can lower. also removes redis deduplication that is less relevant given the longer cycles

The detection pipeline queries top N transactions per org, then runs 1
Snuba query per transaction to sample a trace — but only sends 1 trace
to Seer. At TRANSACTION_BATCH_SIZE=50, that's ~52 Snuba queries to
select 1 trace. Reducing to 5 cuts selection queries by ~90% while
still providing enough candidates after span-count and dedup filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 29, 2026
roggenkemper and others added 5 commits April 29, 2026 18:43
…e queries

Instead of reducing TRANSACTION_BATCH_SIZE, keep querying top 50
transactions for diversity but shuffle and sample 5 before the
per-transaction trace sampling loop. This cuts ~45 Snuba queries
per org execution while maintaining diverse transaction coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Transactions are already shuffled in trace_data.py before sampling,
so the shuffle of evidence_traces here was redundant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only 1 trace is sent to Seer per execution, and neither span count
filtering nor dedup replaces filtered traces with alternatives, so
extra candidates don't add value. Cuts per-transaction trace queries
from 5 to 1 per org.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
With TRACE_SAMPLE_SIZE=1 from a shuffle of 50 transactions, the odds
of picking the same transaction twice across runs are ~2%. Combined
with longer execution cycles, the Redis-based dedup adds complexity
without meaningful value. Removes _get_unprocessed_traces,
mark_traces_as_processed, and TRACE_PROCESSING_TTL_SECONDS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Span count filtering (20-500 spans) can reject candidates, so we
need a few to have fallbacks. 5 gives enough margin while still
cutting queries from 50 to 5.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@roggenkemper roggenkemper marked this pull request as ready for review April 29, 2026 23:14
@roggenkemper roggenkemper requested a review from a team as a code owner April 29, 2026 23:14
@roggenkemper roggenkemper merged commit cffe589 into master Apr 30, 2026
59 checks passed
@roggenkemper roggenkemper deleted the roggenkemper/fix/reduce-detection-batch-size branch April 30, 2026 15:46
cleptric pushed a commit that referenced this pull request May 5, 2026
Reduces `TRANSACTION_BATCH_SIZE` from 50 to 5 in the AI issue detection
trace selection pipeline. We used to take 10 traces from the 50, now
that we are only taking 1, we can lower. also removes redis deduplication
that is less relevant given the longer cycles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants