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

Purge old jemalloc files from cache on cache miss (eg on stack or jemalloc version change) #37

Open
edmorley opened this issue Jun 25, 2024 · 2 comments

Comments

@edmorley
Copy link

This buildpack compiles jemalloc during the build and caches the result under a stack and jemalloc-specific path:

# bundle is the full path to the cached jemalloc binaries for this version.
bundle=$CACHE_DIR/jemalloc/$STACK/$version

This correctly ensures that a recompile happens if the stack or requested jemalloc version changes.

However, currently the buildpack does not remove these cached items on cache miss, meaning the cache will continue to grow in size each time the stack or requested jemalloc version changes (unless users know to manually clear their build cache using a special CLI plugin).

To resolve this, the buildpack could do an rm -rf "${CACHE_DIR}/jemalloc/" on cache miss before the download/recompile, here:

# doesn't exist.
if [[ ! -d $bundle ]]; then
echo "-----> jemalloc: Installing $version from source"
download
compile

@edmorley edmorley changed the title Purge old jemalloc files from cache on cache miss (eg stack or jemalloc version change) Purge old jemalloc files from cache on cache miss (eg on stack or jemalloc version change) Jun 25, 2024
@gaffneyc
Copy link
Owner

My original intent with not clearing the cached builds was to make it possible to revert to a previously built version of jemalloc without having to deploy. Realistically though that's confusing since you have to build a new slug in order to use a version you've never deployed before.

Purging the builds would probably work but I'd like to noodle on it. Fortunately each build is ~6MB and the cadence of Heroku stack and jemalloc releases is both rather slow.

Another option would be to only clear the cache for stacks other than the current one. Compressing the build artifacts would also reduce them down to ~2MB.

@edmorley
Copy link
Author

Ah if it's only 6MB that's not so bad - I had imagined it would be larger than that.

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

No branches or pull requests

2 participants