Skip to content

Commit 9ada583

Browse files
authored
bench: Compression Size summary counts l_comment once, leaves out statpopgen, and shows each format's total size (#216)
1 parent 0741935 commit 9ada583

14 files changed

Lines changed: 375 additions & 47 deletions

‎src/bench/components/SummaryCard.test.tsx‎

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,26 @@ describe('SummaryCard', () => {
140140
expect(html.match(/#1/g)).toHaveLength(2);
141141
});
142142

143+
it('shows a dash for a size total the formats cannot share', () => {
144+
const html = render({
145+
type: 'compressionSize',
146+
title: 'Compression Size Summary',
147+
rankings: [
148+
{
149+
name: 'parquet',
150+
minRatio: 1,
151+
ratio: 1,
152+
maxRatio: 1,
153+
compressionRatio: 4,
154+
totalBytes: null,
155+
},
156+
],
157+
explanation: 'e',
158+
});
159+
expect(html).toContain('class="score-runtime compression-size-value">—</span>');
160+
expect(html).toContain('class="compression-size-heading compression-size-total-unit"></span>');
161+
});
162+
143163
it('renders nothing for a compression card with no rankings', () => {
144164
expect(render({ type: 'compression', title: 't', rankings: [], explanation: 'e' })).toBe('');
145165
});
@@ -155,20 +175,23 @@ describe('SummaryCard', () => {
155175
ratio: 0.45,
156176
maxRatio: 1.55,
157177
compressionRatio: 8.25,
178+
totalBytes: 1_603_980_000,
158179
},
159180
{
160181
name: 'parquet',
161182
minRatio: 1,
162183
ratio: 1,
163184
maxRatio: 1,
164185
compressionRatio: 4.5,
186+
totalBytes: 1_428_150_000,
165187
},
166188
{
167189
name: 'lance',
168190
minRatio: 1.1,
169191
ratio: 1.2,
170192
maxRatio: 1.3,
171193
compressionRatio: null,
194+
totalBytes: 2_500_000,
172195
},
173196
],
174197
explanation: 'higher is better',
@@ -177,25 +200,42 @@ describe('SummaryCard', () => {
177200
expect(html).toContain('class="compression-size-scores"');
178201
expect(html).toContain('>vs Arrow<');
179202
expect(html).toContain('>vs Parquet<');
180-
expect(html).not.toContain('GeoMean');
181-
expect(html.match(/>Mean</g)).toHaveLength(1);
203+
expect(html.match(/>GeoMean</g)).toHaveLength(1);
204+
expect(html).not.toContain('>Mean<');
205+
expect(html.match(/>Total</g)).toHaveLength(1);
182206
expect(html).toContain('>Min<');
183207
expect(html).toContain('>Max<');
184208
expect(html).not.toMatch(/⬇️|📊|⬆️/);
185209
expect(html).toContain('class="score-value compression-size-value">8.25x</span>');
186-
expect(html).toContain('class="score-runtime compression-size-value">0.55x</span>');
210+
expect(html).toContain(
211+
'class="score-runtime compression-size-value compression-size-range">0.55x</span>',
212+
);
187213
expect(html).toContain('class="score-value compression-size-value">0.45x</span>');
188-
expect(html).toContain('class="score-runtime compression-size-value">1.55x</span>');
214+
expect(html).toContain(
215+
'class="score-runtime compression-size-value compression-size-range">1.55x</span>',
216+
);
217+
// Phones hide Min and Max, never the geomean.
218+
expect(html.match(/compression-size-range/g)).toHaveLength(2 + 2 * 3);
189219
expect(html.indexOf('8.25x')).toBeLessThan(html.indexOf('0.55x'));
220+
// Every total is in one unit, which the header names once.
221+
expect(html).toContain(
222+
'class="compression-size-heading compression-size-total-unit">MB</span>',
223+
);
224+
const total = (value: string) =>
225+
`class="score-runtime compression-size-value"><span class="vx-sr-only">Total: </span>${value}<span class="vx-sr-only"> MB</span></span>`;
226+
expect(html).toContain(total('1,604.0'));
227+
expect(html).toContain(total('1,428.2'));
228+
expect(html).toContain(total('2.5'));
229+
// Total sits between the format's name and its ratio to Arrow.
230+
expect(html.indexOf('1,604.0')).toBeLessThan(html.indexOf('8.25x'));
190231
expect(html).toContain('parquet');
191232
expect(html).toContain('lance');
192233
expect(html).toContain('class="score-rank">#3</span>');
193234
expect(html).toContain('class="score-value compression-size-value">—</span>');
194235
expect(html).toContain(
195-
'class="vx-sr-only">vortex: minimum 0.55x, mean 0.45x, maximum 1.55x</span>',
236+
'class="vx-sr-only">vortex: minimum 0.55x, geometric mean 0.45x, maximum 1.55x</span>',
196237
);
197238
expect(html).toContain('aria-hidden="true"');
198-
expect(html).not.toContain('GB');
199239
});
200240

201241
it('renders a queryBenchmark card with scores and total runtimes', () => {
@@ -264,8 +304,22 @@ describe('SummaryCard', () => {
264304
type: 'compressionSize',
265305
title: 'Compression Size Summary',
266306
rankings: [
267-
{ name: 'vortex-file-compressed', minRatio: 1, ratio: 1, maxRatio: 1, compressionRatio: 8 },
268-
{ name: 'lance', minRatio: 1, ratio: 1, maxRatio: 1, compressionRatio: 2 },
307+
{
308+
name: 'vortex-file-compressed',
309+
minRatio: 1,
310+
ratio: 1,
311+
maxRatio: 1,
312+
compressionRatio: 8,
313+
totalBytes: 100,
314+
},
315+
{
316+
name: 'lance',
317+
minRatio: 1,
318+
ratio: 1,
319+
maxRatio: 1,
320+
compressionRatio: 2,
321+
totalBytes: 200,
322+
},
269323
],
270324
explanation: 'e',
271325
});

‎src/bench/components/SummaryCard.tsx‎

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
import { displayFormat, displaySeriesLabel } from '@/bench/lib/chart-format';
5-
import { formatCompressionSizeRatio, formatThroughput, formatTimeNs } from '@/bench/lib/format';
5+
import {
6+
byteUnit,
7+
formatBytesIn,
8+
formatCompressionSizeRatio,
9+
formatThroughput,
10+
formatTimeNs,
11+
} from '@/bench/lib/format';
612
import type { SeriesRanking, Summary } from '@/bench/lib/summary';
713

814
/**
@@ -119,11 +125,20 @@ export function SummaryCard({ summary }: { summary?: Summary | undefined }) {
119125
if (summary.rankings.length === 0) {
120126
return null;
121127
}
128+
// One unit for every total, named once in the header, so the rows compare at a glance.
129+
const totals = summary.rankings.flatMap((item) =>
130+
item.totalBytes === null ? [] : [item.totalBytes],
131+
);
132+
const totalUnit = totals.length === 0 ? null : byteUnit(Math.max(...totals));
122133
return (
123134
<section className="benchmark-scores-summary" aria-label={summary.title}>
124135
<div className="compression-size-scores">
125136
<div className="compression-size-panel compression-size-arrow-panel">
126137
<div className="compression-size-arrow-header">
138+
<span className="compression-size-group compression-size-total-group">Total</span>
139+
<span className="compression-size-heading compression-size-total-unit">
140+
{totalUnit}
141+
</span>
127142
<span className="compression-size-group">vs Arrow</span>
128143
</div>
129144
<div className="compression-size-arrow-list">
@@ -138,6 +153,17 @@ export function SummaryCard({ summary }: { summary?: Summary | undefined }) {
138153
<span className="score-series" title={label}>
139154
{label}
140155
</span>
156+
<span className="score-runtime compression-size-value">
157+
{item.totalBytes === null || totalUnit === null ? (
158+
'—'
159+
) : (
160+
<>
161+
<span className="vx-sr-only">Total: </span>
162+
{formatBytesIn(item.totalBytes, totalUnit)}
163+
<span className="vx-sr-only"> {totalUnit}</span>
164+
</>
165+
)}
166+
</span>
141167
<span className="score-value compression-size-value">
142168
{item.compressionRatio === null
143169
? '—'
@@ -151,9 +177,9 @@ export function SummaryCard({ summary }: { summary?: Summary | undefined }) {
151177
<div className="compression-size-panel compression-size-parquet-panel">
152178
<div className="compression-size-parquet-header">
153179
<span className="compression-size-group">vs {summary.baseline ?? 'Parquet'}</span>
154-
<span className="compression-size-heading">Min</span>
155-
<span className="compression-size-heading">Mean</span>
156-
<span className="compression-size-heading">Max</span>
180+
<span className="compression-size-heading compression-size-range">Min</span>
181+
<span className="compression-size-heading">GeoMean</span>
182+
<span className="compression-size-heading compression-size-range">Max</span>
157183
</div>
158184
<div className="compression-size-parquet-list">
159185
{summary.rankings.map((item) => {
@@ -166,15 +192,21 @@ export function SummaryCard({ summary }: { summary?: Summary | undefined }) {
166192
key={item.name}
167193
>
168194
<span className="vx-sr-only">
169-
{`${displayFormat(item.name)}: minimum ${minRatio}, mean ${meanRatio}, maximum ${maxRatio}`}
195+
{`${displayFormat(item.name)}: minimum ${minRatio}, geometric mean ${meanRatio}, maximum ${maxRatio}`}
170196
</span>
171-
<span aria-hidden="true" className="score-runtime compression-size-value">
197+
<span
198+
aria-hidden="true"
199+
className="score-runtime compression-size-value compression-size-range"
200+
>
172201
{minRatio}
173202
</span>
174203
<span aria-hidden="true" className="score-value compression-size-value">
175204
{meanRatio}
176205
</span>
177-
<span aria-hidden="true" className="score-runtime compression-size-value">
206+
<span
207+
aria-hidden="true"
208+
className="score-runtime compression-size-value compression-size-range"
209+
>
178210
{maxRatio}
179211
</span>
180212
</div>

‎src/bench/lib/compression-suite.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ export const SUMMARY_EXCLUDED_DATASET_PATTERNS: readonly string[] = [
2626
'sparse-wide-%',
2727
];
2828

29+
/**
30+
* `LIKE` patterns for the datasets the compression size summary also leaves out, on top of
31+
* `SUMMARY_EXCLUDED_DATASET_PATTERNS`. They still chart in the group, and the compression time
32+
* summary keeps them.
33+
*
34+
* - `tpc-h l_comment chunked` writes the same column as `tpc-h l_comment canonical`, so their
35+
* files are the same size. Only the input to the encoder differs, which matters for time but
36+
* not for size. The size summary counts the column once, as `canonical`.
37+
* - `statpopgen`, which joined `compress-bench` on 2026-11-06, is left out of the size summary.
38+
* The pattern also matches the older `statpopgen/100000` rows, which have no Parquet size and
39+
* so were never in the summary.
40+
*
41+
* Both names are exact. `_` is a `LIKE` wildcard, but no other dataset name matches.
42+
*/
43+
export const SIZE_SUMMARY_EXCLUDED_DATASET_PATTERNS: readonly string[] = [
44+
...SUMMARY_EXCLUDED_DATASET_PATTERNS,
45+
'tpc-h l_comment chunked',
46+
'statpopgen',
47+
];
48+
2949
export function compressionSuite(dataset: string): CompressionSuite {
3050
return dataset.startsWith(STRING_DATASET_PREFIX) ? 'strings' : 'compress';
3151
}

‎src/bench/lib/data-cache.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ describe('data-cache wrappers', () => {
6969
expect(BENCH_DATA_TAG).toBe('bench-data');
7070
expect(DATA_CACHE_BACKSTOP_SECONDS).toBe(86400);
7171
expect(cacheCalls.map((call) => call.keyParts)).toContainEqual([
72-
'data-cache:group-charts:v11:n100',
72+
'data-cache:group-charts:v12:n100',
7373
]);
74-
expect(cacheCalls.map((call) => call.keyParts)).toContainEqual(['data-cache:groups:v11']);
74+
expect(cacheCalls.map((call) => call.keyParts)).toContainEqual(['data-cache:groups:v12']);
7575
for (const call of cacheCalls) {
7676
expect(call.options.tags).toEqual([BENCH_DATA_TAG]);
7777
expect(call.options.revalidate).toBe(DATA_CACHE_BACKSTOP_SECONDS);

‎src/bench/lib/data-cache.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const CACHE_OPTIONS = { tags: [BENCH_DATA_TAG], revalidate: DATA_CACHE_BACKSTOP_
5757
* code can serve payloads the old code computed until the next ingest.
5858
* It is independent of the producer-facing benchmark schema version.
5959
*/
60-
const GROUP_PAYLOAD_CACHE_VERSION = 'v11';
60+
const GROUP_PAYLOAD_CACHE_VERSION = 'v12';
6161

6262
// The default last-100 group bundle, keyed by group slug. The slug is the cache
6363
// key (an `unstable_cache` argument), so one wrapper covers every group. A

‎src/bench/lib/format.test.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { describe, expect, it } from 'vitest';
55

6-
import { formatTimeNs } from './format';
6+
import { byteUnit, formatBytes, formatBytesIn, formatTimeNs } from './format';
77

88
describe('formatTimeNs', () => {
99
it('renders sub-microsecond values as whole nanoseconds', () => {
@@ -40,3 +40,25 @@ describe('formatTimeNs', () => {
4040
expect(formatTimeNs(-2_000_000)).toBe('-2.00 ms');
4141
});
4242
});
43+
44+
describe('formatBytes', () => {
45+
it('keeps sizes from 1 MB up in MB, with a thousands separator', () => {
46+
expect(formatBytes(1_000_000)).toBe('1.0 MB');
47+
expect(formatBytes(1_428_150_000)).toBe('1,428.2 MB');
48+
expect(formatBytes(20_000_000_000)).toBe('20,000.0 MB');
49+
});
50+
51+
it('uses KB and B below 1 MB', () => {
52+
expect(formatBytes(999_949)).toBe('999.9 KB');
53+
expect(formatBytes(2_500)).toBe('2.5 KB');
54+
expect(formatBytes(999)).toBe('999 B');
55+
});
56+
57+
it('gives a set of sizes the unit of its largest', () => {
58+
const unit = byteUnit(1_428_150_000);
59+
expect(unit).toBe('MB');
60+
expect(formatBytesIn(2_500, unit)).toBe('0.0');
61+
expect(formatBytesIn(1_428_150_000, unit)).toBe('1,428.2');
62+
expect(formatBytesIn(999.6, 'B')).toBe('1000');
63+
});
64+
});

‎src/bench/lib/format.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,40 @@ export function formatCompressionSizeRatio(value: number): string {
3535
return `${Number(value.toPrecision(3))}x`;
3636
}
3737

38+
const BYTES_FORMAT = new Intl.NumberFormat('en-US', {
39+
minimumFractionDigits: 1,
40+
maximumFractionDigits: 1,
41+
});
42+
43+
/** A decimal byte unit. Sizes stay in MB from 1 MB up, so large totals compare at a glance. */
44+
export type ByteUnit = 'MB' | 'KB' | 'B';
45+
46+
/** The unit `formatBytes` gives `bytes`. Pass the largest of a set to give the set one unit. */
47+
export function byteUnit(bytes: number): ByteUnit {
48+
if (bytes >= 1_000_000) {
49+
return 'MB';
50+
}
51+
return bytes >= 1_000 ? 'KB' : 'B';
52+
}
53+
54+
/** A byte count in `unit` without the unit: one decimal place for MB and KB, as `1,428.2`. */
55+
export function formatBytesIn(bytes: number, unit: ByteUnit): string {
56+
switch (unit) {
57+
case 'MB':
58+
return BYTES_FORMAT.format(bytes / 1_000_000);
59+
case 'KB':
60+
return BYTES_FORMAT.format(bytes / 1_000);
61+
case 'B':
62+
return String(Math.round(bytes));
63+
}
64+
}
65+
66+
/** A byte count in decimal units, as `1,428.2 MB`. */
67+
export function formatBytes(bytes: number): string {
68+
const unit = byteUnit(bytes);
69+
return `${formatBytesIn(bytes, unit)} ${unit}`;
70+
}
71+
3872
/** Aggregate throughput as the summary card shows it: MB/s for writes, GB/s for scans. */
3973
export function formatThroughput(valueGbS: number, operation: 'encode' | 'decode'): string {
4074
return operation === 'encode'

‎src/bench/lib/headline.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ describe('groupHeadline', () => {
185185
type: 'compressionSize',
186186
title: 's',
187187
explanation: 'e',
188-
rankings: [{ name: VX, minRatio: ratio, ratio, maxRatio: ratio, compressionRatio: 5 }],
188+
rankings: [
189+
{ name: VX, minRatio: ratio, ratio, maxRatio: ratio, compressionRatio: 5, totalBytes: 1 },
190+
],
189191
});
190192
expect(h && headlineText(h)).toBe(expected);
191193
expect(h?.parts[0]?.tone).toBe(tone);

‎src/bench/lib/methodology.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export const METHODOLOGY: readonly MethodologySection[] = [
9898
'rank well by skipping work. Each summary says how many a series ran.',
9999
`Write and scan throughput scores are ${SCORES.throughput}`,
100100
`File size scores are ${SCORES.size}`,
101+
'Total is the sum of a format’s file sizes over the datasets that every format has.',
102+
'The compression summaries leave out the wide table and sparse-wide datasets, which ' +
103+
'have many variants each. The file size summary also leaves out statpopgen, and counts ' +
104+
'the TPC-H l_comment column once, because its canonical and chunked files are the ' +
105+
'same size. These datasets still have charts.',
101106
'The string encoding benchmark compares its encoders with FSST instead of Parquet, so ' +
102107
'its throughput and size scores divide by FSST’s.',
103108
'Each summary uses each series’ newest result on develop.',

‎src/bench/lib/site-files.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,19 @@ describe('summaryLines', () => {
129129
title: 't',
130130
explanation: 'e',
131131
rankings: [
132-
{ name: VX, minRatio: 0.677, ratio: 1.137, maxRatio: 1.549, compressionRatio: 5.744 },
132+
{
133+
name: VX,
134+
minRatio: 0.677,
135+
ratio: 1.137,
136+
maxRatio: 1.549,
137+
compressionRatio: 5.744,
138+
totalBytes: 1_603_980_000,
139+
},
133140
],
134141
}).at(-1),
135142
).toBe(
136143
'1. Vortex: 1.14x the size of Parquet (from 0.677x to 1.55x across datasets), ' +
137-
'5.74x smaller than Arrow in memory',
144+
'5.74x smaller than Arrow in memory, 1,604.0 MB in total',
138145
);
139146
});
140147
});

0 commit comments

Comments
 (0)