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(maven): cache responses from Maven registries #1408

Merged
merged 6 commits into from
Dec 10, 2024
Merged

Conversation

cuixq
Copy link
Contributor

@cuixq cuixq commented Nov 19, 2024

Follow up on #1045

Currently we cache the decoded Maven metadata and projects after fetching from Maven registries. We are not able to know if a request is Not Found or not. We can avoid making redundant not found requests if we cache the whole response from Maven registries.

This PR caches the response body as well as the statue code. This greatly improves the resolution performance - resolving registry.xml improves from 20s to 5s.

A potential caveat is that the new cache may not work with the existing cache, however considering the cache expires after some time and this is still an experimental feature, I don't worry too much on this.

@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.

Project coverage is 69.71%. Comparing base (dc9a332) to head (c64c12b).

Files with missing lines Patch % Lines
internal/resolution/datasource/maven_registry.go 61.53% 11 Missing and 4 partials ⚠️
...rnal/resolution/datasource/maven_registry_cache.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1408      +/-   ##
==========================================
- Coverage   69.74%   69.71%   -0.03%     
==========================================
  Files         186      186              
  Lines       18576    18581       +5     
==========================================
- Hits        12956    12954       -2     
- Misses       4920     4927       +7     
  Partials      700      700              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cuixq cuixq marked this pull request as ready for review November 21, 2024 00:15
@cuixq cuixq changed the title refactor(maven): cache response body from Maven registries perf(maven): cache responses from Maven registries Nov 21, 2024
responses *RequestCache[string, response]
}

type response struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think of naming this as mavenResponse but this structure is also quite general

Copy link
Member

@michaelkedar michaelkedar left a comment

Choose a reason for hiding this comment

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

LGTM

@cuixq
Copy link
Contributor Author

cuixq commented Nov 22, 2024

after a offline discussion, we probably only want to cache only the not found status code, so I will mark this PR to draft.

@cuixq cuixq marked this pull request as draft November 22, 2024 00:06
@cuixq cuixq marked this pull request as ready for review December 2, 2024 06:05
@cuixq cuixq changed the base branch from main to v2 December 6, 2024 03:03
@another-rex another-rex deleted the branch google:main December 10, 2024 00:26
@another-rex another-rex reopened this Dec 10, 2024
@cuixq cuixq changed the base branch from v2 to main December 10, 2024 00:29
@cuixq cuixq merged commit c693e2d into google:main Dec 10, 2024
13 checks passed
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.

5 participants