From db093346949db4a88185ae775093133b017d3c7e Mon Sep 17 00:00:00 2001 From: Radu Berinde Date: Tue, 14 May 2024 08:38:00 -0700 Subject: [PATCH] tool: add `db lsm` flag to show LSM viewer URL We add a `--url` flag to the `pebble db lsm` command which prints out an LSM viewer URL. --- tool/db.go | 7 +++++++ tool/testdata/db_lsm | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tool/db.go b/tool/db.go index 5909d64101..184ceaf859 100644 --- a/tool/db.go +++ b/tool/db.go @@ -66,6 +66,7 @@ type dbT struct { ioSizes string verbose bool bypassPrompt bool + lsmURL bool } func newDB( @@ -210,6 +211,9 @@ specified database. &d.fmtValue, "value", "value formatter") } + d.LSM.Flags().BoolVar( + &d.lsmURL, "url", false, "generate LSM viewer URL") + d.Space.Flags().Var( &d.start, "start", "start key for the range") d.Space.Flags().Var( @@ -445,6 +449,9 @@ func (d *dbT) runLSM(cmd *cobra.Command, args []string) { defer d.closeDB(stderr, db) fmt.Fprintf(stdout, "%s", db.Metrics()) + if d.lsmURL { + fmt.Fprintf(stdout, "\nLSM viewer: %s\n", db.LSMViewURL()) + } } func (d *dbT) runScan(cmd *cobra.Command, args []string) { diff --git a/tool/testdata/db_lsm b/tool/testdata/db_lsm index d6e459657c..587953663c 100644 --- a/tool/testdata/db_lsm +++ b/tool/testdata/db_lsm @@ -38,3 +38,40 @@ Snapshots: 0 earliest seq num: 0 Table iters: 0 Filter utility: 0.0% Ingestions: 0 as flushable: 0 (0B in 0 tables) + +db lsm --url +../testdata/db-stage-4 +---- +---- + | | | | ingested | moved | written | | amp +level | tables size val-bl vtables | score | in | tables size | tables size | tables size | read | r w +------+-----------------------------+-------+-------+--------------+--------------+--------------+-------+--------- + 0 | 1 709B 0B 0 | 0.50 | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 + 1 | 0 0B 0B 0 | 0.00 | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 + 2 | 0 0B 0B 0 | 0.00 | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 + 3 | 0 0B 0B 0 | 0.00 | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 + 4 | 0 0B 0B 0 | 0.00 | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 + 5 | 0 0B 0B 0 | 0.00 | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 + 6 | 0 0B 0B 0 | - | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 +total | 1 709B 0B 0 | - | 0B | 0 0B | 0 0B | 0 0B | 0B | 0 0.0 +------------------------------------------------------------------------------------------------------------------- +WAL: 0 files (0B) in: 0B written: 0B (0% overhead) +Flushes: 0 +Compactions: 0 estimated debt: 0B in progress: 0 (0B) + default: 0 delete: 0 elision: 0 move: 0 read: 0 rewrite: 0 copy: 0 multi-level: 0 +MemTables: 1 (256KB) zombie: 0 (0B) +Zombie tables: 0 (0B, local: 0B) +Backing tables: 0 (0B) +Virtual tables: 0 (0B) +Local tables size: 709B +Block cache: 0 entries (0B) hit rate: 0.0% +Table cache: 0 entries (0B) hit rate: 0.0% +Secondary cache: 0 entries (0B) hit rate: 0.0% +Snapshots: 0 earliest seq num: 0 +Table iters: 0 +Filter utility: 0.0% +Ingestions: 0 as flushable: 0 (0B in 0 tables) + +LSM viewer: https://raduberinde.github.io/lsmview/decode.html#eJyE0EFLw0AQBeC7v2J4uU5lN42W7lHsrTe9SSgTOi2hm13NRqGV_HdJCaUWMXvaxzfMwPuG1y_1Ce5t_G6CNAqHtbk3YHRSeR1ZKvVwKMBI9UnhFmbJSI14r6nbHPQIZxhe2v0lW8ZWO6nPJ2CGVziqpM1swc-rNc1oF2Nm5_yyeh0XO1qY5dMQ9CN8NsmRzWlGdjj8HuvQpf820JWN8ZTZ_KI3wyFSK2GvtB1qKPuy59sm7HUPf3g-4fMJLyb8YcIff3vJOOjx3HclLRi7GFH2dz8BAAD__2dulBM= +---- +----