mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Enable profile guided optimization for beacon-chain (#13035)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
load("//tools:target_migration.bzl", "moved_targets")
|
||||
|
||||
moved_targets(
|
||||
[
|
||||
":push_images_debug",
|
||||
":push_images_alpine",
|
||||
":push_images",
|
||||
":image_bundle_debug",
|
||||
":image_debug",
|
||||
":image_bundle_alpine",
|
||||
":image_bundle",
|
||||
":image_with_creation_time",
|
||||
":image_alpine",
|
||||
":image",
|
||||
":go_default_test",
|
||||
":beacon-chain",
|
||||
],
|
||||
"//cmd/beacon-chain",
|
||||
)
|
||||
@@ -446,11 +446,10 @@ func BenchmarkHasBlockForkChoiceStore_DoublyLinkedTree(b *testing.B) {
|
||||
s := &Service{
|
||||
cfg: &config{ForkChoiceStore: doublylinkedtree.New(), BeaconDB: beaconDB},
|
||||
}
|
||||
blk := ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}}
|
||||
blk := util.NewBeaconBlock()
|
||||
r, err := blk.Block.HashTreeRoot()
|
||||
require.NoError(b, err)
|
||||
bs := ðpb.BeaconState{FinalizedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}, CurrentJustifiedCheckpoint: ðpb.Checkpoint{Root: make([]byte, 32)}}
|
||||
beaconState, err := state_native.InitializeFromProtoPhase0(bs)
|
||||
beaconState, err := util.NewBeaconState()
|
||||
require.NoError(b, err)
|
||||
require.NoError(b, s.cfg.ForkChoiceStore.InsertNode(ctx, beaconState, r))
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ go_test(
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
"@com_github_golang_snappy//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||
"@io_etcd_go_bbolt//:go_default_library",
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package kv
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v4/config/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -10,3 +15,9 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
logrus.SetOutput(io.Discard)
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ go_test(
|
||||
name = "go_default_test",
|
||||
srcs = [
|
||||
"aggregated_test.go",
|
||||
"benchmark_test.go",
|
||||
"block_test.go",
|
||||
"forkchoice_test.go",
|
||||
"seen_bits_test.go",
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package kv_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v4/beacon-chain/operations/attestations/kv"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
||||
)
|
||||
|
||||
func BenchmarkAttCaches(b *testing.B) {
|
||||
ac := kv.NewAttCaches()
|
||||
|
||||
att := ðpb.Attestation{}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
assert.NoError(b, ac.SaveUnaggregatedAttestation(att))
|
||||
assert.NoError(b, ac.DeleteAggregatedAttestation(att))
|
||||
}
|
||||
}
|
||||
@@ -2239,28 +2239,6 @@ func TestGetValidatorPerformanceCapella_OK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkListValidatorBalances(b *testing.B) {
|
||||
b.StopTimer()
|
||||
beaconDB := dbTest.SetupDB(b)
|
||||
ctx := context.Background()
|
||||
|
||||
count := 1000
|
||||
_, _, headState := setupValidators(b, beaconDB, count)
|
||||
bs := &Server{
|
||||
HeadFetcher: &mock.ChainService{
|
||||
State: headState,
|
||||
},
|
||||
}
|
||||
addDefaultReplayerBuilder(bs, beaconDB)
|
||||
|
||||
req := ðpb.ListValidatorBalancesRequest{PageSize: 100}
|
||||
b.StartTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := bs.ListValidatorBalances(ctx, req)
|
||||
require.NoError(b, err)
|
||||
}
|
||||
}
|
||||
|
||||
func setupValidators(t testing.TB, _ db.Database, count int) ([]*ethpb.Validator, []uint64, state.BeaconState) {
|
||||
balances := make([]uint64, count)
|
||||
validators := make([]*ethpb.Validator, 0, count)
|
||||
|
||||
@@ -214,9 +214,12 @@ go_test(
|
||||
timeout = "moderate",
|
||||
srcs = [
|
||||
"attester_mainnet_test.go",
|
||||
"proposer_utils_bench_test.go",
|
||||
"server_mainnet_test.go",
|
||||
"status_mainnet_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = common_deps,
|
||||
deps = common_deps + [
|
||||
"//proto/prysm/v1alpha1/attestation/aggregation/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -639,9 +639,12 @@ func BenchmarkCommitteeAssignment(b *testing.B) {
|
||||
indices[i] = uint64(i)
|
||||
}
|
||||
|
||||
chain := &mockChain.ChainService{State: bs, Root: genesisRoot[:]}
|
||||
vs := &Server{
|
||||
HeadFetcher: &mockChain.ChainService{State: bs, Root: genesisRoot[:]},
|
||||
SyncChecker: &mockSync.Sync{IsSyncing: false},
|
||||
HeadFetcher: chain,
|
||||
TimeFetcher: chain,
|
||||
SyncChecker: &mockSync.Sync{IsSyncing: false},
|
||||
ProposerSlotIndexCache: cache.NewProposerPayloadIDsCache(),
|
||||
}
|
||||
|
||||
// Create request for all validators in the system.
|
||||
|
||||
@@ -110,6 +110,7 @@ docker_push(
|
||||
go_binary(
|
||||
name = "beacon-chain",
|
||||
embed = [":go_default_library"],
|
||||
pgoprofile = "pprof.beacon-chain.samples.cpu.pb.gz",
|
||||
visibility = [
|
||||
"//beacon-chain:__subpackages__",
|
||||
"//testing/endtoend:__pkg__",
|
||||
|
||||
BIN
cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz
Normal file
BIN
cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz
Normal file
Binary file not shown.
@@ -157,7 +157,7 @@ func TestIsValidAttestationIndices(t *testing.T) {
|
||||
|
||||
func BenchmarkAttestingIndices_PartialCommittee(b *testing.B) {
|
||||
bf := bitfield.Bitlist{0b11111111, 0b11111111, 0b10000111, 0b11111111, 0b100}
|
||||
committee := []primitives.ValidatorIndex{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34}
|
||||
committee := []primitives.ValidatorIndex{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33}
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
@@ -10,6 +10,7 @@ The following configs are in `config.go`:
|
||||
Due to the sheer size of the benchmarking configurations (16384 validators), the files used for benchmarking are pregenerated so there's no wasted computations on generating a genesis state with 16384 validators. This should only be needed if there is a breaking spec change and the tests fail from SSZ issues.
|
||||
|
||||
To generate new files to use for benchmarking, run the below command in the root of Prysm.
|
||||
|
||||
```
|
||||
bazel run //tools/benchmark-files-gen -- --output-dir $PRYSMPATH/testing/benchmark/benchmark_files/ --overwrite
|
||||
```
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -30,7 +30,7 @@ var GenesisFileName = fmt.Sprintf("bStateGenesis-%dAtts-%dVals.ssz", Attestation
|
||||
var BState1EpochFileName = fmt.Sprintf("bState1Epoch-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount)
|
||||
|
||||
// BstateEpochFileName is the generated beacon state after 2 full epochs file name.
|
||||
var BstateEpochFileName = fmt.Sprintf("bstateEpochs-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount)
|
||||
var BstateEpochFileName = fmt.Sprintf("bState2Epochs-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount)
|
||||
|
||||
// FullBlockFileName is the generated full block file name.
|
||||
var FullBlockFileName = fmt.Sprintf("fullBlock-%dAtts-%dVals.ssz", AttestationsPerEpoch, ValidatorCount)
|
||||
|
||||
@@ -12,11 +12,11 @@ func TestPreGenFullBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPreGenState1Epoch(t *testing.T) {
|
||||
_, err := PreGenFullBlock()
|
||||
_, err := PreGenState1Epoch()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestPreGenstateFullEpochs(t *testing.T) {
|
||||
_, err := PreGenFullBlock()
|
||||
_, err := PreGenstateFullEpochs()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
def moved_targets(targets, new_package):
|
||||
for target in targets:
|
||||
native.alias(
|
||||
name = target[1:],
|
||||
actual = new_package + target,
|
||||
deprecation = "This target has moved to %s%s" % (new_package, target),
|
||||
tags = ["manual"],
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
load("//tools:target_migration.bzl", "moved_targets")
|
||||
|
||||
moved_targets(
|
||||
[
|
||||
":push_images_debug",
|
||||
":push_images_alpine",
|
||||
":push_images",
|
||||
":image_bundle_debug",
|
||||
":image_debug",
|
||||
":image_bundle_alpine",
|
||||
":image_bundle",
|
||||
":image_with_creation_time",
|
||||
":image_alpine",
|
||||
":image",
|
||||
":go_default_test",
|
||||
":validator",
|
||||
],
|
||||
"//cmd/validator",
|
||||
)
|
||||
Reference in New Issue
Block a user