Skip to content

Commit

Permalink
ArtProfileWriter to add classes of hot methods.
Browse files Browse the repository at this point in the history
Summary:
https://www.internalfb.com/code/fbsource/[178198e42623]/fbandroid/native/baseline_profiles/manual_profile.py?lines=47-48
this line of code in the baseline profile generator makes it clear that in manual profile (which includes profile from redex), a class has to be its own line in order to be picked into baseline profile, and eventually hopefully in app image.
Remember, a method line starts with its flag like 'H', "S', 'P', never 'L'.

So this change makes sure class of any hot method (and also startup-only method that will be included into profile) is included into baseline profile.

Reviewed By: NTillmann

Differential Revision: D51322912

fbshipit-source-id: 679ef61fdf41f67fc2c1cfa063e71b07f2608edb
  • Loading branch information
ghehg authored and facebook-github-bot committed Nov 15, 2023
1 parent 4ee021f commit 65a6492
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions opt/art-profile-writer/ArtProfileWriterPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,18 @@ void ArtProfileWriterPass::run_pass(DexStoresVector& stores,
for (size_t dex_idx = 0; dex_idx < end; dex_idx++) {
auto& dex = dexen.at(dex_idx);
for (auto* cls : dex) {
bool should_include_class = false;
for (auto* method : cls->get_all_methods()) {
auto it = method_flags.find(method);
if (it == method_flags.end()) {
continue;
}
// hot method's class should be included.
// In addition, if we include non-hot startup method, we also need to
// include its class.
if (it->second.hot || (it->second.startup && !it->second.not_startup)) {
should_include_class = true;
}
std::string descriptor = show_deobfuscated(method);
// reformat it into manual profile pattern so baseline profile generator
// in post-process can recognize the method
Expand All @@ -125,6 +132,9 @@ void ArtProfileWriterPass::run_pass(DexStoresVector& stores,
ofs << it->second << descriptor << std::endl;
methods_with_baseline_profile++;
}
if (should_include_class) {
ofs << show_deobfuscated(cls) << std::endl;
}
}
}

Expand Down

0 comments on commit 65a6492

Please sign in to comment.