From cd01c1a4ceb6c365f182cc8f7b7f73b2ded26694 Mon Sep 17 00:00:00 2001 From: kirill lykov Date: Tue, 21 Jun 2022 18:28:15 +0100 Subject: [PATCH] Add profile option to net scripts (#25624) * add image option to cloud CreateInstaces * add script to install perf * add profile option to gce.sh * add profile option for net.sh start * Revert "add image option to cloud CreateInstaces" This reverts commit fd63991861e632ae87e79281bca63a0f8173e201. * remove imageName from gce.sh * fix for gce.sh * add comments on permissions setup * remove profile option for gce.sh * remove short arg --- net/gce.sh | 1 + net/net.sh | 10 +++++++++- net/scripts/install-perf.sh | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 net/scripts/install-perf.sh diff --git a/net/gce.sh b/net/gce.sh index 8802891674..6c9e9b357f 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -807,6 +807,7 @@ $( install-libssl-compatability.sh \ install-redis.sh \ install-rsync.sh \ + install-perf.sh \ localtime.sh \ network-config.sh \ remove-docker-interface.sh \ diff --git a/net/net.sh b/net/net.sh index 8a04a362cc..418716c47b 100755 --- a/net/net.sh +++ b/net/net.sh @@ -193,9 +193,13 @@ build() { buildVariant=--debug fi + if $profileBuild; then + profilerFlags="RUSTFLAGS='-C force-frame-pointers=y -g ${RUSTFLAGS}'" + fi + $MAYBE_DOCKER bash -c " set -ex - scripts/cargo-install-all.sh farf $buildVariant --validator-only + $profilerFlags scripts/cargo-install-all.sh farf $buildVariant --validator-only " ) @@ -783,6 +787,7 @@ maybeAllowPrivateAddr="" maybeAccountsDbSkipShrink="" maybeSkipRequireTower="" debugBuild=false +profileBuild=false doBuild=true gpuMode=auto netemPartition="" @@ -869,6 +874,9 @@ while [[ -n $1 ]]; do elif [[ $1 = --debug ]]; then debugBuild=true shift 1 + elif [[ $1 = --profile ]]; then + profileBuild=true + shift 1 elif [[ $1 = --partition ]]; then netemPartition=$2 shift 2 diff --git a/net/scripts/install-perf.sh b/net/scripts/install-perf.sh new file mode 100755 index 0000000000..4d25cf1884 --- /dev/null +++ b/net/scripts/install-perf.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# perf setup +# +set -ex + +[[ $(uname) = Linux ]] || exit 1 +[[ $USER = root ]] || exit 1 + +# install perf +apt-get --assume-yes install linux-tools-common linux-tools-generic "linux-tools-$(uname -r)" + +# setup permissions +# Impose no scope and access restrictions on using perf_events performance monitoring +echo -1 | tee /proc/sys/kernel/perf_event_paranoid +# Allow recording kernel reference relocation symbol to avoid skewing symbol resolution if relocation was used +echo 0 | tee /proc/sys/kernel/kptr_restrict