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

perf: listAuthorizedProjectIDs should not get metadata #21555

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Czoyx
Copy link

@Czoyx Czoyx commented Feb 6, 2025

The ListRepositories interface was taking excessively long to execute. The root cause was that listAuthorizedProjectIDs was fetching unnecessary metadata. This PR removes the metadata retrieval from listAuthorizedProjectIDs, thereby improving the overall performance of the interface.

Comprehensive Summary of your change

Issue being fixed

Fixes #(issue)

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@Czoyx Czoyx requested a review from a team as a code owner February 6, 2025 10:22
@@ -153,7 +153,7 @@ func (r *repositoryAPI) listAuthorizedProjectIDs(ctx context.Context) ([]int64,
query.Keywords["public"] = true
}

projects, err := r.proCtl.List(ctx, query)
projects, err := r.proCtl.List(ctx, query, project.Detail(false))
Copy link
Contributor

Choose a reason for hiding this comment

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

we can also set the WithMetadata to false.

Copy link
Author

@Czoyx Czoyx Feb 11, 2025

Choose a reason for hiding this comment

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

I think project.Detail(false) has set WithMetadata to false. But the explicit assignment is also OK

func (c *controller) assembleProjects(ctx context.Context, projects models.Projects, options ...Option) error {

@chlins
Copy link
Member

chlins commented Feb 12, 2025

@Czoyx Thanks for catching that, could you also provide the performance comparison for reference?

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.26%. Comparing base (c8c11b4) to head (1476936).
Report is 382 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21555      +/-   ##
==========================================
+ Coverage   45.36%   46.26%   +0.89%     
==========================================
  Files         244      247       +3     
  Lines       13333    13883     +550     
  Branches     2719     2875     +156     
==========================================
+ Hits         6049     6423     +374     
- Misses       6983     7122     +139     
- Partials      301      338      +37     
Flag Coverage Δ
unittests 46.26% <ø> (+0.89%) ⬆️

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

see 491 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants