From f0d5ed73b2242ea3e4ab4303daabd7771f0722bc Mon Sep 17 00:00:00 2001 From: Sam Haves Date: Mon, 2 Feb 2026 06:42:12 -0800 Subject: [PATCH] Restore cache capacity after BM_CompileManyTextures benchmark. The BM_CompileManyTextures benchmark temporarily sets the MuJoCo cache capacity to 0. This change ensures that the original cache capacity is restored after the benchmark completes, preventing side effects on other tests. PiperOrigin-RevId: 864332653 Change-Id: I5f756e30d4922d5e6f9b70d19ba9d0e31cde9259 --- test/benchmark/parse_benchmark_test.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/benchmark/parse_benchmark_test.cc b/test/benchmark/parse_benchmark_test.cc index cd8957c8..2752e713 100644 --- a/test/benchmark/parse_benchmark_test.cc +++ b/test/benchmark/parse_benchmark_test.cc @@ -114,13 +114,18 @@ void BM_CompileManyTextures(benchmark::State& state) { // Disable cache to simulate many textures without needing separate // testdata files. - mj_setCacheCapacity(mj_getCache(), 0); + auto* cache = mj_getCache(); + int old_capacity = mj_getCacheCapacity(cache); + mj_setCacheCapacity(cache, 0); for (auto s : state) { char error[1024]; mjModel* model = LoadModelFromString(xml, error, sizeof(error)); mj_deleteModel(model); } + + // Reset cache capacity to default value. + mj_setCacheCapacity(cache, old_capacity); } BENCHMARK(BM_CompileManyTextures)->Range(10, 100);