Skip to content

Commit 8219fbd

Browse files
committed
chore: compress benchmark report data
1 parent 7588288 commit 8219fbd

3 files changed

Lines changed: 56 additions & 3 deletions

File tree

benchmark/index.jinja

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,41 @@
292292
293293
const queries = {{ queries | tojson }};
294294
295-
const data = {{ results | tojson }};
295+
const dataGzipBase64 = "{{ results_gzip_base64 }}";
296+
let dataPlainText = "";
297+
let data = [];
298+
299+
function base64ToBytes(encoded) {
300+
const binary = atob(encoded);
301+
const bytes = new Uint8Array(binary.length);
302+
for (let i = 0; i < binary.length; i++) {
303+
bytes[i] = binary.charCodeAt(i);
304+
}
305+
return bytes;
306+
}
307+
308+
async function gunzipBase64(encoded) {
309+
if (!("DecompressionStream" in globalThis)) {
310+
throw new Error("This browser does not support gzip decompression.");
311+
}
312+
313+
const stream = new Blob([base64ToBytes(encoded)])
314+
.stream()
315+
.pipeThrough(new DecompressionStream("gzip"));
316+
return await new Response(stream).text();
317+
}
318+
319+
async function loadData() {
320+
dataPlainText = await gunzipBase64(dataGzipBase64);
321+
data = JSON.parse(dataPlainText);
322+
323+
const download = document.getElementById("download-data");
324+
if (download) {
325+
download.href = URL.createObjectURL(
326+
new Blob([dataPlainText], { type: "application/json" })
327+
);
328+
}
329+
}
296330
297331
const additional_data_size_points = [
298332
];
@@ -306,7 +340,8 @@
306340
<h1>{{ title }}</h1>
307341
<a href="https://github.com/ClickHouse/ClickBench/">Clickbench</a> |
308342
<a href="https://benchmark.databend.com/clickbench/release/{{ dataset }}.html">Release Versions</a> |
309-
<a href="{{ url }}">Changeset Detail</a>
343+
<a href="{{ url }}">Changeset Detail</a> |
344+
<a id="download-data" download="{{ dataset }}-data.json" href="">Download Plaintext Data</a>
310345
</div>
311346

312347
<table class="selectors-container stick-left">
@@ -376,6 +411,7 @@
376411
</table>
377412

378413
<script type="text/javascript">
414+
loadData().then(() => {
379415
380416
const constant_time_add = 0.01;
381417
const missing_result_penalty = 2;
@@ -935,6 +971,13 @@
935971
936972
render();
937973
updateSelectors();
974+
}).catch(error => {
975+
console.error("Failed to load benchmark data:", error);
976+
const message = document.getElementById('nothing-selected');
977+
message.textContent = `Failed to load benchmark data: ${error.message}`;
978+
message.style.display = 'block';
979+
[...document.querySelectorAll('.comparison')].map(e => e.style.display = 'none');
980+
});
938981
939982
</script>
940983
</body>

benchmark/src/bin/benchmark_cloud.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ async fn collect_query_history(
535535
r#"
536536
SELECT to_string(object_construct(
537537
'query_id', query_id,
538+
'log_type', log_type,
539+
'log_type_name', log_type_name,
538540
'query_text', query_text,
539541
'query_kind', query_kind,
540542
'sql_user', sql_user,
@@ -579,6 +581,7 @@ async fn collect_query_history(
579581
))
580582
FROM system_history.query_history
581583
WHERE query_id = '{query_id_literal}'
584+
AND log_type != 1
582585
ORDER BY event_time DESC
583586
LIMIT 1
584587
"#

benchmark/update_results.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import glob
77
import logging
88
import argparse
9+
import base64
10+
import gzip
911

1012
from jinja2 import Environment, FileSystemLoader
1113

@@ -25,6 +27,11 @@ def update_results(dataset, title, url):
2527
with open(result_file, "r") as f:
2628
results.append(json.load(f))
2729

30+
results_json = json.dumps(results, ensure_ascii=False, separators=(",", ":"))
31+
results_gzip_base64 = base64.b64encode(
32+
gzip.compress(results_json.encode("utf-8"), mtime=0)
33+
).decode("ascii")
34+
2835
logger.info("loading report template %s ...", TEMPLATE_FILE)
2936
templateLoader = FileSystemLoader(searchpath="./")
3037
templateEnv = Environment(loader=templateLoader)
@@ -35,7 +42,7 @@ def update_results(dataset, title, url):
3542
title=title,
3643
url=url,
3744
queries=queries,
38-
results=results,
45+
results_gzip_base64=results_gzip_base64,
3946
)
4047
with open(f"results/{dataset}.html", "w") as f:
4148
f.write(outputText)

0 commit comments

Comments
 (0)