Skip to content

perf(worker): Cache flag reports and optimize comparison totals#822

Draft
sentry[bot] wants to merge 3 commits intomainfrom
seer/perf/cache-flag-reports-comparison
Draft

perf(worker): Cache flag reports and optimize comparison totals#822
sentry[bot] wants to merge 3 commits intomainfrom
seer/perf/cache-flag-reports-comparison

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry bot commented Apr 15, 2026

Fixes WORKER-PFZ. The issue was that: Flag.totals property creates new filtered reports, triggering repeated database queries for each flag in a loop.

  • Implemented caching for the Flag.report property to avoid redundant filtering operations.
  • Refactored compute_comparison_for_commit_and_pull to pre-fetch base_report_flags and diff once before iterating through flags.
  • Updated get_flag_comparison_totals to accept pre-fetched head_report_flags, base_report_flags, and diff as arguments, reducing repeated calls and lookups.

This fix was generated by Seer in Sentry, triggered by Tom Hu. 👁️ Run ID: 13349039

Not quite right? Click here to continue debugging with Seer.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes CI Run Lint (ruff format) on PR branch.

Made-with: Cursor
@sentry
Copy link
Copy Markdown
Contributor Author

sentry bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.25%. Comparing base (43f5168) to head (5e3a93f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #822   +/-   ##
=======================================
  Coverage   92.25%   92.25%           
=======================================
  Files        1306     1306           
  Lines       48013    48017    +4     
  Branches     1636     1637    +1     
=======================================
+ Hits        44295    44299    +4     
  Misses       3407     3407           
  Partials      311      311           
Flag Coverage Δ
apiunit 96.35% <ø> (ø)
sharedintegration 36.90% <25.00%> (-0.01%) ⬇️
sharedunit 84.90% <100.00%> (+<0.01%) ⬆️
workerintegration 58.54% <0.00%> (-0.01%) ⬇️
workerunit 90.39% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 15, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing seer/perf/cache-flag-reports-comparison (5e3a93f) with main (e38e122)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (43f5168) during the generation of this report, so e38e122 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

- Assert Flag.report filter uses paths=None (matches implementation).
- Add regression test that filtered report is reused across accesses.
- Add unit tests for ComputeComparisonTask.get_flag_comparison_totals.

Raises Codecov patch coverage for PR changes.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant