summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsystems.com>2017-10-12 16:10:17 +0200
committerChristian Mollekopf <mollekopf@kolabsystems.com>2017-10-12 16:10:17 +0200
commitda0e1bb93de6d45c261a0e48f024f1b0ce92b2d2 (patch)
tree8852bda1939c64d93b44b3608ba3c649d6adad3c
parent85f77b641d06faf934e54e6f154a31844d94627b (diff)
downloadsink-da0e1bb93de6d45c261a0e48f024f1b0ce92b2d2.tar.gz
sink-da0e1bb93de6d45c261a0e48f024f1b0ce92b2d2.zip
Changed how we record and print the mail query benchmark data.
Each column can represent an individual value, which we can use to record related data. Each row thus represents a new run of the benchmark.
-rw-r--r--hawd_defs/mail_query3
-rw-r--r--tests/hawd/modules/json.cpp8
-rw-r--r--tests/mailquerybenchmark.cpp78
3 files changed, 50 insertions, 39 deletions
diff --git a/hawd_defs/mail_query b/hawd_defs/mail_query
index c555997..2138507 100644
--- a/hawd_defs/mail_query
+++ b/hawd_defs/mail_query
@@ -3,6 +3,7 @@
3 "description": "Measures performance of mail queries", 3 "description": "Measures performance of mail queries",
4 "columns": [ 4 "columns": [
5 { "name": "rows", "type": "int" }, 5 { "name": "rows", "type": "int" },
6 { "name": "queryResultPerMs", "type": "float", "unit": "result/ms" } 6 { "name": "simple", "type": "float", "unit": "result/ms" },
7 { "name": "threadleader", "type": "float", "unit": "result/ms" }
7 ] 8 ]
8} 9}
diff --git a/tests/hawd/modules/json.cpp b/tests/hawd/modules/json.cpp
index d08df49..d299761 100644
--- a/tests/hawd/modules/json.cpp
+++ b/tests/hawd/modules/json.cpp
@@ -73,9 +73,15 @@ bool Json::toJson(const QStringList &commands, State &state)
73 QJsonObject jsonRow; 73 QJsonObject jsonRow;
74 jsonRow.insert("timestamp", QJsonValue::fromVariant(row.timestamp())); 74 jsonRow.insert("timestamp", QJsonValue::fromVariant(row.timestamp()));
75 jsonRow.insert("commit", row.commitHash()); 75 jsonRow.insert("commit", row.commitHash());
76 QJsonArray columnsArray;
76 for (const auto &col : columns) { 77 for (const auto &col : columns) {
77 jsonRow.insert(col.first, QJsonValue::fromVariant(row.value(col.first))); 78 QJsonObject columnObject;
79 columnObject.insert("unit", QJsonValue::fromVariant(col.second.unit()));
80 columnObject.insert("name", QJsonValue::fromVariant(col.first));
81 columnObject.insert("value", QJsonValue::fromVariant(row.value(col.first)));
82 columnsArray << columnObject;
78 } 83 }
84 jsonRow.insert("columns", columnsArray);
79 array.append(jsonRow); 85 array.append(jsonRow);
80 }); 86 });
81 json.insert("rows", array); 87 json.insert("rows", array);
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp
index f9a3712..f6d7130 100644
--- a/tests/mailquerybenchmark.cpp
+++ b/tests/mailquerybenchmark.cpp
@@ -80,7 +80,7 @@ class MailQueryBenchmark : public QObject
80 entityStore.commitTransaction(); 80 entityStore.commitTransaction();
81 } 81 }
82 82
83 void testLoad(const QByteArray &name, const Sink::Query &query, int count, int expectedSize) 83 qreal testLoad(const Sink::Query &query, int count, int expectedSize)
84 { 84 {
85 const auto startingRss = getCurrentRSS(); 85 const auto startingRss = getCurrentRSS();
86 86
@@ -105,7 +105,7 @@ class MailQueryBenchmark : public QObject
105 while (!done) { 105 while (!done) {
106 QTest::qWait(1); 106 QTest::qWait(1);
107 } 107 }
108 QCOMPARE(list.size(), expectedSize); 108 Q_ASSERT(list.size() == expectedSize);
109 109
110 const auto elapsed = time.elapsed(); 110 const auto elapsed = time.elapsed();
111 111
@@ -127,21 +127,15 @@ class MailQueryBenchmark : public QObject
127 std::cout << "Rss without db [kb]: " << rssWithoutDb / 1024 << std::endl; 127 std::cout << "Rss without db [kb]: " << rssWithoutDb / 1024 << std::endl;
128 std::cout << "Percentage error: " << percentageRssError << std::endl; 128 std::cout << "Percentage error: " << percentageRssError << std::endl;
129 129
130 HAWD::Dataset dataset(name, mHawdState); 130 Q_ASSERT(percentageRssError < 10);
131 HAWD::Dataset::Row row = dataset.row();
132 row.setValue("rows", list.size());
133 row.setValue("queryResultPerMs", (qreal)list.size() / elapsed);
134 dataset.insertRow(row);
135 HAWD::Formatter::print(dataset);
136
137 QVERIFY(percentageRssError < 10);
138 // TODO This is much more than it should it seems, although adding the attachment results in pretty exactly a 1k increase, 131 // TODO This is much more than it should it seems, although adding the attachment results in pretty exactly a 1k increase,
139 // so it doesn't look like that memory is being duplicated. 132 // so it doesn't look like that memory is being duplicated.
140 QVERIFY(rssGrowthPerEntity < 3300); 133 Q_ASSERT(rssGrowthPerEntity < 3300);
141 134
142 // Print memory layout, RSS is what is in memory 135 // Print memory layout, RSS is what is in memory
143 // std::system("exec pmap -x \"$PPID\""); 136 // std::system("exec pmap -x \"$PPID\"");
144 // std::system("top -p \"$PPID\" -b -n 1"); 137 // std::system("top -p \"$PPID\" -b -n 1");
138 return (qreal)list.size() / elapsed;
145 } 139 }
146 140
147private slots: 141private slots:
@@ -153,33 +147,43 @@ private slots:
153 147
154 void test50k() 148 void test50k()
155 { 149 {
156 Sink::Query query;
157 query.request<Mail::MessageId>()
158 .request<Mail::Subject>()
159 .request<Mail::Date>();
160 query.sort<Mail::Date>();
161 query.filter<Mail::Folder>("folder1");
162 query.limit(1000);
163
164 populateDatabase(50000);
165 testLoad("mail_query", query, 50000, query.limit());
166 }
167
168 void test50kThreadleader()
169 {
170 Sink::Query query;
171 query.request<Mail::MessageId>()
172 .request<Mail::Subject>()
173 .request<Mail::Date>();
174 // query.filter<ApplicationDomain::Mail::Trash>(false);
175 query.reduce<ApplicationDomain::Mail::Folder>(Query::Reduce::Selector::max<ApplicationDomain::Mail::Date>());
176 query.limit(1000);
177
178 int mailsPerFolder = 10;
179
180 int count = 50000; 150 int count = 50000;
181 populateDatabase(count, mailsPerFolder); 151 int limit = 1000;
182 testLoad("mail_query_threadleader", query, count, query.limit()); 152 qreal simpleResultRate = 0;
153 qreal threadResultRate = 0;
154 {
155 Sink::Query query;
156 query.request<Mail::MessageId>()
157 .request<Mail::Subject>()
158 .request<Mail::Date>();
159 query.sort<Mail::Date>();
160 query.filter<Mail::Folder>("folder1");
161 query.limit(limit);
162
163 populateDatabase(count);
164 simpleResultRate = testLoad(query, count, query.limit());
165 }
166 {
167 Sink::Query query;
168 query.request<Mail::MessageId>()
169 .request<Mail::Subject>()
170 .request<Mail::Date>();
171 // query.filter<ApplicationDomain::Mail::Trash>(false);
172 query.reduce<ApplicationDomain::Mail::Folder>(Query::Reduce::Selector::max<ApplicationDomain::Mail::Date>());
173 query.limit(limit);
174
175 int mailsPerFolder = 10;
176
177 populateDatabase(count, mailsPerFolder);
178 threadResultRate = testLoad(query, count, query.limit());
179 }
180 HAWD::Dataset dataset("mail_query", mHawdState);
181 HAWD::Dataset::Row row = dataset.row();
182 row.setValue("rows", limit);
183 row.setValue("simple", simpleResultRate);
184 row.setValue("threadleader", threadResultRate);
185 dataset.insertRow(row);
186 HAWD::Formatter::print(dataset);
183 } 187 }
184 188
185 void testIncremental() 189 void testIncremental()