7

On macOS 11, Rosetta2 apparently caches translated programs and shared libraries under /var/db/oah.

On an M1-based CI instance where we are testing per-commit-novel x86_64 binaries under Rosetta2, this directory seems to grow without bound and eventually ends up consuming all free disk space on the machine. Currently /var/db/oah is approximately 800GB and contains about 2.4 million directories.

I would have hoped that such a cache would have a size limit and built-in LRU behavior, or at least some sort of administrative command to prune it (perhaps based on atime?) that could be scheduled, but so far I've been unable to find any setting to configure such a bound for the cache or any command to interact with it at all, let alone clean it out. Ideally, we would like to not inhibit caching or remove recently used translations since we do expect that caching will offer a performance benefit when the same binary is re-used, which does happen in our testing environment.

Is anyone aware of any tooling or system configuration settings that may allow us to bound the size of the oah cache for Rosetta2, or manually prune it, or if necessary disable caching entirely?

4
  • 1
    A chron script to delete all older than 30 days. Or will you be reusing the ancient stuff?
    – Solar Mike
    Commented Sep 21, 2021 at 19:17
  • 1
    Yes, a cron job is our option of last resort, but the question is whether there are any built-in controls provided by the OS to bound the cache (first preference), or tooling that already understands the cache that we can leverage in such a cron job (second preference), before we need to go and write our own from scratch. It seems very strange that Apple would allow this cache to grow without bound to the point of rendering the system unusable.
    – acm
    Commented Sep 21, 2021 at 19:22
  • /var/db/oah seems to be protected by SIP. More out of curiosity (and partially because it impacts your ability to use cron): Have you disabled SIP on the CI machine?
    – nohillside
    Commented Sep 24, 2021 at 13:32
  • @nohillside - Yes, I believe SIP has been disabled, for other reasons.
    – acm
    Commented Sep 24, 2021 at 16:23

1 Answer 1

5
+150

Unfortunately I don't think Apple ships any configuration options or tooling to allow the user to bound the size of the Rosetta2 cache - nor tools for pruning it or similar.

For this particular usecase with a CI server, I would probably suggest making a small addition to your CI build script that removes its additions to the Rosetta2 cache.

In particular, every time you build a new executable and run it for the first time using Rosetta2, a new .aot file will appear in /var/db/oah. After you have finished using the build product, you could simply have the build script remove that file.

You can find the name of the file by tracing the program the first time you run it, which will reveal the name of the cache file. Another alternative is to set the environment variable ROSETTA_PRINT_SEGMENTS before running the program. This will output the name of the .aot file to stderr when running the program (usually you'll see multiple .aot files because dependencies are loaded in, but the principle is the same).

3
  • 1
    Thanks, those are some good pointers around ROSETTA_PRINT_SEGMENTS. It would help us build something more along the lines of a scalpel. In the end, I think we are going to opt for the big hammer of a cron job though. Meanwhile, I've filed an issue with Apple. I'll follow-up if they come back with any interesting feedback.
    – acm
    Commented Sep 27, 2021 at 16:49
  • @acm Super - please mark the answer as accepted now that it answers your question.
    – jksoegaard
    Commented Sep 27, 2021 at 17:20
  • I'll let the bounty run a little longer in case someone comes by with something truly astounding, but barring that I'll be happy to award it to your answer as you have provided the most detailed insights into how we might build appropriate tooling.
    – acm
    Commented Sep 27, 2021 at 18:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .