lighthouse/beacon_node/beacon_chain
Paul Hauner e7e5878953 Avoid BeaconState clone during metrics scrape (#2298)
## Issue Addressed

Which issue # does this PR address?

## Proposed Changes

Avoids cloning the `BeaconState` each time Prometheus scrapes our metrics (generally every 5s 😱).

I think the original motivation behind this was *"don't hold the lock on the head whilst we do computation on it"*, however I think is flawed since our computation here is so small that it'll be quicker than the clone.

The primary motivation here is to maintain a small memory footprint by holding less in memory (i.e., the cloned `BeaconState`) and to avoid the fragmentation-creep that occurs when cloning the big contiguous slabs of memory in the `BeaconState`.

I also collapsed the active/slashed/withdrawn counters into a single loop to increase efficiency.

## Additional Info

NA
2021-04-07 01:02:56 +00:00
..
src Avoid BeaconState clone during metrics scrape (#2298) 2021-04-07 01:02:56 +00:00
tests Optimize validator duties (#2243) 2021-03-17 05:09:57 +00:00
Cargo.toml Upgrade rand_core (#2201) 2021-02-15 20:34:49 +00:00