Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test parallelism in sonar scan #5336

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions scripts/sonar/sonar-scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SONAR_LOGIN=""
SONAR_ORG="hootenanny"
SONAR_PROJECT="hoot"
SONAR_SOURCES="./hoot-core,./hoot-js,./tbs,./tgs"
SONAR_THREADS="$(( $(nproc) * 2 ))" # Sonar scan doesn't max out CPU, double the threads
SONAR_THREADS=""

# Getting parameters from the command line.
while getopts ":a:b:dj:l:o:p:r:s:t:" opt; do
Expand Down Expand Up @@ -78,7 +78,6 @@ fi
OPTIONS=(
"-Dsonar.projectKey=$SONAR_PROJECT"
"-Dsonar.cfamily.build-wrapper-output=bw-output"
"-Dsonar.cfamily.threads=$SONAR_THREADS"
)

# Add gcov.reportsPath if the directory exists
Expand All @@ -88,6 +87,20 @@ if [ -d $HOOT_HOME/gcov ]; then
"-Dsonar.cfamily.gcov.reportsPath=$HOOT_HOME/gcov"
)
fi

# Optional thread count parameter
if [ -n "$SONAR_THREADS" ]; then
# NOTE: Sonar docs say that using more that `nproc` threads can actually
# cause slowdowns, as of 4/2022 using 2 x nproc was slowing hootenanny
# down about 2 minutes (from 31 minutes to 29 minutes) even though
# the sonar scan process wasn't taking even 50% of each available process
# See "Parallel Code Scan" at https://docs.sonarcloud.io/advanced-setup/languages/c-c-objective-c/
OPTIONS=(
"${OPTIONS[@]}"
"-Dsonar.cfamily.threads=$SONAR_THREADS"
)
fi

# Optional scan parameters based off parameters passed into script
if [ -n "$SONAR_LOGIN" ]; then
# This is the hoot sonarcloud project key, requried to pass scan results to
Expand Down