mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
* Migrate Prysm repo to Offchain Labs organization ahead of Pectra upgrade v6 * Replace prysmaticlabs with OffchainLabs on general markdowns * Update mock * Gazelle and add mock.go to excluded generated mock file
28 lines
925 B
Go
28 lines
925 B
Go
package blockchain
|
|
|
|
import (
|
|
"github.com/OffchainLabs/prysm/v6/beacon-chain/state"
|
|
"github.com/OffchainLabs/prysm/v6/config/features"
|
|
"github.com/OffchainLabs/prysm/v6/time"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
var stateDefragmentationTime = promauto.NewSummary(prometheus.SummaryOpts{
|
|
Name: "head_state_defragmentation_milliseconds",
|
|
Help: "Milliseconds it takes to defragment the head state",
|
|
})
|
|
|
|
// This method defragments our state, so that any specific fields which have
|
|
// a higher number of fragmented indexes are reallocated to a new separate slice for
|
|
// that field.
|
|
func (s *Service) defragmentState(st state.BeaconState) {
|
|
if !features.Get().EnableExperimentalState {
|
|
return
|
|
}
|
|
startTime := time.Now()
|
|
st.Defragment()
|
|
elapsedTime := time.Since(startTime)
|
|
stateDefragmentationTime.Observe(float64(elapsedTime.Milliseconds()))
|
|
}
|