Add a cache for self profiles #1747
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The self-profiles are downloaded from S3 on each request to the detailed results page. Each file has ~12 MiB, downloading and analysing takes ~0.5-1s, and for the detailed page we download two of these profiles.
After download and post-processing, the profile only takes about ~50 KiB in memory, so I think that it makes sense to cache these profiles. This PR adds such a cache, with 1000 entries (using a LRU cache), so that it should take ~50 MiB in memory at most.
If you don't think that a cache is necessary, we could at least keep the first commit, which refactors profile download and should make it easier to reuse it for other use-cases (e.g. for doing more analyses in the benchmark detail endpoint).