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

RSDB: metrics and performance improvements #2184

Merged
merged 5 commits into from
Sep 11, 2023

Conversation

carterqw2
Copy link
Contributor

@carterqw2 carterqw2 commented Sep 7, 2023

Description

Reuses the existing LevelDB implementation from the ethdb/leveldb module to collect LevelDB metrics for Roundstate DB as well and introduces additional metrics related to RLP-encoding.

Other changes

  • Changes default configuration for the Roundstate DB to reduce the amount of non-level0 compactions and improve performance, this change significantly reduces CPU usage and positively affects block construction times.
  • Changes configuration settings of the state db to make compactions happen less often.

Tested

Tested on the testnet.

Backwards compatibility

No breaking changes.

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit 0ed594e

coverage: 48.6% of statements across all listed packages
coverage:  59.8% of statements in consensus/istanbul
coverage:  42.7% of statements in consensus/istanbul/announce
coverage:  55.7% of statements in consensus/istanbul/backend
coverage:   0.0% of statements in consensus/istanbul/backend/backendtest
coverage:  24.3% of statements in consensus/istanbul/backend/internal/replica
coverage:  58.1% of statements in consensus/istanbul/core
coverage:  50.0% of statements in consensus/istanbul/db
coverage:   0.0% of statements in consensus/istanbul/proxy
coverage:  64.4% of statements in consensus/istanbul/uptime
coverage:  51.8% of statements in consensus/istanbul/validator
coverage:  79.2% of statements in consensus/istanbul/validator/random

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

5861 passed, 1 failed, 45 skipped

Test failures:
  TestPriorityClient: geth
    les_test.go:121: Initializing geth: [--networkid=42 init ./testdata/clique.json]
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.170] Maximum peer count ETH=175 LES=0 total=175
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.171] Set global gas inflation rate rate=1.300
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.171] Set global gas cap cap=25,000,000
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.171] Allocated cache and file handles database=/tmp/geth-test3910766448/celo/chaindata cache=16.00MiB handles=16
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.188] Writing custom genesis block
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.189] Persisted trie from memory database nodes=4 size=566.00B time="59.086µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.189] Successfully wrote genesis state database=chaindata hash=9195f2..122dcd
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.189] Allocated cache and file handles database=/tmp/geth-test3910766448/celo/lightchaindata cache=16.00MiB handles=16
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.202] Writing custom genesis block
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.203] Persisted trie from memory database nodes=4 size=566.00B time="31.055µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.203] Successfully wrote genesis state database=lightchaindata hash=9195f2..122dcd
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.203] Allocated cache and file handles database=/tmp/geth-test3910766448/celo/lightestchaindata cache=16.00MiB handles=16
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.217] Writing custom genesis block
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.217] Persisted trie from memory database nodes=4 size=566.00B time="21.065µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=-82.00B
test_cmd.go:262: (stderr:31) INFO [09-11|10:54:27.218] Successfully wrote genesis state database=lightestchaindata hash=9195f2..122dcd
les_test.go:130: Importing keys to geth
test_cmd.go:262: (stderr:32) INFO [09-11|10:54:27.252] Maximum peer count ETH=175 LES=0 total=175
test_cmd.go:262: (stderr:32) INFO [09-11|10:54:27.253] Set global gas inflation rate rate=1.300
test_cmd.go:262: (stderr:32) INFO [09-11|10:54:27.253] Set global gas cap cap=25,000,000
les_test.go:99: Starting lightserver with rpc: [--networkid=42 --port=0 --ipcpath geth-1.ipc --allow-insecure-unlock --datadir /tmp/geth-test3910766448 --password ./testdata/password.txt --unlock 0x02f0d131f1f97aef08aec6e3291b957d9efe7105 --mine --miner.validator 0x02f0d131f1f97aef08aec6e3291b957d9efe7105 --tx-fee-recipient 0x02f0d131f1f97aef08aec6e3291b957d9efe7105 --light.serve=100 --light.maxpeers=1 --nodiscover --nat=extip:127.0.0.1 --verbosity=4]
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.505] Maximum peer count ETH=175 LES=1 total=176
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.506] FS scan times list="39.374µs" set="4.524µs" diff="1.527µs"
test_cmd.go:262: (stderr:33) WARN [09-11|10:54:27.506] LES server cannot serve old transaction status and cannot connect below les/4 protocol version if transaction lookup index is limited
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.506] Sanitizing Go's GC trigger percent=100
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.506] Set global gas inflation rate rate=1.300
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.506] Set global gas cap cap=25,000,000
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.506] Allocated trie memory caches clean=154.00MiB dirty=256.00MiB
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.506] Allocated cache and file handles database=/tmp/geth-test3910766448/celo/chaindata cache=512.00MiB handles=524,288
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.552] Chain freezer table opened database=/tmp/geth-test3910766448/celo/chaindata/ancient table=receipts items=0 size=0.00B
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.555] Chain freezer table opened database=/tmp/geth-test3910766448/celo/chaindata/ancient table=diffs items=0 size=0.00B
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.557] Chain freezer table opened database=/tmp/geth-test3910766448/celo/chaindata/ancient table=headers items=0 size=0.00B
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.561] Chain freezer table opened database=/tmp/geth-test3910766448/celo/chaindata/ancient table=hashes items=0 size=0.00B
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.563] Chain freezer table opened database=/tmp/geth-test3910766448/celo/chaindata/ancient table=bodies items=0 size=0.00B
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.563] Opened ancient database database=/tmp/geth-test3910766448/celo/chaindata/ancient readonly=false
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.563] Current full block not old enough number=0 hash=9195f2..122dcd delay=90000
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.564] Initialised chain configuration config="{ChainID: 15 Homestead: 0 DAO: DAOSupport: false EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: Churrito: , Donut: , Espresso: , Gingerbread: , Gingerbread P2: , Engine: istanbul}"
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.564] Setting up Istanbul consensus engine
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.604] Initialising Ethereum protocol versions=[67] network=42 dbversion=
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.605] Loading Last State: 0
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Loaded most recent local header number=0 hash=9195f2..122dcd td=1 age=54y5mo3w
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Loaded most recent local full block number=0 hash=9195f2..122dcd td=1 age=54y5mo3w
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Loaded most recent local fast block number=0 hash=9195f2..122dcd td=1 age=54y5mo3w
test_cmd.go:262: (stderr:33) WARN [09-11|10:54:27.606] Failed to load snapshot, regenerating err="missing or corrupted snapshot"
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Rebuilding state snapshot
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Journalled generator progress progress=empty
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Start snapshot generation root=8a7a77..f86ff6
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Resuming state snapshot generation root=8a7a77..f86ff6 accounts=0 slots=0 storage=0.00B elapsed="193.668µs"
test_cmd.go:262: (stderr:33) ERROR[09-11|10:54:27.606] Error invoking evm function: EVM call failure to=0x000000000000000000000000000000000000ce10 method=getAddressFor input=0xdd9272338b91d837e1684f7353d73b6197230894243cf869282f722841df96b441303f37 maxgas=100,000 err="execution reverted" message="No Implementation set"
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Registry contract not yet deployed function=blockGasLimit registryId=0x8b91d837e1684f7353d73b6197230894243cf869282f722841df96b441303f37
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Error calling blockGasLimit err="Registry not deployed" contract=0x8b91d837e1684f7353d73b6197230894243cf869282f722841df96b441303f37
test_cmd.go:262: (stderr:33) ERROR[09-11|10:54:27.606] Error invoking evm function: EVM call failure to=0x000000000000000000000000000000000000ce10 method=getAddressFor input=0xdd92723348766a30bcca8b3c8b03b4e4b1f6510aee73f7b41aa6c7578a97040d20334f42 maxgas=100,000 err="execution reverted" message="No Implementation set"
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Registry contract not yet deployed function=gasPriceMinimumFloor registryId=0x48766a30bcca8b3c8b03b4e4b1f6510aee73f7b41aa6c7578a97040d20334f42
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Regenerated state range kind=storage prefix=0x6fc8292a2675fd2df398d2f757c44afe1b96e4c7ba26dac7ed67cdef77799ef404 root=09f508..8cb885 last=0x count=1 created=1 updated=0 untouched=0 deleted=0
test_cmd.go:262: (stderr:33) ERROR[09-11|10:54:27.606] Error invoking evm function: EVM call failure to=0x000000000000000000000000000000000000ce10 method=getAddressFor input=0xdd9272338b91d837e1684f7353d73b6197230894243cf869282f722841df96b441303f37 maxgas=100,000 err="execution reverted" message="No Implementation set"
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Regenerated state range kind=account prefix=0x61 root=8a7a77..f86ff6 last=0x count=2 created=2 updated=0 untouched=0 deleted=0
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Journalled generator progress progress=done
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Registry contract not yet deployed function=intrinsicGasForAlternativeFeeCurrency registryId=0x8b91d837e1684f7353d73b6197230894243cf869282f722841df96b441303f37
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Generated state snapshot accounts=2 slots=1 storage=230.00B elapsed="531.488µs"
test_cmd.go:262: (stderr:33) ERROR[09-11|10:54:27.606] Error invoking evm function: EVM call failure to=0x000000000000000000000000000000000000ce10 method=getAddressFor input=0xdd9272338f897d9543fdc9082789208180c3e3d11f7473aaef3e249ab0020ea0c761c1b6 maxgas=100,000 err="execution reverted" message="No Implementation set"
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Registry contract not yet deployed function=getWhitelist registryId=0x8f897d9543fdc9082789208180c3e3d11f7473aaef3e249ab0020ea0c761c1b6
test_cmd.go:262: (stderr:33) ERROR[09-11|10:54:27.606] getWhitelist invocation failed err="Registry not deployed"
test_cmd.go:262: (stderr:33) ERROR[09-11|10:54:27.606] Error invoking evm function: EVM call failure to=0x000000000000000000000000000000000000ce10 method=getAddressFor input=0xdd927233d7e89ade8430819f08bf97a087285824af3351ee12d72a2d132b0c6c0687bfaf maxgas=100,000 err="execution reverted" message="No Implementation set"
test_cmd.go:262: (stderr:33) DEBUG[09-11|10:54:27.606] Reinjecting stale transactions count=0
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.606] Regenerated local transaction journal transactions=0 accounts=0
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.615] Allocated fast sync bloom size=512.00MiB
test_cmd.go:262: (stderr:33) WARN [09-11|10:54:27.616] Error reading unclean shutdown markers error="leveldb: not found"
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.617] Allocated cache and file handles database=/tmp/geth-test3910766448/celo/les.server cache=16.00MiB handles=16
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:27.620] Initialized state bloom items=5 errorrate=0.000 elapsed=4.929ms
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:28.828] Checkpoint oracle is not enabled
test_cmd.go:262: (stderr:33) INFO [09-11|10:54:28.828] Starting peer-to-peer node instance=celo/v1.8.0-unstable/linux-amd64/go1.18.10
les_test.go:115: lightserver rpc connect to /tmp/geth-test3910766448/geth-1.ipc: dial unix /tmp/geth-test3910766448/geth-1.ipc: connect: no such file or directory
This test report was produced by the test-summary action.  Made with ❤️ in Cambridge.

@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Patch coverage: 59.67% and project coverage change: +0.12% 🎉

Comparison is base (cd2e13a) 55.05% compared to head (25256e6) 55.18%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2184      +/-   ##
==========================================
+ Coverage   55.05%   55.18%   +0.12%     
==========================================
  Files         679      680       +1     
  Lines      114336   114370      +34     
==========================================
+ Hits        62950    63116     +166     
+ Misses      47495    47378     -117     
+ Partials     3891     3876      -15     
Files Changed Coverage Δ
ethdb/leveldb/celo_leveldb.go 0.00% <0.00%> (ø)
ethdb/leveldb/leveldb.go 14.62% <0.00%> (-0.05%) ⬇️
consensus/istanbul/core/roundstate_db.go 61.63% <72.54%> (+2.99%) ⬆️

... and 25 files with indirect coverage changes

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@carterqw2 carterqw2 requested review from a team and karlb and removed request for a team September 7, 2023 14:08
rsdb.rsRLPMeter = metrics.NewRegisteredMeter(namespace+"rs/rlp/encoding/size", nil)
rsdb.rsRLPEncTimer = metrics.NewRegisteredTimer(namespace+"rs/rlp/encoding/duration", nil)
rsdb.rsDbSaveTimer = metrics.NewRegisteredTimer(namespace+"rs/db/save/time", nil)
rsdb.rcvdRLPMeter = metrics.NewRegisteredMeter(namespace+"rcvd/rlp/encoding/size", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember we used rcvd in the past for tests. I wonder if there's name for this that makes it a bit clearer for a reader. As in , the entry for the collection of received consensus messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The type struct is called rcvd, so I thought I would just follow the convention. I also updated the comment next to the definition of the metric. Would it be enough or you want to change it here? If so, what exactly you would like to change, the name of the metric or the path or both?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, iirc I named that struct and I regret it highly xD. Maybe it's ok, I just felt that if you read the metric name, without the context of it being in this specific piece of code, it's really tough to understand what it is. That being said, it's probably the same with other metrics, so maybe it's ok.

consensus/istanbul/core/roundstate_db.go Show resolved Hide resolved
consensus/istanbul/core/roundstate_db.go Show resolved Hide resolved
ethdb/leveldb/leveldb.go Outdated Show resolved Hide resolved
ethdb/leveldb/leveldb.go Show resolved Hide resolved
Copy link
Contributor

@hbandura hbandura left a comment

Choose a reason for hiding this comment

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

LGTM!

@carterqw2 carterqw2 merged commit 0ed594e into master Sep 11, 2023
28 checks passed
@carterqw2 carterqw2 deleted the carterqw2/roundstatedb-metrics branch September 11, 2023 09:41
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