Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Test/Flag inserts in the DB #921

Merged
merged 1 commit into from
Dec 3, 2024
Merged

Conversation

Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Dec 2, 2024

This eagerly inserts all the test / flags combinations, and uses a on_conflict_do_nothing to avoid duplicates.

Previously, this would resolve/fetch all the tests that have any repo flag, and deduplicate those on the python side.

That code was very slow, as the underlying query was extremely slow for unknown reasons. I also believe the code was potentially buggy, as it queried for all the tests with repo flags, not filtering for the specific flags we were interested in. Though it was probably fine, as the flags are part of the deterministic test_id.

In addition, this queries for the flag_id directly, turning it into a set, instead of using a map and a lookup for each test.


Fun fact, this function accounts for ~40% of all time in profiling:
Bildschirmfoto 2024-12-02 um 13 34 17

@Swatinem Swatinem self-assigned this Dec 2, 2024
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.98%. Comparing base (23232c9) to head (80d83cc).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #921      +/-   ##
==========================================
- Coverage   97.98%   97.98%   -0.01%     
==========================================
  Files         446      446              
  Lines       35656    35652       -4     
==========================================
- Hits        34936    34932       -4     
  Misses        720      720              
Flag Coverage Δ
integration 42.09% <100.00%> (-0.01%) ⬇️
unit 90.65% <16.66%> (+<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

codecov-notifications bot commented Dec 2, 2024

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!

Copy link

github-actions bot commented Dec 2, 2024

✅ All tests successful. No failed tests were found.

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

Copy link
Contributor

@joseph-sentry joseph-sentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm cool with getting this in and measuring how it improves the perf, i do think the actual long term solution is the one that you mentioned previously: instead of writing to the db in each processor task we should be writing some intermediate result (to redis?) and merging them in the finisher and writing to the db there

Base automatically changed from swatinem/cleanup-ta-processor to main December 2, 2024 15:30
@Swatinem Swatinem force-pushed the swatinem/insert-test-flags branch from a9b1b7f to 112a639 Compare December 2, 2024 15:33
This eagerly inserts all the test / flags combinations, and uses a `on_conflict_do_nothing` to avoid duplicates.

Previously, this would resolve/fetch *all* the tests that have *any* repo flag, and deduplicate those on the python side.

That code was very slow, as the underlying query was extremely slow for unknown reasons. I also believe the code was potentially buggy, as it queried for *all* the tests with repo flags, not filtering for the specific flags we were interested in. Though it was probably fine, as the flags are part of the deterministic `test_id`.

In addition, this queries for the `flag_id` directly, turning it into a `set`, instead of using a `map` and a lookup for each test.
@Swatinem Swatinem force-pushed the swatinem/insert-test-flags branch from 112a639 to 80d83cc Compare December 3, 2024 08:25
@Swatinem Swatinem enabled auto-merge December 3, 2024 08:26
@Swatinem Swatinem added this pull request to the merge queue Dec 3, 2024
Merged via the queue into main with commit dcf7304 Dec 3, 2024
26 of 27 checks passed
@Swatinem Swatinem deleted the swatinem/insert-test-flags branch December 3, 2024 08:39
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.

2 participants