Skip to content

Commit

Permalink
Enable including all betamap classes/methods
Browse files Browse the repository at this point in the history
Summary: Adds an option to include all classes/methods from betamap into the baseline profile.

Reviewed By: danjin250

Differential Revision: D68174163

fbshipit-source-id: dcc223ddf408b4a3fb1e935784aad278c530ddcd
  • Loading branch information
Koby Chan authored and facebook-github-bot committed Jan 17, 2025
1 parent 2899bff commit e3ef341
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libredex/BaselineProfileConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ struct BaselineProfileOptions {
// NOTE: This requires that include_betamap_20pct_coldstart be set to have any
// effect
bool betamap_include_coldstart_1pct;

// If this is true, then the ArtProfileWriter will insert all methods/classes
// from the betamap into the baseline profile.
bool include_all_startup_classes;
};

struct BaselineProfileConfig {
Expand Down
3 changes: 3 additions & 0 deletions libredex/ConfigFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ ConfigFiles::get_default_baseline_profile_config() {
"betamap_include_coldstart_1pct", false,
current_baseline_profile_config.options.betamap_include_coldstart_1pct);
Json::Value deepdata_interactions_json;
baseline_profile_config_jw.get(
"include_all_startup_classes", false,
current_baseline_profile_config.options.include_all_startup_classes);
baseline_profile_config_jw.get("deep_data_interaction_config", {},
deepdata_interactions_json);
always_assert(!deepdata_interactions_json.empty());
Expand Down
23 changes: 23 additions & 0 deletions opt/art-profile-writer/ArtProfileWriterPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,29 @@ void ArtProfileWriterPass::run_pass(DexStoresVector& stores,
: baseline_profiles::get_baseline_profile(
conf.get_default_baseline_profile_config(),
method_profiles, &method_refs_without_def);
if (conf.get_default_baseline_profile_config()
.options.include_all_startup_classes) {
const std::vector<std::string>& interdexorder =
conf.get_coldstart_classes();
std::vector<DexClass*> coldstart_classes;
for (const auto& entry : interdexorder) {
DexType* type = DexType::get_type(entry);
if (type) {
auto coldstart_class = type_class(type);
if (coldstart_class) {
coldstart_classes.push_back(coldstart_class);
baseline_profile.classes.insert(coldstart_class);
}
}
}
baseline_profiles::MethodFlags flags;
flags.hot = true;
flags.startup = true;
walk::methods(coldstart_classes,
[&baseline_profile, flags](DexMethod* method) {
baseline_profile.methods.emplace(method, flags);
});
}
auto scope = build_class_scope(stores);
if (m_never_compile_callcount_threshold > -1 ||
m_never_compile_perf_threshold > -1) {
Expand Down

0 comments on commit e3ef341

Please sign in to comment.