diff options
author | Jin Qian <jinqian@google.com> | 2017-09-28 16:02:22 -0700 |
---|---|---|
committer | Jin Qian <jinqian@google.com> | 2017-10-10 00:56:03 +0000 |
commit | d691d6e941c930e54313a53f817302fcdaf74460 (patch) | |
tree | b1d70aa475385403a1ea9f9112ccb621b1d8ce8c /storaged/tests | |
parent | 65dea712483927b59ae2451baa3bb12d6a246169 (diff) | |
download | core-d691d6e941c930e54313a53f817302fcdaf74460.tar.gz core-d691d6e941c930e54313a53f817302fcdaf74460.tar.bz2 core-d691d6e941c930e54313a53f817302fcdaf74460.zip |
storaged: record IO perf history from proto updates
Record the bandwidth when writing storaged.proto to monitor system
storage performance.
The history is maintained in 3 catergories.
1. samples of last 24 hours.
2. daily average of last 7 days.
3. weekly average of last 52 weeks.
Sampling frequency of the first catergory is set to once every hour.
Storaged also flushes proto at same frequency.
The proto file is padded to reach a minimal size of 128KB. Storaged
writes 16KB at a time. Bandwidth calculation ignores time spent in
the first write and writes smaller than 16KB.
bandwidth = total size of 16KB writes / time spent in 16KB writes
Restructured the code so that storaged.cpp handles proto load/flush.
It calls individual module to sync proto with internal data
structures.
Added a cmdline argument to dump perf history.
adb shell storaged -p
I/O perf history (KB/s) : most_recent <--------- least_recent
last 24 hours : 5315 3775 3659 2042 3890 5652 3649 3696 6023
last 7 days : 4648 3532 3828 3567 3841 3359 4676
last 52 weeks : 3817 4275 3836 3766 4280 0 0 0 0 0 ...
Test: adb shell storaged -p
atp:asit/perf/jank_systemui_test
atp:asit/perf/appstartup_hermetic_cyclic_dropcache_test
atp:asit/perf/appstartup_non_hermetic_cyclic_dropcache_test
Bug: 63629306
Change-Id: Ie7051e7a8df883d4a6818ea9a54a10f4dccb4843
Diffstat (limited to 'storaged/tests')
-rw-r--r-- | storaged/tests/storaged_test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/storaged/tests/storaged_test.cpp b/storaged/tests/storaged_test.cpp index bd14d766f..5ae1c91c2 100644 --- a/storaged/tests/storaged_test.cpp +++ b/storaged/tests/storaged_test.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <chrono> #include <deque> #include <fcntl.h> #include <random> @@ -30,6 +31,9 @@ #define MMC_DISK_STATS_PATH "/sys/block/mmcblk0/stat" #define SDA_DISK_STATS_PATH "/sys/block/sda/stat" +using namespace std; +using namespace chrono; + namespace { void write_and_pause(uint32_t sec) { @@ -343,3 +347,61 @@ TEST(storaged_test, disk_stats_monitor) { write_and_pause(5); } } + +TEST(storaged_test, storage_info_t) { + storage_info_t si; + time_point<steady_clock> tp; + time_point<system_clock> stp; + + // generate perf history [least_recent ------> most recent] + // day 1: 5, 10, 15, 20 | daily average 12 + // day 2: 25, 30, 35, 40, 45 | daily average 35 + // day 3: 50, 55, 60, 65, 70 | daily average 60 + // day 4: 75, 80, 85, 90, 95 | daily average 85 + // day 5: 100, 105, 110, 115, | daily average 107 + // day 6: 120, 125, 130, 135, 140 | daily average 130 + // day 7: 145, 150, 155, 160, 165 | daily average 155 + // end of week 1: | weekly average 83 + // day 1: 170, 175, 180, 185, 190 | daily average 180 + // day 2: 195, 200, 205, 210, 215 | daily average 205 + // day 3: 220, 225, 230, 235 | daily average 227 + // day 4: 240, 245, 250, 255, 260 | daily average 250 + // day 5: 265, 270, 275, 280, 285 | daily average 275 + // day 6: 290, 295, 300, 305, 310 | daily average 300 + // day 7: 315, 320, 325, 330, 335 | daily average 325 + // end of week 2: | weekly average 251 + // day 1: 340, 345, 350, 355 | daily average 347 + // day 2: 360, 365, 370, 375 + si.day_start_tp = {}; + for (int i = 0; i < 75; i++) { + tp += hours(5); + stp = {}; + stp += duration_cast<seconds>(tp.time_since_epoch()); + si.update_perf_history((i + 1) * 5, stp); + } + + vector<vector<uint32_t>> history = si.get_perf_history(); + EXPECT_EQ(history.size(), 3UL); + EXPECT_EQ(history[0].size(), 4UL); + EXPECT_EQ(history[1].size(), 7UL); // 7 days + EXPECT_EQ(history[2].size(), 52UL); // 52 weeks + // last 24 hours + EXPECT_EQ(history[0][0], 375UL); + EXPECT_EQ(history[0][1], 370UL); + EXPECT_EQ(history[0][2], 365UL); + EXPECT_EQ(history[0][3], 360UL); + // daily average of last 7 days + EXPECT_EQ(history[1][0], 347UL); + EXPECT_EQ(history[1][1], 325UL); + EXPECT_EQ(history[1][2], 300UL); + EXPECT_EQ(history[1][3], 275UL); + EXPECT_EQ(history[1][4], 250UL); + EXPECT_EQ(history[1][5], 227UL); + EXPECT_EQ(history[1][6], 205UL); + // weekly average of last 52 weeks + EXPECT_EQ(history[2][0], 251UL); + EXPECT_EQ(history[2][1], 83UL); + for (int i = 2; i < 52; i++) { + EXPECT_EQ(history[2][i], 0UL); + } +} |