[Symbolize] LRU cache binaries in llvm-symbolizer.
This change adds a simple LRU cache to the Symbolize class to put a cap on llvm-symbolizer memory usage. Previously, the Symbolizer's virtual memory footprint would grow without bound as additional binaries were referenced. I'm putting this out there early for an informal review, since there may be a dramatically different/better way to go about this. I still need to figure out a good default constant for the memory cap and benchmark the implementation against a large symbolization workload. Right now I've pegged max memory usage at zero for testing purposes, which evicts the whole cache every time. Unfortunately, it looks like StringRefs in the returned DI objects can directly refer to the contents of binaries. Accordingly, the cache pruning must be explicitly requested by the caller, as the caller must guarantee that none of the returned objects will be used afterwards. For llvm-symbolizer this a light burden; symbolization occurs line-by-line, and the returned objects are discarded after each. Implementation wise, there are a number of nested caches that depend on one another. I've implemented a simple Evictor callback system to allow derived caches to register eviction actions to occur when the underlying binaries are evicted. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D119784
Loading
Please sign in to comment