Skip to content

Commit

Permalink
Revert MAReshuffle change to InterDexReshufflePass
Browse files Browse the repository at this point in the history
Summary: This diff removes the mergeability-aware changes that were previously landed to InterDexReshufflePass.

Reviewed By: thezhangwei

Differential Revision: D56717734

fbshipit-source-id: 46009d36da9932a3edbb2f59cb3163926131eb4b
  • Loading branch information
ShatianWang authored and facebook-github-bot committed May 2, 2024
1 parent de283e8 commit 5ce3b2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 43 deletions.
30 changes: 3 additions & 27 deletions opt/interdex/InterDexReshufflePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
*/

#include "InterDexReshufflePass.h"
#include "ClassMerging.h"
#include "ConfigFiles.h"
#include "DedupStrings.h"
#include "DexClass.h"
#include "DexStructure.h"
#include "DexUtil.h"
#include "InterDexPass.h"
#include "ModelSpecGenerator.h"
#include "PassManager.h"
#include "Show.h"
#include "StlUtil.h"
Expand Down Expand Up @@ -51,29 +49,9 @@ void InterDexReshufflePass::run_pass(DexStoresVector& stores,
return;
}

auto has_IDCM_pass = mgr.find_pass("IntraDexClassMergingPass");
// The mergeability_aware reshuffle algorithm is only enabled when 1) there
// will be a IDCM pass; 2) m_allow_mergeability_aware is set true; and 3) This
// is the first run of InterDexReshufflePass.
bool enable_mergeability_aware_reshuffle =
has_IDCM_pass && m_allow_mergeability_aware && m_run == 0;
if (enable_mergeability_aware_reshuffle) {
TRACE(PM, 1, "Run regular mergeability-aware InterDexReshuffle");
mgr.incr_metric("Mergeability_aware", 1);
class_merging::Model merging_model = class_merging::construct_global_model(
original_scope, mgr, conf, stores);

InterDexReshuffleImpl impl(conf, mgr, m_config, original_scope, root_dexen,
merging_model);
impl.compute_plan();
impl.apply_plan();
} else {
TRACE(PM, 1, "Run regular InterDexReshuffle");
mgr.incr_metric("Mergeability_aware", 0);
InterDexReshuffleImpl impl(conf, mgr, m_config, original_scope, root_dexen);
impl.compute_plan();
impl.apply_plan();
}
InterDexReshuffleImpl impl(conf, mgr, m_config, original_scope, root_dexen);
impl.compute_plan();
impl.apply_plan();

// Sanity check
std::unordered_set<DexClass*> original_scope_set(original_scope.begin(),
Expand All @@ -85,8 +63,6 @@ void InterDexReshufflePass::run_pass(DexStoresVector& stores,
for (auto cls : original_scope_set) {
always_assert(new_scope_set.count(cls));
}

++m_run;
}

static InterDexReshufflePass s_pass;
16 changes: 0 additions & 16 deletions opt/interdex/InterDexReshufflePass.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,14 @@ class InterDexReshufflePass : public Pass {
m_config.max_batch_size,
"How many class to move per batch. More might yield better results, "
"but might take longer.");
bind("other_weight",
m_config.other_weight,
m_config.other_weight,
"Weight for non-deduped method in mergeability-aware reshuffle cost "
"function.");
bind("deduped_weight",
m_config.deduped_weight,
m_config.deduped_weight,
"Weight for deduped method in mergeability-aware reshuffle cost "
"function.");
bind("exclude_below20pct_coldstart_classes",
false,
m_config.exclude_below20pct_coldstart_classes,
"Whether to exclude coldstart classes in between 1pctColdStart and "
"20pctColdStart marker"
"from the reshuffle.");
bind("allow_mergeability_aware", true, m_allow_mergeability_aware);
}

private:
ReshuffleConfig m_config;

// Which iteration of `run_pass`.
size_t m_run{0};

bool m_allow_mergeability_aware;
};

0 comments on commit 5ce3b2a

Please sign in to comment.