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

fix(update_branches): commit more often, no more yield_per, no more ownerid #257

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

joseph-sentry
Copy link
Contributor

@joseph-sentry joseph-sentry commented Feb 7, 2024

  • no more ownerid
  • takes in incorrect commitid to help filter branches
  • no longer uses yield_per, instead does one query for all the branches then breaks it up into chunks of branches
  • commits after updating every chunk

@codecov-staging
Copy link

codecov-staging bot commented Feb 7, 2024

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #257   +/-   ##
=======================================
  Coverage   98.11%   98.12%           
=======================================
  Files         377      377           
  Lines       31462    31460    -2     
=======================================
+ Hits        30868    30869    +1     
+ Misses        594      591    -3     
Flag Coverage Δ
integration 98.12% <10.52%> (+<0.01%) ⬆️
latest-uploader-overall 98.12% <10.52%> (+<0.01%) ⬆️
unit 98.12% <10.52%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 96.19% <10.52%> (+0.02%) ⬆️
OutsideTasks 97.93% <ø> (ø)
Files Coverage Δ
tasks/update_branches.py 30.55% <10.52%> (+4.23%) ⬆️

@codecov-qa
Copy link

codecov-qa bot commented Feb 7, 2024

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (d9ef69b) 98.11% compared to head (a254743) 98.12%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #257   +/-   ##
=======================================
  Coverage   98.11%   98.12%           
=======================================
  Files         377      377           
  Lines       31462    31460    -2     
=======================================
+ Hits        30868    30869    +1     
+ Misses        594      591    -3     
Flag Coverage Δ
integration 98.12% <10.52%> (+<0.01%) ⬆️
latest-uploader-overall 98.12% <10.52%> (+<0.01%) ⬆️
unit 98.12% <10.52%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 96.19% <10.52%> (+0.02%) ⬆️
OutsideTasks 97.93% <ø> (ø)
Files Coverage Δ
tasks/update_branches.py 30.55% <10.52%> (+4.23%) ⬆️

Copy link

codecov-public-qa bot commented Feb 7, 2024

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (d9ef69b) 98.11% compared to head (a254743) 98.12%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #257   +/-   ##
=======================================
  Coverage   98.11%   98.12%           
=======================================
  Files         377      377           
  Lines       31462    31460    -2     
=======================================
+ Hits        30868    30869    +1     
+ Misses        594      591    -3     
Flag Coverage Δ
integration 98.12% <10.52%> (+<0.01%) ⬆️
latest-uploader-overall 98.12% <10.52%> (+<0.01%) ⬆️
unit 98.12% <10.52%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 96.19% <10.52%> (+0.02%) ⬆️
OutsideTasks 97.93% <ø> (ø)
Files Coverage Δ
tasks/update_branches.py 30.55% <10.52%> (+4.23%) ⬆️

):
if branch_name is None:
log.warning("No branch name specified, not updating any branches")
return {"attempted": False}

log.info(
"Doing update branches for branch",
extra=dict(branch_name=branch_name, ownerid=ownerid),
extra=dict(branch_name=branch_name),
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] I'd put the incorrect_commit here too since it changes the filter

Copy link
Contributor

Choose a reason for hiding this comment

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

Echo

tasks/update_branches.py Show resolved Hide resolved
)
if existing_commit is not None:
latest_commit_on_branch = (
db_session.query(Commit)
Copy link
Contributor

Choose a reason for hiding this comment

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

This query will run many times.

If we want to optimize to run the least number of queries in the DB as possible (as to now disturb normal operations) I think this should be refactored.
The trade-off as you'd expect is use more memory in the task to pre-compute certain values.

My recommendation, if possible (haven't looked into it but I think it should be) is to get the latest commit for all the repoid in the chunk once before the start of the loop and use that info to make the updates.

something like

SELECT Commit WHERE branch == branch_name, repoid IN (repoids) GROUP BY repoid -picking last row by updatetimestamp- 

The part I don't know exactly how to do is the -picking last row by updatetimestamp- but I think it should be possible to do that...

What do you think about that? Assuming to make the SELECT you need to possibly wait for locks maybe it's faster in the aggregate to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that makes a lot sense, I didn't think I could optimize this part but it makes sense to try to only do one query, I will look into this

@joseph-sentry joseph-sentry force-pushed the joseph/improve-branch-head-script branch 2 times, most recently from 1f8d7c9 to 3c12bf7 Compare February 7, 2024 22:05
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (d9ef69b) 98.08% compared to head (a254743) 98.09%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #257   +/-   ##
=======================================
  Coverage   98.08%   98.09%           
=======================================
  Files         408      408           
  Lines       32163    32161    -2     
=======================================
+ Hits        31548    31549    +1     
+ Misses        615      612    -3     
Flag Coverage Δ
integration 98.12% <10.52%> (+<0.01%) ⬆️
latest-uploader-overall 98.12% <10.52%> (+<0.01%) ⬆️
unit 98.12% <10.52%> (+<0.01%) ⬆️

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

Components Coverage Δ
NonTestCode 96.10% <10.52%> (+0.02%) ⬆️
OutsideTasks 97.93% <ø> (ø)
Files Coverage Δ
tasks/update_branches.py 30.55% <10.52%> (+4.23%) ⬆️

This change has been scanned for critical changes. Learn more

@joseph-sentry joseph-sentry force-pushed the joseph/improve-branch-head-script branch from 3c12bf7 to a254743 Compare February 7, 2024 22:59
@joseph-sentry joseph-sentry merged commit 62b1b24 into main Feb 8, 2024
27 of 31 checks passed
@joseph-sentry joseph-sentry deleted the joseph/improve-branch-head-script branch February 8, 2024 15:10
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.

3 participants