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

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

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.50%. Comparing base (5ae7169) to head (dadb1ce).

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.52%   69.50%   -0.03%     
==========================================
  Files         186      186              
  Lines       18326    18331       +5     
==========================================
- Hits        12742    12741       -1     
- Misses       4909     4913       +4     
- Partials      675      677       +2     

☔ 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
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