This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
ci(circleci): add benchmark comparisons #147
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,7 @@ | ||
#!/bin/bash | ||
output="$1" | ||
branch="$2" | ||
|
||
git checkout "$2" | ||
|
||
IPFS_LOGGING=critical go test -benchtime=3s -run=NONE -bench=. ./... | tee "$1" |
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,24 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
list_buildable() { | ||
go list -f '{{if (len .GoFiles)}}{{.ImportPath}} {{if .Module}}{{.Module.Dir}}{{else}}{{.Dir}}{{end}}{{end}}' ./... | grep -v /vendor/ | ||
} | ||
|
||
build_all() { | ||
# Make sure everything can compile since some package may not have tests | ||
# Note: that "go build ./..." will fail if some packages have only | ||
# tests (will get "no buildable Go source files" error) so we | ||
# have to do this the hard way. | ||
list_buildable | while read -r pkg dir; do | ||
echo '*** go build' "$pkg" | ||
buildmode=archive | ||
if [[ "$(go list -f '{{.Name}}')" == "main" ]]; then | ||
# plugin works even when a "main" function is missing. | ||
buildmode=plugin | ||
fi | ||
( cd "$dir"; go build -buildmode=$buildmode -o /dev/null "$pkg") | ||
done | ||
} | ||
|
||
build_all | ||
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,32 @@ | ||
#!/bin/bash | ||
|
||
before="$1" | ||
after="$2" | ||
|
||
parse() { | ||
sed -n \ | ||
-e 's/ *\t */\t/g' \ | ||
-e '/^Benchmark/p' | | ||
awk 'BEGIN{print "{\"results\": ["} {print " {\"name\": \"",$1,"\", \"time\": ",$3," },"} END{print "]}"}' OFS="" ORS=" "| | ||
sed -e 's/, ]/ ]/g' | | ||
jq '.results[] | {name: .name, time: .time }' | ||
|
||
} | ||
|
||
benchcmp "$1" "$2" | ||
|
||
echo "" | ||
echo "Result:" | ||
|
||
{ | ||
parse < "$1" | ||
parse < "$2" | ||
} | jq -e -r -s 'group_by(.name)[] | {name: .[0].name, speedup: (.[0].time / .[1].time)} | select(.speedup < 0.75) | "\(.name)\t\(.speedup)x"' | ||
|
||
if [[ $? -ne 4 ]]; then | ||
echo "" | ||
echo "FAIL" | ||
exit 1 | ||
else | ||
echo "PASS" | ||
fi |
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,62 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
display_and_run() { | ||
echo "***" "$@" | ||
eval $(printf '%q ' "$@") | ||
} | ||
|
||
# reset workdir to state from git (to remove possible rewritten dependencies) | ||
display_and_run git reset --hard | ||
|
||
# Environment | ||
echo "*** Setting up test environment" | ||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
if [[ "$TRAVIS_SUDO" == true ]]; then | ||
# Ensure that IPv6 is enabled. | ||
# While this is unsupported by TravisCI, it still works for localhost. | ||
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 | ||
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0 | ||
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 | ||
fi | ||
else | ||
# OSX has a default file limit of 256, for some tests we need a | ||
# maximum of 8192. | ||
ulimit -Sn 8192 | ||
fi | ||
|
||
list_buildable() { | ||
go list -f '{{if (len .GoFiles)}}{{.ImportPath}} {{if .Module}}{{.Module.Dir}}{{else}}{{.Dir}}{{end}}{{end}}' ./... | grep -v /vendor/ | ||
} | ||
|
||
build_all() { | ||
# Make sure everything can compile since some package may not have tests | ||
# Note: that "go build ./..." will fail if some packages have only | ||
# tests (will get "no buildable Go source files" error) so we | ||
# have to do this the hard way. | ||
list_buildable | while read -r pkg dir; do | ||
echo '*** go build' "$pkg" | ||
buildmode=archive | ||
if [[ "$(go list -f '{{.Name}}')" == "main" ]]; then | ||
# plugin works even when a "main" function is missing. | ||
buildmode=plugin | ||
fi | ||
( cd "$dir"; go build -buildmode=$buildmode -o /dev/null "$pkg") | ||
done | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably skip all of this logic and just rely on the standard test scripts. |
||
|
||
export GO111MODULE=on | ||
display_and_run go get golang.org/x/tools/cmd/benchcmp | ||
build_all | ||
display_and_run git reset --hard | ||
git checkout -b after | ||
git fetch origin master:refs/remotes/origin/before | ||
git checkout remotes/origin/before | ||
git checkout -b before | ||
git checkout after | ||
display_and_run BENCHMARK_SEED="$$" ./bin/benchmark-to-file.sh benchmark-before.txt before | ||
git checkout after | ||
display_and_run BENCHMARK_SEED="$$" ./bin/benchmark-to-file.sh benchmark-after.txt after | ||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
display_and_run ./bin/diff-benchmarks.sh benchmark-before.txt benchmark-after.txt | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's have |
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,6 @@ | ||
#!/bin/bash | ||
if [[ "$TEST_PHASE" == "test" ]]; then | ||
bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh) | ||
else | ||
./bin/run-benchmarks.sh | ||
fi |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this file.