Skip to content

Commit

Permalink
splitting string_ref config into large string and small string
Browse files Browse the repository at this point in the history
Summary: as title

Reviewed By: NTillmann

Differential Revision: D50742454

fbshipit-source-id: 62587fcf2d39d2d73baf68a3c3ac888ebc263d76
  • Loading branch information
beicy authored and facebook-github-bot committed Oct 28, 2023
1 parent 1a42dd2 commit 38bb17d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
12 changes: 8 additions & 4 deletions opt/interdex/InterDex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,17 +698,21 @@ void InterDex::init_cross_dex_ref_minimizer() {
TRACE(IDEX, 2,
"[dex ordering] Cross-dex-ref-minimizer active with method ref weight "
"%" PRIu64 ", field ref weight %" PRIu64 ", type ref weight %" PRIu64
", string ref weight %" PRIu64 ", method seed weight %" PRIu64
", large string ref weight %" PRIu64
", small string ref weight %" PRIu64 ", method seed weight %" PRIu64
", field seed weight %" PRIu64 ", type seed weight %" PRIu64
", string seed weight %" PRIu64 ".",
", large string seed weight %" PRIu64
", small string seed weight %" PRIu64 ".",
m_cross_dex_ref_minimizer.get_config().method_ref_weight,
m_cross_dex_ref_minimizer.get_config().field_ref_weight,
m_cross_dex_ref_minimizer.get_config().type_ref_weight,
m_cross_dex_ref_minimizer.get_config().string_ref_weight,
m_cross_dex_ref_minimizer.get_config().large_string_ref_weight,
m_cross_dex_ref_minimizer.get_config().small_string_ref_weight,
m_cross_dex_ref_minimizer.get_config().method_seed_weight,
m_cross_dex_ref_minimizer.get_config().field_seed_weight,
m_cross_dex_ref_minimizer.get_config().type_seed_weight,
m_cross_dex_ref_minimizer.get_config().string_seed_weight);
m_cross_dex_ref_minimizer.get_config().large_string_seed_weight,
m_cross_dex_ref_minimizer.get_config().small_string_seed_weight);

std::vector<DexClass*> classes_to_insert;
// Emit classes using some algorithm to group together classes which
Expand Down
21 changes: 15 additions & 6 deletions opt/interdex/InterDexPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ void InterDexPass::bind_config() {
bind("minimize_cross_dex_refs_type_ref_weight",
m_minimize_cross_dex_refs_config.type_ref_weight,
m_minimize_cross_dex_refs_config.type_ref_weight);
bind("minimize_cross_dex_refs_string_ref_weight",
m_minimize_cross_dex_refs_config.string_ref_weight,
m_minimize_cross_dex_refs_config.string_ref_weight);
bind("minimize_cross_dex_refs_large_string_ref_weight",
m_minimize_cross_dex_refs_config.large_string_ref_weight,
m_minimize_cross_dex_refs_config.large_string_ref_weight);
bind("minimize_cross_dex_refs_small_string_ref_weight",
m_minimize_cross_dex_refs_config.small_string_ref_weight,
m_minimize_cross_dex_refs_config.small_string_ref_weight);
bind("minimize_cross_dex_refs_min_large_string_size",
m_minimize_cross_dex_refs_config.min_large_string_size,
m_minimize_cross_dex_refs_config.min_large_string_size);
bind("minimize_cross_dex_refs_method_seed_weight",
m_minimize_cross_dex_refs_config.method_seed_weight,
m_minimize_cross_dex_refs_config.method_seed_weight);
Expand All @@ -83,9 +89,12 @@ void InterDexPass::bind_config() {
bind("minimize_cross_dex_refs_type_seed_weight",
m_minimize_cross_dex_refs_config.type_seed_weight,
m_minimize_cross_dex_refs_config.type_seed_weight);
bind("minimize_cross_dex_refs_string_seed_weight",
m_minimize_cross_dex_refs_config.string_seed_weight,
m_minimize_cross_dex_refs_config.string_seed_weight);
bind("minimize_cross_dex_refs_large_string_seed_weight",
m_minimize_cross_dex_refs_config.large_string_seed_weight,
m_minimize_cross_dex_refs_config.large_string_seed_weight);
bind("minimize_cross_dex_refs_large_string_seed_weight",
m_minimize_cross_dex_refs_config.small_string_seed_weight,
m_minimize_cross_dex_refs_config.small_string_seed_weight);
bind("minimize_cross_dex_refs_emit_json", false,
m_minimize_cross_dex_refs_config.emit_json);
bind("minimize_cross_dex_refs_explore_alternatives", 1,
Expand Down
8 changes: 7 additions & 1 deletion service/cross-dex-ref-minimizer/CrossDexRefMinimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ void CrossDexRefMinimizer::insert(DexClass* cls) {
add_weight(type, m_config.type_ref_weight, m_config.type_seed_weight);
}
for (auto string : cls_refs.strings) {
add_weight(string, m_config.string_ref_weight, m_config.string_seed_weight);
if (string->length() > m_config.min_large_string_size) {
add_weight(string, m_config.small_string_ref_weight,
m_config.large_string_seed_weight);
} else {
add_weight(string, m_config.large_string_ref_weight,
m_config.small_string_seed_weight);
}
}
for (auto fref : cls_refs.field_refs) {
add_weight(fref, m_config.field_ref_weight, m_config.field_seed_weight);
Expand Down
7 changes: 5 additions & 2 deletions service/cross-dex-ref-minimizer/CrossDexRefMinimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ struct CrossDexRefMinimizerConfig {
uint64_t method_ref_weight{100};
uint64_t field_ref_weight{90};
uint64_t type_ref_weight{100};
uint64_t string_ref_weight{90};
uint64_t large_string_ref_weight{90};
uint64_t small_string_ref_weight{90};

uint64_t method_seed_weight{100};
uint64_t field_seed_weight{20};
uint64_t type_seed_weight{30};
uint64_t string_seed_weight{20};
uint64_t large_string_seed_weight{20};
uint64_t small_string_seed_weight{20};

uint32_t min_large_string_size{50};
bool emit_json{false};
};

Expand Down

0 comments on commit 38bb17d

Please sign in to comment.