From 64fad483ce2ce2106002abfb7d86ae0978610314 Mon Sep 17 00:00:00 2001 From: Nikolai Tillmann Date: Tue, 31 Oct 2023 18:13:45 -0700 Subject: [PATCH] Limit concurrent destruction Summary: A recent change caused excessive parallelism during the RedexContext destruction. This is being fixed here, by clearing concurrent containers sequentially (as part of the already ongoing massively parallel destruction effort). Reviewed By: agampe Differential Revision: D50819506 fbshipit-source-id: e08de44047bd6970ae6c85b694bc80bd3f931573 --- libredex/PassManager.cpp | 1 + libredex/RedexContext.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libredex/PassManager.cpp b/libredex/PassManager.cpp index 86078bcb6d..1d0deb19bc 100644 --- a/libredex/PassManager.cpp +++ b/libredex/PassManager.cpp @@ -66,6 +66,7 @@ #include "ScopedMetrics.h" #include "Show.h" #include "SourceBlocks.h" +#include "ThreadPool.h" #include "Timer.h" #include "Walkers.h" diff --git a/libredex/RedexContext.cpp b/libredex/RedexContext.cpp index 0659cf2c36..7da37f8ad8 100644 --- a/libredex/RedexContext.cpp +++ b/libredex/RedexContext.cpp @@ -76,14 +76,14 @@ RedexContext::~RedexContext() { s_type_map.clear(); }, [&] { - Timer timer("DexTypeLists", /* indent */ false); + Timer timer("Delete DexTypeLists", /* indent */ false); for (auto const& p : s_typelist_map) { delete p.second; } s_typelist_map.clear(); }, [&] { - Timer timer("Delete DexProtos.", /* indent */ false); + Timer timer("Delete DexProtos", /* indent */ false); for (auto* proto : s_proto_set) { delete proto; } @@ -185,7 +185,10 @@ RedexContext::~RedexContext() { for (size_t i = 0; i < s_small_string_set.size(); ++i) { auto* small_string_set = s_small_string_set[i]; small_strings_size += small_string_set->size(); - fns.push_back([small_string_set]() { delete small_string_set; }); + fns.push_back([small_string_set]() { + small_string_set->clear(); + delete small_string_set; + }); } for (auto& segment : s_large_string_set) { large_strings_size += segment.size();