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

core/blockchain: add some metrics for monitoring block and state #498

Open
wants to merge 16 commits into
base: pre-release
Choose a base branch
from

Conversation

c98tristan
Copy link
Contributor

@c98tristan c98tristan commented Dec 26, 2024

Prerequisites:

This pull request introduces significant changes to the Viction codebase, primarily focusing on enhancing metrics collection and reporting. The changes include the addition of new metrics, refactoring existing flags, and updating various parts of the blockchain and state management code to track and report metrics more effectively.

Metrics Enhancements:

  • Added new metrics for tracking various blockchain and state operations, including block insertion, validation, execution, and storage updates. (core/blockchain.go, core/state/state_object.go, core/state/statedb.go) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
  • Track the head header, receipt and block via gauges. This gives us access to the sync status without RPC.
	headBlockGauge     = metrics.NewRegisteredGauge("chain/head/block", nil)
	headHeaderGauge    = metrics.NewRegisteredGauge("chain/head/header", nil)
	headFastBlockGauge = metrics.NewRegisteredGauge("chain/head/receipt", nil)

	accountReadTimer   = metrics.NewRegisteredTimer("chain/account/reads", nil)
	accountHashTimer   = metrics.NewRegisteredTimer("chain/account/hashes", nil)
	accountUpdateTimer = metrics.NewRegisteredTimer("chain/account/updates", nil)
	accountCommitTimer = metrics.NewRegisteredTimer("chain/account/commits", nil)

	storageReadTimer   = metrics.NewRegisteredTimer("chain/storage/reads", nil)
	storageHashTimer   = metrics.NewRegisteredTimer("chain/storage/hashes", nil)
	storageUpdateTimer = metrics.NewRegisteredTimer("chain/storage/updates", nil)
	storageCommitTimer = metrics.NewRegisteredTimer("chain/storage/commits", nil)

	blockInsertTimer     = metrics.NewRegisteredTimer("chain/inserts", nil)
	blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil)
	blockExecutionTimer  = metrics.NewRegisteredTimer("chain/execution", nil)
	blockWriteTimer      = metrics.NewRegisteredTimer("chain/write", nil)

	blockReorgMeter         = metrics.NewRegisteredMeter("chain/reorg/executes", nil)
	blockReorgAddMeter      = metrics.NewRegisteredMeter("chain/reorg/add", nil)
	blockReorgDropMeter     = metrics.NewRegisteredMeter("chain/reorg/drop", nil)
	blockReorgInvalidatedTx = metrics.NewRegisteredMeter("chain/reorg/invalidTx", nil)

Code Refactoring:

  • Refactored the import paths and usage of the metrics package across various files to ensure consistency and avoid redundancy. (cmd/utils/flags.go, core/blockchain.go, core/headerchain.go, core/state/state_object.go, core/state/statedb.go) [1] [2] [3] [4]

Additional Changes:

  • Updated the logging mechanism to provide more informative messages during chain reorganization and other critical operations. (core/blockchain.go)
  • Ensured that various gauges and timers are updated correctly to reflect the current state of the blockchain and header chain. (core/blockchain.go, core/headerchain.go) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

These changes collectively aim to improve the observability and performance monitoring of the Viction system, making it easier to diagnose issues and optimize the blockchain's performance.

Reference:

@c98tristan c98tristan changed the title Add metrics for monitoring in core/blockchain core/blockchain: add some metrics for monitoring block and state Jan 2, 2025
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.

1 participant