Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rocksdb usage - Replace Column Size with more accurate Total Size #6540

Merged
merged 20 commits into from
Feb 15, 2024

Conversation

siladu
Copy link
Contributor

@siladu siladu commented Feb 8, 2024

Replace "Column Size" with "Total Size" where Total Size = SST Files Size + Blob Files Size

besu --data-path=... storage rocksdb usage

e.g. with a BONSAI + X_SNAP node...

BEFORE THIS PR

| Column Family                  | Keys            | Column Size  | SST Files Size  |
|--------------------------------|-----------------|--------------|-----------------|
| BLOCKCHAIN                     | 2355141414      | 905 GiB      | 166 GiB         |
| VARIABLES                      | 26              | 120 KiB      | 240 KiB         |
| ACCOUNT_INFO_STATE             | 9634454         | 294 MiB      | 496 MiB         |
| ACCOUNT_STORAGE_STORAGE        | 24041432        | 977 MiB      | 1 GiB           |
| CODE_STORAGE                   | 37703864        | 10 GiB       | 12 GiB          |
| TRIE_BRANCH_STORAGE            | 1885032116      | 110 GiB      | 138 GiB         |
| TRIE_LOG_STORAGE               | 267301          | 14 GiB       | 17 GiB          |

Column Size Total = 905 + 0.294 + 0.977 + 10 + 110 + 14 = 1042 GB

AFTER THIS PR

| Column Family                  | Keys            | Total Size  | SST Files Size  | Blob Files Size  |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| BLOCKCHAIN                     | 2355141414      | 933 GiB     | 166 GiB         | 767 GiB          |
| VARIABLES                      | 26              | 240 KiB     | 240 KiB         | 0 B              |
| ACCOUNT_INFO_STATE             | 9634454         | 496 MiB     | 496 MiB         | 0 B              |
| ACCOUNT_STORAGE_STORAGE        | 24041432        | 1 GiB       | 1 GiB           | 0 B              |
| CODE_STORAGE                   | 37703864        | 12 GiB      | 12 GiB          | 0 B              |
| TRIE_BRANCH_STORAGE            | 1885032116      | 138 GiB     | 138 GiB         | 0 B              |
| TRIE_LOG_STORAGE               | 267301          | 17 GiB      | 17 GiB          | 0 B              |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| ESTIMATED TOTAL                | 4311820607      | 1104 GiB    | 337 GiB         | 767 GiB          |

1104 GB is much closer to the on disk result:

$du -ksch /data/besu/database
1.1T	/data/besu/database
1.1T	total

Another example with a BONSAI + X_CHECKPOINT node:

| Column Family                  | Keys            | Total Size  | SST Files Size  | Blob Files Size  |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| BLOCKCHAIN                     | 1432578448      | 685 GiB     | 101 GiB         | 583 GiB          |
| VARIABLES                      | 4970            | 89 KiB      | 89 KiB          | 0 B              |
| ACCOUNT_INFO_STATE             | 236237895       | 11 GiB      | 11 GiB          | 0 B              |
| ACCOUNT_STORAGE_STORAGE        | 1112465479      | 49 GiB      | 49 GiB          | 0 B              |
| CODE_STORAGE                   | 37702404        | 12 GiB      | 12 GiB          | 0 B              |
| TRIE_BRANCH_STORAGE            | 1853480673      | 134 GiB     | 134 GiB         | 0 B              |
| TRIE_LOG_STORAGE               | 514             | 69 MiB      | 69 MiB          | 0 B              |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| ESTIMATED TOTAL                | 4672470383      | 893 GiB     | 309 GiB         | 583 GiB          |
$ du -ksch /data/besu/database
896G	/data/besu/database
896G	total

Also dumping a bunch of stats out in...
besu --data-path=/data/besu storage rocksdb x-stats

which is useful for seeing the blobdb garbage stats (useful for #6289 (review)) among other things.

Example output for TRIE_LOG_STORAGE column family...

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Column Family: TRIE_LOG_STORAGE
cfstats:
** Compaction Stats [
] **
Level    Files   Size     Score Read(GB)  Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop Rblob(GB) Wblob(GB)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  L1      1/0   25.08 KB   0.0      0.0     0.0      0.0       0.0      0.0       0.0   0.0      0.0      0.0      0.00              0.00         0    0.000       0      0       0.0       0.0
 Sum      1/0   25.08 KB   0.0      0.0     0.0      0.0       0.0      0.0       0.0   0.0      0.0      0.0      0.00              0.00         0    0.000       0      0       0.0       0.0
 Int      0/0    0.00 KB   0.0      0.0     0.0      0.0       0.0      0.0       0.0   0.0      0.0      0.0      0.00              0.00         0    0.000       0      0       0.0       0.0

** Compaction Stats [
] **
Priority    Files   Size     Score Read(GB)  Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop Rblob(GB) Wblob(GB)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Blob file count: 2, total size: 0.0 GB, garbage size: 0.0 GB, space amp: 1.2

Uptime(secs): 11.6 total, 11.6 interval
Flush(GB): cumulative 0.000, interval 0.000
AddFile(GB): cumulative 0.000, interval 0.000
AddFile(Total Files): cumulative 0, interval 0
AddFile(L0 Files): cumulative 0, interval 0
AddFile(Keys): cumulative 0, interval 0
Cumulative compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Interval compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Write Stall (count): cf-l0-file-count-limit-delays-with-ongoing-compaction: 0, cf-l0-file-count-limit-stops-with-ongoing-compaction: 0, l0-file-count-limit-delays: 0, l0-file-count-limit-stops: 0, memtable-limit-delays: 0, memtable-limit-stops: 0, pending-compaction-bytes-delays: 0, pending-compaction-bytes-stops: 0, total-delays: 0, total-stops: 0

** File Read Latency Histogram By Level [
] **

cfstats-no-file-histogram:
** Compaction Stats [
] **
Level    Files   Size     Score Read(GB)  Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop Rblob(GB) Wblob(GB)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  L1      1/0   25.08 KB   0.0      0.0     0.0      0.0       0.0      0.0       0.0   0.0      0.0      0.0      0.00              0.00         0    0.000       0      0       0.0       0.0
 Sum      1/0   25.08 KB   0.0      0.0     0.0      0.0       0.0      0.0       0.0   0.0      0.0      0.0      0.00              0.00         0    0.000       0      0       0.0       0.0
 Int      0/0    0.00 KB   0.0      0.0     0.0      0.0       0.0      0.0       0.0   0.0      0.0      0.0      0.00              0.00         0    0.000       0      0       0.0       0.0

** Compaction Stats [
] **
Priority    Files   Size     Score Read(GB)  Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) CompMergeCPU(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop Rblob(GB) Wblob(GB)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Blob file count: 2, total size: 0.0 GB, garbage size: 0.0 GB, space amp: 1.2

Uptime(secs): 11.6 total, 11.6 interval
Flush(GB): cumulative 0.000, interval 0.000
AddFile(GB): cumulative 0.000, interval 0.000
AddFile(Total Files): cumulative 0, interval 0
AddFile(L0 Files): cumulative 0, interval 0
AddFile(Keys): cumulative 0, interval 0
Cumulative compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Interval compaction: 0.00 GB write, 0.00 MB/s write, 0.00 GB read, 0.00 MB/s read, 0.0 seconds
Write Stall (count): cf-l0-file-count-limit-delays-with-ongoing-compaction: 0, cf-l0-file-count-limit-stops-with-ongoing-compaction: 0, l0-file-count-limit-delays: 0, l0-file-count-limit-stops: 0, memtable-limit-delays: 0, memtable-limit-stops: 0, pending-compaction-bytes-delays: 0, pending-compaction-bytes-stops: 0, total-delays: 0, total-stops: 0

cf-file-histogram:
** File Read Latency Histogram By Level [
] **

cf-write-stall-stats: Write Stall (count): cf-l0-file-count-limit-delays-with-ongoing-compaction: 0, cf-l0-file-count-limit-stops-with-ongoing-compaction: 0, l0-file-count-limit-delays: 0, l0-file-count-limit-stops: 0, memtable-limit-delays: 0, memtable-limit-stops: 0, pending-compaction-bytes-delays: 0, pending-compaction-bytes-stops: 0, total-delays: 0, total-stops: 0

dbstats:
** DB Stats **
Uptime(secs): 11.6 total, 11.6 interval
Cumulative writes: 0 writes, 0 keys, 0 commit groups, 0.0 writes per commit group, ingest: 0.00 GB, 0.00 MB/s
Cumulative WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
Cumulative stall: 00:00:0.000 H:M:S, 0.0 percent
Interval writes: 0 writes, 0 keys, 0 commit groups, 0.0 writes per commit group, ingest: 0.00 MB, 0.00 MB/s
Interval WAL: 0 writes, 0 syncs, 0.00 writes per sync, written: 0.00 GB, 0.00 MB/s
Interval stall: 00:00:0.000 H:M:S, 0.0 percent
Write Stall (count): write-buffer-manager-limit-stops: 0

db-write-stall-stats: Write Stall (count): write-buffer-manager-limit-stops: 0

levelstats: Level Files Size(MB)
--------------------
  0        0        0
  1        1        0
  2        0        0
  3        0        0
  4        0        0
  5        0        0
  6        0        0

block-cache-entry-stats: Block cache LRUCache@0x7fa8a10119e0#817675 capacity: 32.00 MB seed: 2042184589 usage: 0.09 KB table_size: 1024 occupancy: 1 collections: 1 last_copies: 0 last_secs: 4e-05 secs_since: 0
Block cache entry stats(count,size,portion): Misc(1,0.00 KB,0%)

fast-block-cache-entry-stats: Block cache LRUCache@0x7fa8a10119e0#817675 capacity: 32.00 MB seed: 2042184589 usage: 0.09 KB table_size: 1024 occupancy: 1 collections: 1 last_copies: 1 last_secs: 4e-05 secs_since: 0
Block cache entry stats(count,size,portion): Misc(1,0.00 KB,0%)

num-immutable-mem-table: 0
num-immutable-mem-table-flushed: 0
mem-table-flush-pending: 0
compaction-pending: 0
background-errors: 0
cur-size-active-mem-table: 1050624
cur-size-all-mem-tables: 1050624
size-all-mem-tables: 1050624
num-entries-active-mem-table: 10
num-entries-imm-mem-tables: 0
num-deletes-active-mem-table: 5
num-deletes-imm-mem-tables: 0
estimate-num-keys: 518
estimate-table-readers-mem: 1907
is-file-deletions-enabled: 1
num-snapshots: 0
oldest-snapshot-time: 0
oldest-snapshot-sequence: 0
num-live-versions: 1
current-super-version-number: 1
estimate-live-data-size: 38820896
min-log-number-to-keep: 458779
min-obsolete-sst-number-to-keep: 18446744073709551615
base-level: 1
total-sst-files-size: 25679
live-sst-files-size: 25679
estimate-pending-compaction-bytes: 0
aggregated-table-properties: # data blocks=1; # entries=518; # deletions=0; # merge operands=0; # range deletions=0; raw key size=20720; raw average key size=40.000000; raw value size=6154; raw average value size=11.880309; data block size=23821; index block size (user-key? 1, delta-value? 1)=51; filter block size=709; # entries for filter=518; (estimated) table size=24581; filter policy name=N/A; prefix extractor name=N/A; column family ID=N/A; column family name=N/A; comparator name=N/A; merge operator name=N/A; property collectors names=N/A; SST file compression algo=N/A; SST file compression options=N/A; creation time=0; time stamp of earliest key=0; file creation time=0; slow compression estimated data size=0; fast compression estimated data size=0; DB identity=; DB session identity=; DB host id=; original file number=0; unique ID=N/A; Sequence number to time mapping=;
num-running-compactions: 0
num-running-flushes: 0
actual-delayed-write-rate: 0
is-write-stopped: 0
block-cache-capacity: 33554432
block-cache-usage: 96
block-cache-pinned-usage: 96
num-blob-files: 2
blob-stats: Number of blob files: 2
Total size of blob files: 47423532
Total size of garbage in blob files: 8628191
Blob file space amplification: 1.2224

total-blob-file-size: 47423532
live-blob-file-size: 47423532
live-blob-file-garbage-size: 8628191

Copy link

github-actions bot commented Feb 8, 2024

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.
  • I thought about the changelog and included a changelog update if required.
  • If my PR includes database changes (e.g. KeyValueSegmentIdentifier) I have thought about compatibility and performed forwards and backwards compatibility tests
  • I thought about running CI.
  • If I did not run CI, I ran as much locally as possible before pushing.

@siladu siladu force-pushed the add-blob-files-estimate-to-rocks-usage branch from de5b82e to f178a2e Compare February 8, 2024 03:08
Signed-off-by: Simon Dudley <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
@siladu siladu changed the title Add total-blob-file-size to rocksdb usage Replace Column Size with more accurate Total Size Feb 9, 2024
Signed-off-by: Simon Dudley <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
@siladu siladu marked this pull request as ready for review February 9, 2024 07:01
@siladu siladu changed the title Replace Column Size with more accurate Total Size rocksdb usage - Replace Column Size with more accurate Total Size Feb 9, 2024
@siladu siladu requested a review from ahamlat February 9, 2024 07:02
@sslivkoff
Copy link

hi. not directly related to your PR, but is the data you posted of a fully sync'd node?

@siladu
Copy link
Contributor Author

siladu commented Feb 12, 2024

hi. not directly related to your PR, but is the data you posted of a fully sync'd node?

@sslivkoff No, this is synced with X_CHECKPOINT so missing block data since before October 2020 (the deposit contract deployment).

@siladu siladu added the TeamGroot GH issues worked on by Groot Team label Feb 12, 2024
@sslivkoff
Copy link

besu storage rocksdb usage

good to know. thanks

by chance do you have access to a full besu node that you could run your improved besu storage rocksdb usage command on? I'm doing some research on state growth and it would be very helpful to have this information for besu

@siladu
Copy link
Contributor Author

siladu commented Feb 13, 2024

@sslivkoff here is one from another BONSAI node synced with X_SNAP which means it has all the blocks...

| Column Family                  | Keys            | Total Size  | SST Files Size  | Blob Files Size  |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| BLOCKCHAIN                     | 2355096053      | 933 GiB     | 166 GiB         | 767 GiB          |
| VARIABLES                      | 18              | 120 KiB     | 120 KiB         | 0 B              |
| ACCOUNT_INFO_STATE             | 9600983         | 494 MiB     | 494 MiB         | 0 B              |
| ACCOUNT_STORAGE_STORAGE        | 23995931        | 1 GiB       | 1 GiB           | 0 B              |
| CODE_STORAGE                   | 37703620        | 12 GiB      | 12 GiB          | 0 B              |
| TRIE_BRANCH_STORAGE            | 1884446327      | 138 GiB     | 138 GiB         | 0 B              |
| TRIE_LOG_STORAGE               | 266994          | 17 GiB      | 17 GiB          | 0 B              |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| ESTIMATED TOTAL                | 4311109926      | 1104 GiB    | 336 GiB         | 767 GiB          |

Is that what you mean by full node, or do you mean a full archive node?

(Note: the values may change depending on how much compacting rocksdb has done at the time of measurement. For example, restarting Besu triggers compaction and may reduce the DB size slightly)

@siladu
Copy link
Contributor Author

siladu commented Feb 13, 2024

@sslivkoff by the way, if you're interested in state DB growth, this is a very relevant up and coming feature: https://wiki.hyperledger.org/display/BESU/Limit+Trie+Logs+for+Bonsai
Hopefully ready in the release following the Dencun fork release.

@sslivkoff
Copy link

@sslivkoff here is one from another BONSAI node synced with X_SNAP which means it has all the blocks...

| Column Family                  | Keys            | Total Size  | SST Files Size  | Blob Files Size  |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| BLOCKCHAIN                     | 2355096053      | 933 GiB     | 166 GiB         | 767 GiB          |
| VARIABLES                      | 18              | 120 KiB     | 120 KiB         | 0 B              |
| ACCOUNT_INFO_STATE             | 9600983         | 494 MiB     | 494 MiB         | 0 B              |
| ACCOUNT_STORAGE_STORAGE        | 23995931        | 1 GiB       | 1 GiB           | 0 B              |
| CODE_STORAGE                   | 37703620        | 12 GiB      | 12 GiB          | 0 B              |
| TRIE_BRANCH_STORAGE            | 1884446327      | 138 GiB     | 138 GiB         | 0 B              |
| TRIE_LOG_STORAGE               | 266994          | 17 GiB      | 17 GiB          | 0 B              |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| ESTIMATED TOTAL                | 4311109926      | 1104 GiB    | 336 GiB         | 767 GiB          |

Is that what you mean by full node, or do you mean a full archive node?

(Note: the values may change depending on how much compacting rocksdb has done at the time of measurement. For example, restarting Besu triggers compaction and may reduce the DB size slightly)

this is exactly what I was looking for. thanks!

@sslivkoff
Copy link

earlier the numbers were like this

| Column Family                  | Keys            | Total Size  | SST Files Size  | Blob Files Size  |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| BLOCKCHAIN                     | 1428245080      | 681 GiB     | 101 GiB         | 580 GiB          |
| VARIABLES                      | 3121            | 115 KiB     | 115 KiB         | 0 B              |
| ACCOUNT_INFO_STATE             | 235050819       | 11 GiB      | 11 GiB          | 0 B              |
| ACCOUNT_STORAGE_STORAGE        | 1111009063      | 49 GiB      | 49 GiB          | 0 B              |
| CODE_STORAGE                   | 37676523        | 9 GiB       | 12 GiB          | 0 B              |
| TRIE_BRANCH_STORAGE            | 1842217975      | 132 GiB     | 132 GiB         | 0 B              |
| TRIE_LOG_STORAGE               | 516             | 77 MiB      | 77 MiB          | 0 B              |

this seems like a more accurate count of the accounts (~235M) and storage slots(~1.1B) for ethereum mainnet. the newer number have 9.6M accounts and 23M slots afaict. do you know where this discrepancy comes from?

@siladu
Copy link
Contributor Author

siladu commented Feb 13, 2024

@sslivkoff

earlier the numbers were like this

I've updated the description to add a re-measured version of the checkpoint synced node back in.

this seems like a more accurate count of the accounts (~235M) and storage slots(~1.1B) for ethereum mainnet. the newer number have 9.6M accounts and 23M slots afaict. do you know where this discrepancy comes from?

I suspect it's because of --Xsnapsync-synchronizer-flat-db-healing-enabled which is not enabled on the X_SNAP node I tested.

ACCOUNT_INFO_STATE and ACCOUNT_STORAGE_STORAGE are part of the flat-db which is effectively a cache on top of the traditional TRIE_BRANCH_STORAGE.

When this is enabled, we proactively populate the flat-db. Without it, it fills upon usage, so it will vary depending on how old your node is and what requests have hit it from peers for example.

@ahamlat
Copy link
Contributor

ahamlat commented Feb 13, 2024

What is the expected output of --version ? I see different values between the one displayed by the subcommand and the one returned by web3_clientVersion

besu storage rocksdb --version
besu/v24.1.1/linux-x86_64/openjdk-java-21
curl --location 'http://localhost:8545' \
--data '{
    "jsonrpc": "2.0",
    "method": "web3_clientVersion",
    "params": [],
    "id": 1
}'
{"jsonrpc":"2.0","id":1,"result":"besu/v24.1.2-dev-570fd785/linux-x86_64/openjdk-java-21"}

Copy link
Contributor

@ahamlat ahamlat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using stats besu --data-path=/data/besu storage rocksdb stats. I see some metrics that don't exist, like : couldn't get property obsolete-sst-files-size.
I already shared some of them in the my comments below. We shouldn't have these warning messages.


final PrintWriter out = spec.commandLine().getOut();

final String dbPath =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to rename parentCommand in RocksDbUsage, RocksDbSubCommand and StorageSubCommand to have a dbPath like this :
final String dbPath =
rocksDbSubCommand
.storageSubCommand
.besuCommand
.dataDir()
.toString()
.concat("/")
.concat(DATABASE_PATH);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, done!

Copy link
Contributor

@gfukushima gfukushima Feb 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace the .concat("/").concat(DATABASE_PATH); by .resolve(DATABASE_PATH)

out.println("Column Family: " + getNameById(cfHandle.getName()));

final String prefix = "rocksdb.";
final String num_files_at_level_prefix = "num-files-at-level";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this metric doesn't exist, you need to add the level number, like explain here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


final String prefix = "rocksdb.";
final String num_files_at_level_prefix = "num-files-at-level";
final String compression_ratio_at_level_prefix = "compression-ratio-at-level";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above, check here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

final String total_sst_files_size = "total-sst-files-size";
final String live_sst_files_size = "live-sst-files-size";
final String obsolete_sst_files_size = "obsolete-sst-files-size";
final String live_sst_files_size_at_temperature = "live-sst-files-size-at-temperature";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This metric is not exposed!

final String num_running_flushes = "num-running-flushes";
final String actual_delayed_write_rate = "actual-delayed-write-rate";
final String is_write_stopped = "is-write-stopped";
final String estimate_oldest_key_time = "estimate-oldest-key-time";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this metric is not available when compaction is enabled, which is the case in Besu.

@siladu
Copy link
Contributor Author

siladu commented Feb 14, 2024

I see some metrics that don't exist... We shouldn't have these warning messages.

My approach was copy/paste all the available stats from rocksdb. I removed a few that were obvious duplicates and created unnecessary noise such as the sst dumps. There's more I could remove to tidy up. However, I am not 100% all the warnings will remain warnings forever, maybe they will become useful if we reconfigure rocksdb in the future?
If you think the stats you mentioned in the comments above will never be useful then I can remove them :)

I also don't think there's much harm in the warnings. This subcommand is intended as an internal tool, unlikely useful to users. Maybe I should rename to x-stats to reflect this?

@ahamlat
Copy link
Contributor

ahamlat commented Feb 14, 2024

What is the expected output of --version ? I see different values between the one displayed by the subcommand and the one returned by web3_clientVersion

besu storage rocksdb --version
besu/v24.1.1/linux-x86_64/openjdk-java-21
curl --location 'http://localhost:8545' \
--data '{
    "jsonrpc": "2.0",
    "method": "web3_clientVersion",
    "params": [],
    "id": 1
}'
{"jsonrpc":"2.0","id":1,"result":"besu/v24.1.2-dev-570fd785/linux-x86_64/openjdk-java-21"}

This is actually working fine, my besu command was referring to another version, the one defined in the PATH, which was different from the one that was running.

@ahamlat
Copy link
Contributor

ahamlat commented Feb 14, 2024

I checked the results with the output displayed by speedb log-parser, and the output from this subcommand and the results are quite similar for the SST files, log-parser seems to not support yet blobs :

This PR (besu --data-path=/data/besu storage rocksdb usage)

| Column Family                  | Keys            | Total Size  | SST Files Size  | Blob Files Size  | 
|--------------------------------|-----------------|-------------|-----------------|------------------|
| BLOCKCHAIN                     | 1433807624      | 686 GiB     | 101 GiB         | 584 GiB          |
| VARIABLES                      | 2188            | 35 KiB      | 35 KiB          | 0 B              |
| CODE_STORAGE                   | 37547588        | 12 GiB      | 12 GiB          | 0 B              |
| TRIE_BRANCH_STORAGE            | 1851064142      | 133 GiB     | 133 GiB         | 0 B              |
| ACCOUNT_INFO_STATE             | 2878081         | 139 MiB     | 139 MiB         | 0 B              |
| ACCOUNT_STORAGE_STORAGE        | 6317580         | 288 MiB     | 288 MiB         | 0 B              |
| TRIE_LOG_STORAGE               | 54722           | 3 GiB       | 2 GiB           | 678 MiB          |
|--------------------------------|-----------------|-------------|-----------------|------------------|
| ESTIMATED TOTAL                | 3331671925      | 837 GiB     | 251 GiB         | 585 GiB          |

Speedb log-parser

--------------------------------------------------------------------------------------------------------------------------------
| Column Family | Size (*) | Avg. Key Size | Avg. Value Size |    Compaction Style   | Compression |       Filter-Policy       |
--------------------------------------------------------------------------------------------------------------------------------
|    default    |   0 B    |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|              | 101.8 GB |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|              |   0 B    |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|              |   0 B    |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|       
               | 35.4 KB  |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|       
               |   0 B    |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|              | 12.7 GB  |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|       	       | 133.9 GB |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|              | 139.2 MB |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|             | 288.7 MB |      0 B      |       0 B       | kCompactionStyleLevel |     LZ4     | bloomfilter (unknown bpk) |
|              |   0 B    |      0 B      |       0 B       |        UNKNOWN        |   UNKNOWN   | Filter Data Not Available |
|              |   0 B    |      0 B      |       0 B       |        UNKNOWN        |   UNKNOWN   | Filter Data Not Available |
|              |   0 B    |      0 B      |       0 B       |        UNKNOWN        |   UNKNOWN   | Filter Data Not Available |
|              |   0 B    |      0 B      |       0 B       |        UNKNOWN        |   UNKNOWN   | Filter Data Not Available |
--------------------------------------------------------------------------------------------------------------------------------```

Copy link
Contributor

@ahamlat ahamlat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one last suggestion is to add a line at the beginning and the end of the table to make it a complete. one (see screenshot)
image

Signed-off-by: Simon Dudley <[email protected]>
Remove nonsensical metrics
Signed-off-by: Simon Dudley <[email protected]>
Signed-off-by: Simon Dudley <[email protected]>
@siladu
Copy link
Contributor Author

siladu commented Feb 15, 2024

one last suggestion is to add a line at the beginning and the end of the table to make it a complete.

@ahamlat easy, done.
I've moved the WARN logs to DEBUG but left most metrics in so they should appear if we ever start using them.
Removed the nonsensical ones that require -level

Also, renamed to "x-stats"

Thanks for the feedback!

Signed-off-by: Simon Dudley <[email protected]>
@siladu siladu enabled auto-merge (squash) February 15, 2024 03:39
@siladu siladu merged commit c913b6d into hyperledger:main Feb 15, 2024
50 checks passed
@siladu siladu deleted the add-blob-files-estimate-to-rocks-usage branch February 15, 2024 04:18
suraneti pushed a commit to suraneti/besu that referenced this pull request Feb 24, 2024
…perledger#6540)

Add rocksdb x-stats command to print various stats for each column family

---------

Signed-off-by: Simon Dudley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TeamGroot GH issues worked on by Groot Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants