Skip to content

Commit

Permalink
Break up the patcher stats into more granular sections
Browse files Browse the repository at this point in the history
Summary: The current patcher stats are too general. It's impossible to tell which code path can a stats delta be attributed to. Therefore, I propose to break them up into smaller sections. Each section covers a particular top level entry point in the `run()` method of the patcher. Hopefully this change will shed some lights on which code paths are causing the nondeterminism in the patcher.

Reviewed By: ssj933

Differential Revision: D69889601

fbshipit-source-id: 7e80277756fb0f4204957d2a319162bb73c9a62b
  • Loading branch information
Wei Zhang (Devinfra) authored and facebook-github-bot committed Feb 20, 2025
1 parent 664b0d4 commit 9f48417
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 72 deletions.
6 changes: 3 additions & 3 deletions opt/typedef-anno-checker/TypedefAnnoCheckerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,14 +710,14 @@ void TypedefAnnoCheckerPass::run_pass(DexStoresVector& stores,
patcher.print_stats(mgr);
TRACE(TAC, 1, "Finished patcher run");

auto stats = walk::parallel::methods<Stats>(scope, [&](DexMethod* m) {
auto stats = walk::parallel::methods<CheckerStats>(scope, [&](DexMethod* m) {
TypedefAnnoChecker checker = TypedefAnnoChecker(
strdef_constants, intdef_constants, m_config, *method_override_graph);
checker.run(m);
if (!checker.complete()) {
return Stats(checker.error());
return CheckerStats(checker.error());
}
return Stats();
return CheckerStats();
});

if (stats.m_count > 0) {
Expand Down
9 changes: 5 additions & 4 deletions opt/typedef-anno-checker/TypedefAnnoCheckerPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ class TypedefAnnoCheckerPass : public Pass {
friend struct TypedefAnnoCheckerTest;
};

struct Stats {
struct CheckerStats {
std::string m_errors;
size_t m_count{0};

explicit Stats(std::string error) : m_errors(std::move(error)), m_count(1) {}
Stats() = default;
explicit CheckerStats(std::string error)
: m_errors(std::move(error)), m_count(1) {}
CheckerStats() = default;

Stats& operator+=(const Stats& other) {
CheckerStats& operator+=(const CheckerStats& other) {
m_count += other.m_count;
if (m_errors.empty()) {
m_errors = other.m_errors;
Expand Down
Loading

0 comments on commit 9f48417

Please sign in to comment.