go-ethereum/core/rawdb
Martin HS 9045b79bc2
metrics, cmd/geth: change init-process of metrics (#30814)
This PR modifies how the metrics library handles `Enabled`: previously,
the package `init` decided whether to serve real metrics or just
dummy-types.

This has several drawbacks: 
- During pkg init, we need to determine whether metrics are enabled or
not. So we first hacked in a check if certain geth-specific
commandline-flags were enabled. Then we added a similar check for
geth-env-vars. Then we almost added a very elaborate check for
toml-config-file, plus toml parsing.

- Using "real" types and dummy types interchangeably means that
everything is hidden behind interfaces. This has a performance penalty,
and also it just adds a lot of code.

This PR removes the interface stuff, uses concrete types, and allows for
the setting of Enabled to happen later. It is still assumed that
`metrics.Enable()` is invoked early on.

The somewhat 'heavy' operations, such as ticking meters and exp-decay,
now checks the enable-flag to prevent resource leak.

The change may be large, but it's mostly pretty trivial, and from the
last time I gutted the metrics, I ensured that we have fairly good test
coverage.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-12-10 13:27:29 +01:00
..
ancienttest core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
testdata core/rawdb: avoid unnecessary receipt processing for log filtering (#23147) 2021-09-28 12:54:49 +02:00
accessors_chain.go core/rawdb: remove unused deriveLogFields (#29913) 2024-06-05 21:05:00 +08:00
accessors_chain_test.go all: fix issues with benchmarks (#30667) 2024-11-04 15:10:12 +01:00
accessors_indexes.go core/types, params: add blob transaction type, RLP encoded for now (#27049) 2023-04-21 12:52:02 +03:00
accessors_indexes_test.go ethdb: refactor Database interface (#30693) 2024-10-29 10:32:40 +02:00
accessors_metadata.go Revert "core/rawdb: remove unused transition status state accessors" (#30449) 2024-09-18 11:53:50 +03:00
accessors_snapshot.go all: fix various typos (#29542) 2024-04-16 15:44:00 +03:00
accessors_state.go all: implement path-based state scheme (#25963) 2023-08-01 15:17:32 +03:00
accessors_sync.go core, accounts, eth, trie: handle genesis state missing (#28171) 2023-09-28 10:00:53 +03:00
accessors_trie.go core/rawdb: make sure specified state scheme is valid (#30499) 2024-09-24 09:26:29 +02:00
ancient_scheme.go core/rawdb, triedb, cmd: create an isolated disk namespace for verkle (#30105) 2024-07-16 16:17:58 +03:00
ancient_utils.go core/rawdb, triedb, cmd: create an isolated disk namespace for verkle (#30105) 2024-07-16 16:17:58 +03:00
chain_freezer.go core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
chain_iterator.go core, core/rawdb, eth/sync: no tx indexing during snap sync (#28703) 2024-01-22 21:05:18 +01:00
chain_iterator_test.go all: refactor so `NewBlock`, `WithBody` take `types.Body` (#29482) 2024-04-30 14:55:08 +02:00
database.go core, eth, node: break rawdb -> {leveldb, pebble} dependency (#30689) 2024-10-29 10:31:04 +02:00
database_test.go all: update license headers and AUTHORS from git history (#24947) 2022-05-24 20:39:40 +02:00
freezer.go ethdb: refactor Database interface (#30693) 2024-10-29 10:32:40 +02:00
freezer_batch.go all: get rid of custom MaxUint64 and MaxUint64 (#30636) 2024-10-20 14:41:51 +03:00
freezer_memory.go ethdb: refactor Database interface (#30693) 2024-10-29 10:32:40 +02:00
freezer_memory_test.go core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
freezer_meta.go all: update license headers and AUTHORS from git history (#24947) 2022-05-24 20:39:40 +02:00
freezer_meta_test.go all: simplify tests using t.TempDir() (#30150) 2024-07-15 15:26:58 +02:00
freezer_resettable.go ethdb: refactor Database interface (#30693) 2024-10-29 10:32:40 +02:00
freezer_resettable_test.go core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
freezer_table.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
freezer_table_test.go core/rawdb: freezer index repair (#29792) 2024-10-01 18:16:16 +02:00
freezer_test.go core/rawdb: drop MigrateTable (#30331) 2024-08-20 14:06:00 +02:00
freezer_utils.go core/rawdb: fsync the index file after each freezer write (#28483) 2023-11-10 12:56:39 +02:00
freezer_utils_test.go all: more linters (#24783) 2022-06-13 16:24:45 +02:00
key_length_iterator.go core/rawdb: add specified key length iterator (#24535) 2022-03-15 10:28:26 +02:00
key_length_iterator_test.go core/rawdb: add specified key length iterator (#24535) 2022-03-15 10:28:26 +02:00
schema.go core/rawdb, triedb, cmd: create an isolated disk namespace for verkle (#30105) 2024-07-16 16:17:58 +03:00
table.go ethdb: add DeleteRange feature (#30668) 2024-10-25 17:33:46 +02:00
table_test.go all: simplify and fix database iteration with prefix/start (#20808) 2020-04-15 14:08:53 +03:00