Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Use the CommitLoader for bundleAnalysisCompareWithParent#1271

Merged
Swatinem merged 1 commit intomainfrom
swatinem/batch-load-bundlecompare
Apr 4, 2025
Merged

Use the CommitLoader for bundleAnalysisCompareWithParent#1271
Swatinem merged 1 commit intomainfrom
swatinem/batch-load-bundlecompare

Conversation

@Swatinem
Copy link
Copy Markdown
Contributor

@Swatinem Swatinem commented Apr 3, 2025

This is loading the parent_commit using the async batch-loading CommitLoader.

This way, we can avoid one of the N+1 queries being executed when executing the GetCommits GraphQL query.

However, we are still loading all the BA CommitReports separately within load_bundle_analysis_comparison, which is another 2N+1 problem on its own. Will solve that one another time :-)

@Swatinem Swatinem self-assigned this Apr 3, 2025
@Swatinem Swatinem requested a review from a team as a code owner April 3, 2025 14:10
@seer-by-sentry
Copy link
Copy Markdown
Contributor

seer-by-sentry bot commented Apr 3, 2025

✅ Sentry found no issues in your recent changes ✅

Copy link
Copy Markdown
Contributor

@adrian-codecov adrian-codecov left a comment

Choose a reason for hiding this comment

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

Can you explain a bit more how making the call async to load_... helps w/ the N+1?

@Swatinem
Copy link
Copy Markdown
Contributor Author

Swatinem commented Apr 4, 2025

https://github.com/syrusakbary/aiodataloader?tab=readme-ov-file#batching explains it quite well.

Assuming we have an async framework based on an event-loop. We can call the async fns, and they will run immediately up until the first await point. So they will observe a bunch of load calls.

On the next tick of the event loop, all the load calls that happened on the previous tick are being batched together and executed as one.

The graphql framework in the background is executing all the resolvers concurrently, meaning all of them are running up until the first await Loader.load(). Then the dataloader does its magic and batches all those load requests together.

This is loading the `parent_commit` using the async batch-loading `CommitLoader`.

This way, we can avoid one of the N+1 queries being executed when executing the `GetCommits` GraphQL query.

However, we are still loading all the BA `CommitReport`s separately within `load_bundle_analysis_comparison`, which is another 2N+1 problem on its own.
Will solve that one another time :-)
@Swatinem Swatinem force-pushed the swatinem/batch-load-bundlecompare branch from 323ee99 to cdbd476 Compare April 4, 2025 08:16
@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Apr 4, 2025

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!

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.32%. Comparing base (ab4cb5b) to head (cdbd476).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1271      +/-   ##
==========================================
- Coverage   96.32%   96.32%   -0.01%     
==========================================
  Files         487      487              
  Lines       16892    16891       -1     
==========================================
- Hits        16272    16271       -1     
  Misses        620      620              
Flag Coverage Δ
unit 96.32% <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.

@Swatinem Swatinem added this pull request to the merge queue Apr 4, 2025
Merged via the queue into main with commit 382f278 Apr 4, 2025
23 of 24 checks passed
@Swatinem Swatinem deleted the swatinem/batch-load-bundlecompare branch April 4, 2025 09:16
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 4, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ OperationalError: table bundles already exists /graphql/{service} View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants