neo-go/pkg/core
Roman Khimov 9513780c45 core: adjust in-memory processed set dynamically
Instead of tick-tocking with sync/async and having an unpredictable data
set we can just try to check for the real amount of keys that be processed
by the underlying DB. Can't be perfect, but still this adds some hard
limit to the amount of in-memory data. It's also adaptive, slower machines
will keep less and faster machines will keep more.

This gives almost perfect 4s cycles for mainnet BoltDB with no tail cutting,
it makes zero sense to process more blocks since we're clearly DB-bound:

2025-01-15T11:35:00.567+0300    INFO    persisted to disk       {"blocks": 1469, "keys": 40579, "headerHeight": 5438141, "blockHeight": 5438140, "velocity": 9912, "took": "4.378939648s"}
2025-01-15T11:35:04.699+0300    INFO    persisted to disk       {"blocks": 1060, "keys": 39976, "headerHeight": 5439201, "blockHeight": 5439200, "velocity": 9888, "took": "4.131985438s"}
2025-01-15T11:35:08.752+0300    INFO    persisted to disk       {"blocks": 1508, "keys": 39658, "headerHeight": 5440709, "blockHeight": 5440708, "velocity": 9877, "took": "4.052347569s"}
2025-01-15T11:35:12.807+0300    INFO    persisted to disk       {"blocks": 1645, "keys": 39565, "headerHeight": 5442354, "blockHeight": 5442353, "velocity": 9864, "took": "4.05547743s"}
2025-01-15T11:35:17.011+0300    INFO    persisted to disk       {"blocks": 1472, "keys": 39519, "headerHeight": 5443826, "blockHeight": 5443825, "velocity": 9817, "took": "4.203258142s"}
2025-01-15T11:35:21.089+0300    INFO    persisted to disk       {"blocks": 1345, "keys": 39529, "headerHeight": 5445171, "blockHeight": 5445170, "velocity": 9804, "took": "4.078297579s"}
2025-01-15T11:35:25.090+0300    INFO    persisted to disk       {"blocks": 1054, "keys": 39326, "headerHeight": 5446225, "blockHeight": 5446224, "velocity": 9806, "took": "4.000524899s"}
2025-01-15T11:35:30.372+0300    INFO    persisted to disk       {"blocks": 1239, "keys": 39349, "headerHeight": 5447464, "blockHeight": 5447463, "velocity": 9744, "took": "4.281444939s"}

2× can be considered, but this calculation isn't perfect for low number of
keys, so somewhat bigger tolerance is preferable for now. Overall it's not
degrading performance, my mainnet/bolt run was even 8% better with this.

Fixes #3249, we don't need any option this way.

Fixes #3783 as well, it no longer OOMs in that scenario. It however can OOM in
case of big GarbageCollectionPeriod (like 400K), but this can't be solved easily.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-15 22:08:08 +03:00
..
block core: a bit better field explanations for header/transaction 2024-11-15 11:27:21 +03:00
chaindump chaindump: microoptimize memory management 2024-07-16 15:03:17 +03:00
dao core: fix removing old transfer data with RemoveUntraceableHeaders 2024-12-13 16:09:00 +03:00
fee *: improve for loop syntax 2024-08-30 21:45:18 +03:00
interop interop: slightly rephrase BuildHFSpecificMD logic 2024-11-25 14:45:26 +03:00
mempool *: fix some dupword warnings 2024-11-13 20:57:10 +03:00
mempoolevent *: replace interface{} with any keyword 2023-04-04 13:22:42 +03:00
mpt mpt: refactor lcp to be possible to use range 2024-09-04 14:15:44 +03:00
native native: add candidate registration via onNEP17Payment 2024-12-25 10:36:38 +03:00
state state: drop compatibility code for NEOBalance 2024-11-19 21:40:01 +03:00
stateroot core: fix restoring chain with StateRootInHeader = true 2024-11-22 13:33:50 +03:00
statesync *: improve for loop syntax 2024-08-30 21:45:18 +03:00
storage core: adjust in-memory processed set dynamically 2025-01-15 22:08:08 +03:00
test_data core: refactor helper test contracts generation 2022-03-30 11:46:29 +03:00
transaction core: a bit better field explanations for header/transaction 2024-11-15 11:27:21 +03:00
basic_chain_test.go *: extend basic testing chain documentation 2024-11-20 18:06:13 +03:00
bench_test.go *: improve for loop syntax 2024-08-30 21:45:18 +03:00
blockchain.go core: adjust in-memory processed set dynamically 2025-01-15 22:08:08 +03:00
blockchain_core_test.go core: adjust in-memory processed set dynamically 2025-01-15 22:08:08 +03:00
blockchain_neotest_test.go config: enable Echidna for tests 2024-12-24 18:01:12 +03:00
doc.go *: apply go 1.19 formatter heuristics 2022-08-09 15:37:52 +03:00
headerhashes.go *: drop open-coded slice reversing 2024-08-24 22:41:48 +03:00
helper_test.go *: improve for loop syntax 2024-08-30 21:45:18 +03:00
interops.go core: add System.Runtime.CurrentSigners syscall 2023-11-20 14:46:27 +03:00
native_designate_test.go *: introduce Genesis protocol configuration 2023-10-19 18:30:20 +03:00
prometheus.go core: adjust in-memory processed set dynamically 2025-01-15 22:08:08 +03:00
util.go *: drop open-coded slice reversing 2024-08-24 22:41:48 +03:00
util_test.go *: add GenesisTransaction extension to the protocol configuration 2023-10-19 18:33:50 +03:00