Skip to content

Commit 687a1b7

Browse files
committed
metrics: use a table for compression metrics
1 parent 0f27635 commit 687a1b7

File tree

7 files changed

+72
-46
lines changed

7 files changed

+72
-46
lines changed

metrics.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,11 @@ var (
750750
table.Div(),
751751
table.String("range dels", 15, table.AlignRight, func(i keysInfo) string { return i.rangeDels }),
752752
)
753+
compressionTableHeader = `COMPRESSION`
754+
compressionTable = table.Define[pair[string, int64]](
755+
table.String("algorithm", 10, table.AlignRight, func(p pair[string, int64]) string { return p.k }),
756+
table.Count("tables", 10, table.AlignRight, func(p pair[string, int64]) int64 { return p.v }),
757+
)
753758
)
754759

755760
type commitPipelineInfo struct {
@@ -983,21 +988,17 @@ func (m *Metrics) String() string {
983988
cur = keysInfoTable.Render(cur, table.RenderOptions{}, oneItemIter(keysInfoContents))
984989
cur = cur.NewlineReturn()
985990

986-
func(cur ascii.Cursor) {
987-
maybePrintCompression := func(pos ascii.Cursor, name string, value int64) ascii.Cursor {
988-
if value > 0 {
989-
pos = pos.Printf(" %s %s", name, humanizeCount(value)).NewlineReturn()
990-
}
991-
return pos
992-
}
993-
cur = cur.WriteString("COMPRESSION").NewlineReturn()
994-
cur = maybePrintCompression(cur, "minlz: ", m.Table.CompressedCountMinLZ)
995-
cur = maybePrintCompression(cur, "snappy:", m.Table.CompressedCountSnappy)
996-
cur = maybePrintCompression(cur, "zstd: ", m.Table.CompressedCountZstd)
997-
cur = maybePrintCompression(cur, "none: ", m.Table.CompressedCountNone)
998-
cur = maybePrintCompression(cur, "???: ", m.Table.CompressedCountUnknown)
999-
_ = cur
1000-
}(cur)
991+
cur = cur.WriteString(compressionTableHeader).NewlineReturn()
992+
compressionContents := []pair[string, int64]{
993+
{k: "none", v: m.Table.CompressedCountNone},
994+
{k: "snappy", v: m.Table.CompressedCountSnappy},
995+
{k: "minlz", v: m.Table.CompressedCountMinLZ},
996+
{k: "zstd", v: m.Table.CompressedCountZstd},
997+
}
998+
if m.Table.CompressedCountUnknown > 0 {
999+
compressionContents = append(compressionContents, pair[string, int64]{k: "???", v: m.Table.CompressedCountUnknown})
1000+
}
1001+
compressionTable.Render(cur, table.RenderOptions{Orientation: table.Horizontally}, slices.Values(compressionContents))
10011002

10021003
return wb.String()
10031004
}

testdata/compaction/l0_to_lbase_compaction

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ KEYS
9191
0 | 0 | 0 | 0B | 0B
9292

9393
COMPRESSION
94-
snappy: 3
94+
algorithm | none snappy minlz zstd
95+
tables | 0 3 0 0
9596
----
9697
----

testdata/compaction/value_separation

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ KEYS
179179
0 | 0 | 0 | 0B | 0B
180180

181181
COMPRESSION
182-
snappy: 1
182+
algorithm | none snappy minlz zstd
183+
tables | 0 1 0 0
183184
----
184185
----
185186

@@ -450,7 +451,8 @@ KEYS
450451
0 | 0 | 0 | 0B | 0B
451452

452453
COMPRESSION
453-
snappy: 1
454+
algorithm | none snappy minlz zstd
455+
tables | 0 1 0 0
454456
----
455457
----
456458

testdata/event_listener

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ KEYS
301301
0 | 0 | 0 | 0B | 0B
302302

303303
COMPRESSION
304-
snappy: 3
304+
algorithm | none snappy minlz zstd
305+
tables | 0 3 0 0
305306
----
306307
----
307308

@@ -437,7 +438,8 @@ KEYS
437438
0 | 0 | 0 | 0B | 0B
438439

439440
COMPRESSION
440-
snappy: 6
441+
algorithm | none snappy minlz zstd
442+
tables | 0 6 0 0
441443
----
442444
----
443445

testdata/ingest

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ KEYS
9090
0 | 0 | 0 | 0B | 0B
9191

9292
COMPRESSION
93-
snappy: 1
93+
algorithm | none snappy minlz zstd
94+
tables | 0 1 0 0
9495
----
9596
----
9697

testdata/metrics

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ KEYS
5959
123 | 456 | 789!! | 1MB | 2MB
6060

6161
COMPRESSION
62-
minlz: 32
63-
snappy: 33
64-
zstd: 34
65-
none: 35
62+
algorithm | none snappy minlz zstd
63+
tables | 35 33 32 34
6664
----
6765
----
6866

@@ -147,7 +145,8 @@ KEYS
147145
0 | 0 | 0 | 0B | 0B
148146

149147
COMPRESSION
150-
snappy: 1
148+
algorithm | none snappy minlz zstd
149+
tables | 0 1 0 0
151150
Iter category stats:
152151
pebble-compaction, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
153152
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -243,7 +242,8 @@ KEYS
243242
0 | 0 | 0 | 0B | 0B
244243

245244
COMPRESSION
246-
snappy: 2
245+
algorithm | none snappy minlz zstd
246+
tables | 0 2 0 0
247247
Iter category stats:
248248
pebble-compaction, non-latency: {BlockBytes:224 BlockBytesInCache:112 BlockReadDuration:10ms}
249249
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -322,7 +322,8 @@ KEYS
322322
0 | 0 | 0 | 0B | 0B
323323

324324
COMPRESSION
325-
snappy: 2
325+
algorithm | none snappy minlz zstd
326+
tables | 0 2 0 0
326327
Iter category stats:
327328
pebble-compaction, non-latency: {BlockBytes:224 BlockBytesInCache:112 BlockReadDuration:10ms}
328329
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -398,7 +399,8 @@ KEYS
398399
0 | 0 | 0 | 0B | 0B
399400

400401
COMPRESSION
401-
snappy: 2
402+
algorithm | none snappy minlz zstd
403+
tables | 0 2 0 0
402404
Iter category stats:
403405
pebble-compaction, non-latency: {BlockBytes:224 BlockBytesInCache:112 BlockReadDuration:10ms}
404406
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -477,7 +479,8 @@ KEYS
477479
0 | 0 | 0 | 0B | 0B
478480

479481
COMPRESSION
480-
snappy: 2
482+
algorithm | none snappy minlz zstd
483+
tables | 0 2 0 0
481484
Iter category stats:
482485
pebble-compaction, non-latency: {BlockBytes:224 BlockBytesInCache:112 BlockReadDuration:10ms}
483486
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -595,7 +598,8 @@ KEYS
595598
0 | 0 | 0 | 0B | 0B
596599

597600
COMPRESSION
598-
snappy: 9
601+
algorithm | none snappy minlz zstd
602+
tables | 0 9 0 0
599603
Iter category stats:
600604
pebble-compaction, non-latency: {BlockBytes:224 BlockBytesInCache:112 BlockReadDuration:10ms}
601605
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -698,7 +702,8 @@ KEYS
698702
0 | 0 | 0 | 0B | 0B
699703

700704
COMPRESSION
701-
snappy: 9
705+
algorithm | none snappy minlz zstd
706+
tables | 0 9 0 0
702707
Iter category stats:
703708
pebble-compaction, non-latency: {BlockBytes:1106 BlockBytesInCache:112 BlockReadDuration:80ms}
704709
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -852,7 +857,8 @@ KEYS
852857
0 | 0 | 0 | 0B | 0B
853858

854859
COMPRESSION
855-
snappy: 15
860+
algorithm | none snappy minlz zstd
861+
tables | 0 15 0 0
856862
Iter category stats:
857863
pebble-compaction, non-latency: {BlockBytes:1106 BlockBytesInCache:112 BlockReadDuration:80ms}
858864
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -968,7 +974,8 @@ KEYS
968974
0 | 0 | 0 | 0B | 0B
969975

970976
COMPRESSION
971-
snappy: 22
977+
algorithm | none snappy minlz zstd
978+
tables | 0 22 0 0
972979
Iter category stats:
973980
pebble-compaction, non-latency: {BlockBytes:1106 BlockBytesInCache:112 BlockReadDuration:80ms}
974981
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -1096,7 +1103,8 @@ KEYS
10961103
0 | 0 | 0 | 0B | 0B
10971104

10981105
COMPRESSION
1099-
snappy: 21
1106+
algorithm | none snappy minlz zstd
1107+
tables | 0 21 0 0
11001108
Iter category stats:
11011109
pebble-compaction, non-latency: {BlockBytes:1106 BlockBytesInCache:112 BlockReadDuration:80ms}
11021110
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -1268,7 +1276,8 @@ KEYS
12681276
0 | 0 | 0 | 0B | 0B
12691277

12701278
COMPRESSION
1271-
snappy: 18
1279+
algorithm | none snappy minlz zstd
1280+
tables | 0 18 0 0
12721281
Iter category stats:
12731282
pebble-compaction, non-latency: {BlockBytes:2235 BlockBytesInCache:457 BlockReadDuration:150ms}
12741283
a, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
@@ -1357,7 +1366,8 @@ KEYS
13571366
0 | 0 | 0 | 0B | 0B
13581367

13591368
COMPRESSION
1360-
snappy: 3
1369+
algorithm | none snappy minlz zstd
1370+
tables | 0 3 0 0
13611371
Iter category stats:
13621372
pebble-compaction, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
13631373
----
@@ -1432,7 +1442,8 @@ KEYS
14321442
0 | 0 | 0 | 0B | 0B
14331443

14341444
COMPRESSION
1435-
snappy: 3
1445+
algorithm | none snappy minlz zstd
1446+
tables | 0 3 0 0
14361447
Iter category stats:
14371448
pebble-compaction, non-latency: {BlockBytes:336 BlockBytesInCache:0 BlockReadDuration:30ms}
14381449
----
@@ -1523,7 +1534,8 @@ KEYS
15231534
0 | 0 | 0 | 0B | 0B
15241535

15251536
COMPRESSION
1526-
snappy: 4
1537+
algorithm | none snappy minlz zstd
1538+
tables | 0 4 0 0
15271539
Iter category stats:
15281540
pebble-compaction, non-latency: {BlockBytes:336 BlockBytesInCache:0 BlockReadDuration:30ms}
15291541
----
@@ -1606,7 +1618,8 @@ KEYS
16061618
0 | 0 | 0 | 0B | 0B
16071619

16081620
COMPRESSION
1609-
snappy: 5
1621+
algorithm | none snappy minlz zstd
1622+
tables | 0 5 0 0
16101623
Iter category stats:
16111624
pebble-compaction, non-latency: {BlockBytes:336 BlockBytesInCache:0 BlockReadDuration:30ms}
16121625
----
@@ -1678,7 +1691,8 @@ KEYS
16781691
0 | 0 | 0 | 0B | 0B
16791692

16801693
COMPRESSION
1681-
snappy: 5
1694+
algorithm | none snappy minlz zstd
1695+
tables | 0 5 0 0
16821696
Iter category stats:
16831697
pebble-compaction, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
16841698
----
@@ -1753,7 +1767,8 @@ KEYS
17531767
0 | 0 | 0 | 0B | 0B
17541768

17551769
COMPRESSION
1756-
snappy: 3
1770+
algorithm | none snappy minlz zstd
1771+
tables | 0 3 0 0
17571772
Iter category stats:
17581773
pebble-compaction, non-latency: {BlockBytes:342 BlockBytesInCache:0 BlockReadDuration:30ms}
17591774
----
@@ -1866,7 +1881,8 @@ KEYS
18661881
0 | 3 | 0 | 502B | 1.5KB
18671882

18681883
COMPRESSION
1869-
snappy: 5
1884+
algorithm | none snappy minlz zstd
1885+
tables | 0 5 0 0
18701886
Iter category stats:
18711887
pebble-compaction, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
18721888
----
@@ -1938,7 +1954,8 @@ KEYS
19381954
0 | 3 | 0 | 502B | 1.5KB
19391955

19401956
COMPRESSION
1941-
snappy: 5
1957+
algorithm | none snappy minlz zstd
1958+
tables | 0 5 0 0
19421959
Iter category stats:
19431960
pebble-compaction, non-latency: {BlockBytes:0 BlockBytesInCache:0 BlockReadDuration:0s}
19441961
----

tool/testdata/db_lsm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ KEYS
6969
0 | 0 | 0 | 0B | 0B
7070

7171
COMPRESSION
72-
???: 1
72+
algorithm | none snappy minlz zstd ???
73+
tables | 0 0 0 0 1
7374
----
7475
----
7576

@@ -135,7 +136,8 @@ KEYS
135136
0 | 0 | 0 | 0B | 0B
136137

137138
COMPRESSION
138-
???: 1
139+
algorithm | none snappy minlz zstd ???
140+
tables | 0 0 0 0 1
139141
LSM viewer: https://raduberinde.github.io/lsmview/decode.html#eJyE0EFLw0AQBeC7v2J4uU5lN42W7lHsrTe9SSgTOi2hm13NRqGV_HdJCaUWMXvaxzfMwPuG1y_1Ce5t_G6CNAqHtbk3YHRSeR1ZKvVwKMBI9UnhFmbJSI14r6nbHPQIZxhe2v0lW8ZWO6nPJ2CGVziqpM1swc-rNc1oF2Nm5_yyeh0XO1qY5dMQ9CN8NsmRzWlGdjj8HuvQpf820JWN8ZTZ_KI3wyFSK2GvtB1qKPuy59sm7HUPf3g-4fMJLyb8YcIff3vJOOjx3HclLRi7GFH2dz8BAAD__2dulBM=
140142
----
141143
----

0 commit comments

Comments
 (0)