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

Draft
wants to merge 2 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 65.78947% with 13 lines in your changes missing coverage. Please review.

Project coverage is 69.52%. Comparing base (7fc8567) to head (f562fb1).

Files with missing lines Patch % Lines
internal/resolution/datasource/maven_registry.go 69.44% 8 Missing and 3 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.52%   -0.01%     
==========================================
  Files         186      186              
  Lines       18326    18327       +1     
==========================================
- Hits        12742    12741       -1     
- Misses       4909     4910       +1     
- Partials      675      676       +1     

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


🚨 Try these New Features:

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