Skip to content

Commit

Permalink
excluded_prefices
Browse files Browse the repository at this point in the history
Summary:
This allows an easy workaround to exclude methods known to have unstable method profiles.

This is a behavior-preserving change.

Reviewed By: beicy

Differential Revision: D51761656

fbshipit-source-id: 6b8a71e8c981717a12d602d9bf6b2abfde4d14ab
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Dec 6, 2023
1 parent 8450ce7 commit d40e2fc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
19 changes: 17 additions & 2 deletions opt/outliner/MethodSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,23 @@ void split_methods_in_stores(
dex_states[&dex];
}
}
walk::parallel::code(
scope, [&](DexMethod* method, IRCode&) { methods.insert(method); });

auto is_excluded = [&](DexMethod* method) {
auto name = method->get_deobfuscated_name_or_empty();
for (const auto& prefix : config.excluded_prefices) {
if (name.substr(0, prefix.size()) == prefix) {
return true;
}
}
return false;
};
walk::parallel::code(scope, [&](DexMethod* method, IRCode&) {
if (is_excluded(method)) {
stats->excluded_methods++;
return;
}
methods.insert(method);
});

size_t iteration{0};
AtomicMap<std::string, size_t> uniquifiers;
Expand Down
1 change: 1 addition & 0 deletions opt/outliner/MethodSplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct Stats {
std::atomic<size_t> added_code_size{0};
std::atomic<size_t> split_code_size{0};
std::unordered_set<DexMethod*> added_methods;
std::atomic<size_t> excluded_methods{0};
};

void split_methods_in_stores(
Expand Down
4 changes: 4 additions & 0 deletions opt/outliner/MethodSplittingConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>

namespace method_splitting_impl {

Expand All @@ -29,6 +31,8 @@ struct Config {
size_t cost_split_method{16};
size_t cost_split_switch{6};
size_t cost_split_switch_case{4};

std::vector<std::string> excluded_prefices;
};

} // namespace method_splitting_impl
3 changes: 3 additions & 0 deletions opt/outliner/MethodSplittingPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void MethodSplittingPass::bind_config() {
"Maximum number of live-in registers");
bind("max_iteration", m_config.max_iteration, m_config.max_iteration,
"Maximum number of top-level iterations");
bind("excluded_prefices", m_config.excluded_prefices,
m_config.excluded_prefices);
}

void MethodSplittingPass::run_pass(DexStoresVector& stores,
Expand Down Expand Up @@ -96,6 +98,7 @@ void MethodSplittingPass::run_pass(DexStoresVector& stores,
mgr.set_metric("split_code_size", (size_t)stats.split_code_size);
mgr.set_metric("new_hot_methods", concurrent_new_hot_methods.size());
mgr.set_metric("derived_method_profile_stats", derived_method_profile_stats);
mgr.set_metric("excluded_methods", (size_t)stats.excluded_methods);
TRACE(MS, 1, "Split out %zu methods", stats.added_methods.size());

for (auto [method, size] : concurrent_splittable_no_optimizations_methods) {
Expand Down

0 comments on commit d40e2fc

Please sign in to comment.