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

cmd/geth: add dbstats command #21887

Closed
wants to merge 2 commits into from
Closed

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Nov 22, 2020

Small wip/poc PR that makes it possible to dump out the leveldb statistics. Might be useful for analyzing errors, e.g #21809 and syndtr/goleveldb#346

Usage examples:

[user@work go-ethereum]$ ./build/bin/geth --goerli dbstats
INFO [11-22|10:26:23.066] Maximum peer count                       ETH=50 LES=0 total=50
INFO [11-22|10:26:23.066] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
ERROR[11-22|10:26:23.077] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[11-22|10:26:23.077] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[11-22|10:26:23.077] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=1 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[11-22|10:26:23.077] Failed to enumerate USB devices          hub=ledger vendor=11415 failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[11-22|10:26:23.077] Failed to enumerate USB devices          hub=trezor vendor=21324 failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
ERROR[11-22|10:26:23.077] Failed to enumerate USB devices          hub=trezor vendor=4617  failcount=2 err="failed to initialize libusb: libusb: unknown error [code -99]"
INFO [11-22|10:26:23.078] Set global gas cap                       cap=25000000
INFO [11-22|10:26:23.078] Allocated cache and file handles         database=/home/user/.ethereum/goerli/geth/chaindata cache=1024.00MiB handles=1000
INFO [11-22|10:26:23.120] Checking stats 
Compactions
 Level |   Tables   |    Size(MB)   |    Time(sec)  |    Read(MB)   |   Write(MB)
-------+------------+---------------+---------------+---------------+---------------
   1   |         22 |      42.68468 |       0.00000 |       0.00000 |       0.00000
-------+------------+---------------+---------------+---------------+---------------
 Total |         22 |      42.68468 |       0.00000 |       0.00000 |       0.00000

[user@work go-ethereum]$ ./build/bin/geth --nousb dbstats
INFO [11-22|10:28:21.239] Maximum peer count                       ETH=50 LES=0 total=50
INFO [11-22|10:28:21.239] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [11-22|10:28:21.240] Set global gas cap                       cap=25000000
INFO [11-22|10:28:21.240] Allocated cache and file handles         database=/home/user/.ethereum/geth/chaindata cache=1024.00MiB handles=1000
INFO [11-22|10:28:21.278] Checking stats 
Compactions
 Level |   Tables   |    Size(MB)   |    Time(sec)  |    Read(MB)   |   Write(MB)
-------+------------+---------------+---------------+---------------+---------------
   0   |          2 |       0.00097 |       0.00000 |       0.00000 |       0.00000
   3   |        322 |     644.93655 |       0.00000 |       0.00000 |       0.00000
-------+------------+---------------+---------------+---------------+---------------
 Total |        324 |     644.93752 |       0.00000 |       0.00000 |       0.00000

[user@work go-ethereum]$ 

@holiman
Copy link
Contributor Author

holiman commented Nov 23, 2020

Updated this PR, the syntax is now geth leveldb.stats for checking basic stats, and geth leveldb.compact to trigger a compaction.

@@ -219,6 +221,34 @@ Use "ethereum dump 0" to dump the genesis block.`,
},
Category: "BLOCKCHAIN COMMANDS",
}
statDbCommand = cli.Command{
Copy link
Member

Choose a reason for hiding this comment

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

nitpicks, would be nice to have a new file dbcmd.go and put all db related commands there(also make the new category DATABASE COMMANDS.

@holiman
Copy link
Contributor Author

holiman commented Dec 14, 2020

Closed in favour of #22014

@holiman holiman closed this Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants