lighthouse/beacon_node/store/src
Michael Sproul 9c785a9b33 Optimize process_attestation with active balance cache (#2560)
## Proposed Changes

Cache the total active balance for the current epoch in the `BeaconState`. Computing this value takes around 1ms, and this was negatively impacting block processing times on Prater, particularly when reconstructing states.

With a large number of attestations in each block, I saw the `process_attestations` function taking 150ms, which means that reconstructing hot states can take up to 4.65s (31 * 150ms), and reconstructing freezer states can take up to 307s (2047 * 150ms).

I opted to add the cache to the beacon state rather than computing the total active balance at the start of state processing and threading it through. Although this would be simpler in a way, it would waste time, particularly during block replay, as the total active balance doesn't change for the duration of an epoch. So we save ~32ms for hot states, and up to 8.1s for freezer states (using `--slots-per-restore-point 8192`).
2021-09-03 07:50:43 +00:00
..
impls Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
chunked_iter.rs Make key value storage abstractions more accurate (#1267) 2020-06-16 11:34:04 +10:00
chunked_vector.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
config.rs Refine compaction (#1916) 2020-11-17 09:10:53 +00:00
errors.rs Use the database to persist the pubkey cache (#2234) 2021-03-04 01:25:12 +00:00
forwards_iter.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
garbage_collection.rs Compact database on finalization (#1871) 2020-11-09 07:02:21 +00:00
hot_cold_store.rs Revert bad blocks on missed fork (#2529) 2021-08-30 06:41:31 +00:00
impls.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
iter.rs Revert bad blocks on missed fork (#2529) 2021-08-30 06:41:31 +00:00
leveldb_store.rs update dependencies (#2032) 2020-12-07 08:20:33 +00:00
lib.rs Rust 1.54.0 lints (#2483) 2021-07-30 01:11:47 +00:00
memory_store.rs Compact database on finalization (#1871) 2020-11-09 07:02:21 +00:00
metadata.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
metrics.rs Implement slasher (#1567) 2020-11-23 03:43:22 +00:00
partial_beacon_state.rs Optimize process_attestation with active balance cache (#2560) 2021-09-03 07:50:43 +00:00