Skip to content

Conversation

mateagluhak
Copy link

@mateagluhak mateagluhak commented Sep 3, 2025

PR Description

Alloy currently stores all source maps in memory (cache) indefinitely. This can become an issue if you are running an instance with a lot of big source maps where frontend application versions often change as it can lead to OOM. I've added an option to clear source maps from cache if they were not used after the specified time has passed.
In this PR I've also changed the behavior of the cache when download/parsing of sourcemaps fails. Before, errors would be cached and download would not be retried. With this solution you can specify an interval in which you want to check if there are any errors cached and remove them, after which Alloy will reattempt to download.

Which issue(s) this PR fixes

No issue filed.

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated

…ps can be removed from cache if cache minimum ttl is specified
@mateagluhak mateagluhak requested review from clayton-cornell and a team as code owners September 3, 2025 15:29
@CLAassistant
Copy link

CLAassistant commented Sep 3, 2025

CLA assistant check
All committers have signed the CLA.

@clayton-cornell clayton-cornell requested a review from a team September 4, 2025 19:35
Comment on lines 143 to 155
go func(s *sourceMapsStoreImpl) {
for {
time.Sleep(newArgs.SourceMaps.CacheCleanupCheckInterval)
s.CleanOldCacheEntries()
}
}(innerStore)

go func(s *sourceMapsStoreImpl) {
for {
time.Sleep(newArgs.SourceMaps.CacheErrorCleanupInterval)
s.CleanCachedErrors()
}
}(innerStore)
Copy link
Contributor

Choose a reason for hiding this comment

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

This would leak goroutines and memory because it's scheduled on every update without a way to exit

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Sep 25, 2025
@mateagluhak mateagluhak requested a review from kalleep September 26, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Docs Squad label across all Grafana Labs repos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants