heroku-buildpack-jemalloc icon indicating copy to clipboard operation
heroku-buildpack-jemalloc copied to clipboard

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

Open edmorley opened this issue 7 months ago • 2 comments

This buildpack compiles jemalloc during the build and caches the result under a stack and jemalloc-specific path: https://github.com/gaffneyc/heroku-buildpack-jemalloc/blob/a7fe9271f64c861debe9b6cc814203c17e7e68dc/bin/compile#L37-L38

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: https://github.com/gaffneyc/heroku-buildpack-jemalloc/blob/a7fe9271f64c861debe9b6cc814203c17e7e68dc/bin/compile#L116-L121

edmorley avatar Jun 25 '24 19:06 edmorley