storaged: add dumpsys flags to limit data size
--threshold <bytes> This skips io usage not greater than <bytes> for current report. --time_window <secs> This sets uid_io collection interval to <secs> for future reports. The new interval will be ignore if it's less than 5 minutes. Test: adb shell dumpsys --threshold 4096 --time_window 300 Bug: 33086174 Bug: 34198239 Change-Id: I723c0850fa504a113da0a14945c4fbc64ea47659
This commit is contained in:
parent
9eaeba9040
commit
e5ea17c840
|
@ -257,6 +257,7 @@ public:
|
|||
#define DEFAULT_PERIODIC_CHORES_INTERVAL_DISK_STATS_PUBLISH ( 3600 )
|
||||
#define DEFAULT_PERIODIC_CHORES_INTERVAL_EMMC_INFO_PUBLISH ( 86400 )
|
||||
#define DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO ( 3600 )
|
||||
#define DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO_LIMIT (300)
|
||||
|
||||
// UID IO threshold in bytes
|
||||
#define DEFAULT_PERIODIC_CHORES_UID_IO_THRESHOLD ( 1024 * 1024 * 1024ULL )
|
||||
|
@ -300,8 +301,14 @@ public:
|
|||
std::unordered_map<uint32_t, struct uid_info> get_uids(void) {
|
||||
return mUidm.get_uid_io_stats();
|
||||
}
|
||||
std::map<uint64_t, std::vector<struct uid_record>> get_uid_records(int hours) {
|
||||
return mUidm.dump(hours);
|
||||
std::map<uint64_t, std::vector<struct uid_record>> get_uid_records(
|
||||
int hours, uint64_t threshold) {
|
||||
return mUidm.dump(hours, threshold);
|
||||
}
|
||||
void update_uid_io_interval(int interval) {
|
||||
if (interval >= DEFAULT_PERIODIC_CHORES_INTERVAL_UID_IO_LIMIT) {
|
||||
mConfig.periodic_chores_interval_uid_io = interval;
|
||||
}
|
||||
}
|
||||
|
||||
void init_battery_service();
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
// called by storaged -u
|
||||
std::unordered_map<uint32_t, struct uid_info> get_uid_io_stats();
|
||||
// called by dumpsys
|
||||
std::map<uint64_t, std::vector<struct uid_record>> dump(int hours);
|
||||
std::map<uint64_t, std::vector<struct uid_record>> dump(int hours, uint64_t threshold);
|
||||
// called by battery properties listener
|
||||
void set_charger_state(charger_stat_t stat);
|
||||
// called by storaged periodic_chore
|
||||
|
|
|
@ -89,6 +89,8 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
|
|||
}
|
||||
|
||||
int hours = 0;
|
||||
int time_window = 0;
|
||||
uint64_t threshold = 0;
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
const auto& arg = args[i];
|
||||
if (arg == String16("--hours")) {
|
||||
|
@ -97,10 +99,22 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
|
|||
hours = stoi(String16::std_string(args[i]));
|
||||
continue;
|
||||
}
|
||||
if (arg == String16("--time_window")) {
|
||||
if (++i >= args.size())
|
||||
break;
|
||||
time_window = stoi(String16::std_string(args[i]));
|
||||
continue;
|
||||
}
|
||||
if (arg == String16("--threshold")) {
|
||||
if (++i >= args.size())
|
||||
break;
|
||||
threshold = stoll(String16::std_string(args[i]));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<uint64_t, std::vector<struct uid_record>>& records =
|
||||
storaged.get_uid_records(hours);
|
||||
storaged.get_uid_records(hours, threshold);
|
||||
for (const auto& it : records) {
|
||||
dprintf(fd, "%llu\n", (unsigned long long)it.first);
|
||||
for (const auto& record : it.second) {
|
||||
|
@ -116,6 +130,11 @@ status_t Storaged::dump(int fd, const Vector<String16>& args) {
|
|||
(unsigned long long)record.ios.bytes[WRITE][BACKGROUND][CHARGER_ON]);
|
||||
}
|
||||
}
|
||||
|
||||
if (time_window) {
|
||||
storaged.update_uid_io_interval(time_window);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,8 @@ void uid_monitor::add_records_locked(uint64_t curr_ts)
|
|||
new_records.begin(), new_records.end());
|
||||
}
|
||||
|
||||
std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(int hours)
|
||||
std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(
|
||||
int hours, uint64_t threshold)
|
||||
{
|
||||
std::unique_ptr<lock_t> lock(new lock_t(&um_lock));
|
||||
|
||||
|
@ -160,7 +161,25 @@ std::map<uint64_t, std::vector<struct uid_record>> uid_monitor::dump(int hours)
|
|||
first_ts = time(NULL) - (uint64_t)hours * HOUR_TO_SEC;
|
||||
}
|
||||
|
||||
dump_records.insert(records.lower_bound(first_ts), records.end());
|
||||
for (auto it = records.lower_bound(first_ts); it != records.end(); ++it) {
|
||||
const std::vector<struct uid_record>& recs = it->second;
|
||||
std::vector<struct uid_record> filtered;
|
||||
|
||||
for (const auto& rec : recs) {
|
||||
if (rec.ios.bytes[READ][FOREGROUND][CHARGER_ON] +
|
||||
rec.ios.bytes[READ][FOREGROUND][CHARGER_OFF] +
|
||||
rec.ios.bytes[READ][BACKGROUND][CHARGER_ON] +
|
||||
rec.ios.bytes[READ][BACKGROUND][CHARGER_OFF] +
|
||||
rec.ios.bytes[WRITE][FOREGROUND][CHARGER_ON] +
|
||||
rec.ios.bytes[WRITE][FOREGROUND][CHARGER_OFF] +
|
||||
rec.ios.bytes[WRITE][BACKGROUND][CHARGER_ON] +
|
||||
rec.ios.bytes[WRITE][BACKGROUND][CHARGER_OFF] > threshold) {
|
||||
filtered.push_back(rec);
|
||||
}
|
||||
}
|
||||
dump_records.insert(
|
||||
std::pair<uint64_t, std::vector<struct uid_record>>(it->first, filtered));
|
||||
}
|
||||
|
||||
return dump_records;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue