-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the Abillity to Defragment the Beacon State (#13444)
* Defragment head state * change log level * change it to be more efficient * add flag * add tests and clean up * fix it * gosimple * Update container/multi-value-slice/multi_value_slice.go Co-authored-by: Radosław Kapka <[email protected]> * radek's review * unlock it * remove from fc lock --------- Co-authored-by: rkapka <[email protected]>
- Loading branch information
Showing
8 changed files
with
288 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package blockchain | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state" | ||
"github.com/prysmaticlabs/prysm/v4/config/features" | ||
"github.com/prysmaticlabs/prysm/v4/time" | ||
) | ||
|
||
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())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters