Skip to content

Commit

Permalink
Upgrade redex baseline config to new format
Browse files Browse the repository at this point in the history
Summary:
Updates the redex baseline profile config to the new 2.0 format. After talking to Nikolai, it looks like we probably do need this config instead of the metadata file.

We will probably have to update whatsapp before making this change

Reviewed By: jimmycFB

Differential Revision: D66207921

fbshipit-source-id: e59cb0a0177733c43f600619266fac7a1d3e7449
  • Loading branch information
Koby Chan authored and facebook-github-bot committed Dec 12, 2024
1 parent bdf76d7 commit 0bafb5a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 48 deletions.
58 changes: 26 additions & 32 deletions libredex/ConfigFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,61 +594,55 @@ ConfigFiles::get_baseline_profile_config() {
get_json_config().get("baseline_profile", {}, baseline_profile_config_json);
}

auto baseline_profile_config_jw = JsonWrapper(baseline_profile_config_json);

if (baseline_profile_config_json.empty()) {
return *m_baseline_profile_config;
}

auto interactions_json = baseline_profile_config_json.get("interactions", {});
always_assert(!interactions_json.empty());

for (auto& interaction_pair_json : interactions_json) {
auto id = interaction_pair_json[0].asString();
auto name = interaction_pair_json[1].asString();

m_baseline_profile_config->interaction_configs[id] = {};
m_baseline_profile_config->interactions.emplace_back(std::move(id),
std::move(name));
}

auto options_json = baseline_profile_config_json.get("options", {});
always_assert(!options_json.empty());

auto options_jw = JsonWrapper(options_json);

options_jw.get("oxygen_modules", false,
m_baseline_profile_config->options.oxygen_modules);
options_jw.get("strip_classes", false,
m_baseline_profile_config->options.strip_classes);
options_jw.get(
baseline_profile_config_jw.get(
"oxygen_modules", false,
m_baseline_profile_config->options.oxygen_modules);
baseline_profile_config_jw.get(
"strip_classes", false, m_baseline_profile_config->options.strip_classes);
baseline_profile_config_jw.get(
"use_redex_generated_profile", false,
m_baseline_profile_config->options.use_redex_generated_profile);
options_jw.get(
"include_betamap_20pct_coldstart", false,
baseline_profile_config_jw.get(
"include_betamap_20pct_coldstart", true,
m_baseline_profile_config->options.include_betamap_20pct_coldstart);
options_jw.get(
baseline_profile_config_jw.get(
"betamap_include_coldstart_1pct", false,
m_baseline_profile_config->options.betamap_include_coldstart_1pct);

for (auto it = baseline_profile_config_json.begin();
it != baseline_profile_config_json.end();
auto deepdata_interactions_json =
baseline_profile_config_json.get("deep_data_interaction_config", {});
always_assert(!deepdata_interactions_json.empty());

for (auto it = deepdata_interactions_json.begin();
it != deepdata_interactions_json.end();
++it) {
std::string key = it.memberName();
if (key == "interactions" || key == "options") {
continue;
}

const auto& interaction_id = key;

m_baseline_profile_config->interaction_configs[interaction_id] = {};

auto& bpi_config =
m_baseline_profile_config->interaction_configs[interaction_id];

const auto& bpi_config_jw = JsonWrapper(*it);

bpi_config_jw.get("call_threshold", 1, bpi_config.call_threshold);
bpi_config_jw.get("classes", false, bpi_config.classes);
bpi_config_jw.get("post_startup", false, bpi_config.post_startup);
bpi_config_jw.get("classes", true, bpi_config.classes);
bpi_config_jw.get("post_startup", true, bpi_config.post_startup);
bpi_config_jw.get("startup", false, bpi_config.startup);
bpi_config_jw.get("threshold", 80, bpi_config.threshold);
always_assert(bpi_config_jw.contains("name"));
std::string name = bpi_config_jw.get("name", std::string());

m_baseline_profile_config->interactions.emplace_back(interaction_id,
std::move(name));
}

return *m_baseline_profile_config;
Expand Down
31 changes: 15 additions & 16 deletions test/integ/BaselineAwareBetamapsTest.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
],
},
"baseline_profile": {
"ColdStart": {
"call_threshold": 1,
"classes": true,
"post_startup": true,
"startup": true,
"threshold": 20
},
"interactions": [
["ColdStart", "ColdStart"],
["12345678", "Other"],
],
"options": {
"oxygen_modules": true,
"strip_classes": false,
"use_redex_generated_profile": false,
"include_betamap_20pct_coldstart": true
"deep_data_interaction_config": {
"ColdStart": {
"name": "ColdStart",
"call_threshold": 1,
"classes": true,
"post_startup": true,
"startup": true,
"threshold": 20
},
"12345678": {
"name": "Other",
},
},
"oxygen_modules": true,
"strip_classes": false,
"use_redex_generated_profile": false,
},
"InterDexPass": {
"static_prune": false,
Expand Down

0 comments on commit 0bafb5a

Please sign in to comment.