diff --git a/.bazelrc b/.bazelrc index 443744d28..5f9c50b5c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -27,6 +27,7 @@ build:minimal --@io_bazel_rules_go//go/config:tags=minimal # Release flags build:release --compilation_mode=opt build:release --stamp +build:release --define pgo_enabled=1 # Build binary with cgo symbolizer for debugging / profiling. build:cgo_symbolizer --copt=-g diff --git a/BUILD.bazel b/BUILD.bazel index a11d68cf4..a1f9544b4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -144,6 +144,11 @@ config_setting( values = {"define": "coverage_enabled=1"}, ) +config_setting( + name = "pgo_enabled", + values = {"define": "pgo_enabled=1"}, +) + common_files = { "//:LICENSE.md": "LICENSE.md", "//:README.md": "README.md", diff --git a/cmd/beacon-chain/BUILD.bazel b/cmd/beacon-chain/BUILD.bazel index 63fdc2c67..bb8d5e95d 100644 --- a/cmd/beacon-chain/BUILD.bazel +++ b/cmd/beacon-chain/BUILD.bazel @@ -110,6 +110,10 @@ docker_push( go_binary( name = "beacon-chain", embed = [":go_default_library"], + pgoprofile = select({ + "//:pgo_enabled": "pprof.beacon-chain.samples.cpu.pb.gz", + "//conditions:default": None, + }), visibility = [ "//beacon-chain:__subpackages__", "//testing/endtoend:__pkg__", diff --git a/cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz b/cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz new file mode 100644 index 000000000..553015b13 Binary files /dev/null and b/cmd/beacon-chain/pprof.beacon-chain.samples.cpu.pb.gz differ