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

Check for pending uploads outside of lock #628

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

Swatinem
Copy link
Contributor

According to traces, it happens quite frequently that an Upload task early-returns right after acquiring its upload lock because it does not have any pending tasks.

This moves this check outside of the lock to optimize one case. However it can still happen that concurrent Upload tasks "steal" each others pending uploads, so another check is still required within the lock.

@Swatinem Swatinem requested a review from a team August 16, 2024 09:24
@Swatinem Swatinem self-assigned this Aug 16, 2024
@codecov-staging
Copy link

codecov-staging bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files Patch % Lines
tasks/upload.py 81.81% 2 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
- Coverage   98.13%   98.12%   -0.02%     
==========================================
  Files         438      438              
  Lines       36565    36570       +5     
==========================================
- Hits        35884    35883       -1     
- Misses        681      687       +6     
Flag Coverage Δ
integration 98.12% <84.61%> (-0.02%) ⬇️
latest-uploader-overall 98.12% <84.61%> (-0.02%) ⬇️
unit 98.12% <84.61%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 96.07% <81.81%> (-0.05%) ⬇️
OutsideTasks 98.11% <ø> (ø)
Files Coverage Δ
tasks/tests/unit/test_upload_task.py 99.53% <100.00%> (+<0.01%) ⬆️
tasks/upload.py 95.84% <81.81%> (-1.90%) ⬇️

@codecov-qa
Copy link

codecov-qa bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.12%. Comparing base (201323d) to head (d5a4cd8).
Report is 10 commits behind head on main.

✅ All tests successful. No failed tests found.

Files Patch % Lines
tasks/upload.py 81.81% 2 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
- Coverage   98.13%   98.12%   -0.02%     
==========================================
  Files         438      438              
  Lines       36565    36570       +5     
==========================================
- Hits        35884    35883       -1     
- Misses        681      687       +6     
Flag Coverage Δ
integration 98.12% <84.61%> (-0.02%) ⬇️
latest-uploader-overall 98.12% <84.61%> (-0.02%) ⬇️
unit 98.12% <84.61%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 96.07% <81.81%> (-0.05%) ⬇️
OutsideTasks 98.11% <ø> (ø)
Files Coverage Δ
tasks/tests/unit/test_upload_task.py 99.53% <100.00%> (+<0.01%) ⬆️
tasks/upload.py 95.84% <81.81%> (-1.90%) ⬇️

Copy link

codecov-public-qa bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.12%. Comparing base (201323d) to head (d5a4cd8).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
- Coverage   98.13%   98.12%   -0.02%     
==========================================
  Files         438      438              
  Lines       36565    36570       +5     
==========================================
- Hits        35884    35883       -1     
- Misses        681      687       +6     
Flag Coverage Δ
integration 98.12% <84.61%> (-0.02%) ⬇️
latest-uploader-overall 98.12% <84.61%> (-0.02%) ⬇️
unit 98.12% <84.61%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 96.07% <81.81%> (-0.05%) ⬇️
OutsideTasks 98.11% <ø> (ø)
Files Coverage Δ
tasks/tests/unit/test_upload_task.py 99.53% <100.00%> (+<0.01%) ⬆️
tasks/upload.py 95.84% <81.81%> (-1.90%) ⬇️

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.15%. Comparing base (201323d) to head (d5a4cd8).
Report is 10 commits behind head on main.

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

✅ All tests successful. No failed tests found.

Files Patch % Lines
tasks/upload.py Critical 81.81% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
- Coverage   98.15%   98.15%   -0.01%     
==========================================
  Files         473      473              
  Lines       37770    37775       +5     
==========================================
+ Hits        37075    37078       +3     
- Misses        695      697       +2     
Flag Coverage Δ
integration 98.12% <84.61%> (-0.02%) ⬇️
latest-uploader-overall 98.12% <84.61%> (-0.02%) ⬇️
unit 98.12% <84.61%> (-0.02%) ⬇️

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

Components Coverage Δ
NonTestCode 96.13% <81.81%> (-0.02%) ⬇️
OutsideTasks 98.11% <ø> (ø)
Files Coverage Δ
tasks/tests/unit/test_upload_task.py 99.53% <100.00%> (+<0.01%) ⬆️
tasks/upload.py Critical 97.46% <81.81%> (-0.62%) ⬇️
Related Entrypoints
run/app.tasks.upload.Upload

According to traces, it happens quite frequently that an `Upload` task early-returns right after acquiring its upload lock because it does not have any pending tasks.

This moves this check outside of the lock to optimize one case. However it can still happen that concurrent `Upload` tasks "steal" each others pending uploads, so another check is still required within the lock.
@Swatinem Swatinem force-pushed the swatinem/check-uploads-first branch from 8a1de7c to d5a4cd8 Compare August 16, 2024 12:10
@Swatinem Swatinem added this pull request to the merge queue Aug 26, 2024
Merged via the queue into main with commit 93c03f9 Aug 26, 2024
18 of 26 checks passed
@Swatinem Swatinem deleted the swatinem/check-uploads-first branch August 26, 2024 09:18
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