-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(http): Switch to memory cache provider #33901
base: main
Are you sure you want to change the base?
feat(http): Switch to memory cache provider #33901
Conversation
…cache-provider-switch
…-cache-provider-switch
…-cache-provider-switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test first
@@ -13,7 +13,6 @@ async function matchingBranches( | |||
): Promise<string[]> { | |||
const { body: branches } = await githubApi.getJson( | |||
`/repos/${repo}/git/matching-refs/heads/${branchName}`, | |||
{ memCache: false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why the memCache=false parts are no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memCache=false
is the equivalent of the absent cacheProvider
option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yes, no memory cache is the default now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we be confident that we haven't missed anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking, we can't. What we can is analyze HTTP stats and watch for repeating GET requests (sometimes, though, it's intended).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you summarize all the cases where http memcache is still being explicitly enabled in this PR (seems to be within platform code) and we evaluate whether we're better to add platform-level caching (e.g. of PR lists) instead of relying on http-level? Maybe you can do this through inline PR comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a significant reduction in the number of http requests which we cache in memory. This should apply especially to datasource requests
@zharinov can we log when caching fails/falls through to the lowest level? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs deconflicting
lib/util/http/index.ts
Outdated
|
||
// istanbul ignore next | ||
if (resPromise && options.cacheProvider !== memCacheProvider) { | ||
logger.debug({ url }, 'Cache hit on the obsolete memCache option'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched this to logger.error and ran on containerbase/base with dryRun=lookup and got many errors. They're all either /v2/
queries or /token?
ones from docker datasource.
Maybe this datasource should do its own caching of these, with its own TTLs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer to accumulate these URLs into a Set and then at the end print a debug message about number of URLs using legacy caching. Then we can capture and graph that in our hosted app and know when we reach 0
# Conflicts: # lib/modules/platform/bitbucket-server/index.ts # lib/util/http/index.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a refactor of docker datasource too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run on a fork of the renovate repo, and there are PRs needing changelogs, we see some more cache fallbacks:
DEBUG: Cache hit URLs (repository=renovate-reproductions/renovate2)
"count": 7,
"hits": {
"https://api.github.com/repos/yarnpkg/berry": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 1
},
"https://api.github.com/repos/yarnpkg/berry/git/trees/master?recursive=1": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 1
},
"https://api.github.com/repos/yarnpkg/berry/git/blobs/3e96b54ffe13ba43b83ee1844a3ba37aeb4f77f8": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 1
},
"https://api.github.com/repos/aws/aws-sdk-js-v3": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 5
},
"https://api.github.com/repos/aws/aws-sdk-js-v3/git/trees/main?recursive=1": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 5
},
"https://api.github.com/repos/eslint/eslint": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 1
},
"https://api.github.com/repos/eslint/eslint/git/blobs/7d070fd0c3cbfeb53f719f85ee0e6677b70a0f5b": {
"callsite": "async Object.getReleaseNotesMd (/Users/rhys/src/renovatebot/renovate/lib/workers/repository/update/pr/changelog/github/index.ts)",
"count": 1
}
}
Changes
Make caching of GET/HEAD HTTP requests disabled by default.
When it's needed, the
memCacheProvider
is be used.Context
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: