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

Update alloc counter scaffolding. #249

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,28 @@ done

for test in "${all_tests[@]}"; do
cat "$tmp/output" # helps debugging
total_allocations=$(grep "^test_$test.total_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g')
not_freed_allocations=$(grep "^test_$test.remaining_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g')
max_allowed_env_name="MAX_ALLOCS_ALLOWED_$test"

info "$test: allocations not freed: $not_freed_allocations"
info "$test: total number of mallocs: $total_allocations"
while read -r test_case; do
test_case=${test_case#test_*}
total_allocations=$(grep "^test_$test_case.total_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g')
not_freed_allocations=$(grep "^test_$test_case.remaining_allocations:" "$tmp/output" | cut -d: -f2 | sed 's/ //g')
max_allowed_env_name="MAX_ALLOCS_ALLOWED_$test_case"

assert_less_than "$not_freed_allocations" 5 # allow some slack
assert_greater_than "$not_freed_allocations" -5 # allow some slack
assert_greater_than "$total_allocations" 1000
if [[ -z "${!max_allowed_env_name+x}" ]]; then
info "$test_case: allocations not freed: $not_freed_allocations"
info "$test_case: total number of mallocs: $total_allocations"

assert_less_than "$not_freed_allocations" 5 # allow some slack
assert_greater_than "$not_freed_allocations" -5 # allow some slack
if [[ -z "${!max_allowed_env_name+x}" ]]; then
warn "no reference number of allocations set (set to \$$max_allowed_env_name)"
warn "to set current number:"
warn " export $max_allowed_env_name=$total_allocations"
if [[ -z "${!max_allowed_env_name+x}" ]]; then
warn "no reference number of allocations set (set to \$$max_allowed_env_name)"
warn "to set current number:"
warn " export $max_allowed_env_name=$total_allocations"
fi
else
max_allowed=${!max_allowed_env_name}
assert_less_than_or_equal "$total_allocations" "$max_allowed"
assert_greater_than "$total_allocations" "$(( max_allowed - 1000))"
fi
else
assert_less_than_or_equal "$total_allocations" "${!max_allowed_env_name}"
fi
done < <(grep "^test_$test[^\W]*.total_allocations:" "$tmp/output" | cut -d: -f1 | cut -d. -f1 | sort | uniq)
done
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

tmp_dir="/tmp"

function die() {
echo >&2 "ERROR: $*"
exit 1
}

while getopts "t:" opt; do
case "$opt" in
t)
tmp_dir="$OPTARG"
;;
\?)
die "unknown option $opt"
*)
exit 1
;;
esac
done
Expand All @@ -40,11 +35,19 @@ cd "$nio_checkout"
git clone --depth 1 https://github.com/apple/swift-nio
)

shift $((OPTIND-1))

tests_to_run=("$here"/test_*.swift)

if [[ $# -gt 0 ]]; then
tests_to_run=("$@")
fi

"$nio_checkout/swift-nio/IntegrationTests/allocation-counter-tests-framework/run-allocation-counter.sh" \
-p "$here/../../.." \
-m NIO \
-m NIOHTTP1 \
-m NIOHTTP2 \
-t "$tmp_dir" \
-d <( echo '.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),' ) \
"$here"/test_*.swift
"${tests_to_run[@]}"
12 changes: 6 additions & 6 deletions docker/docker-compose.1604.51.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ services:
integration-tests:
image: swift-nio-http2:16.04-5.1
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=378000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000
- MAX_ALLOCS_ALLOWED_client_server_request_response=338000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=406000

performance-test:
image: swift-nio-http2:16.04-5.1
Expand All @@ -30,10 +30,10 @@ services:
test:
image: swift-nio-http2:16.04-5.1
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=378000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000
- MAX_ALLOCS_ALLOWED_client_server_request_response=338000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=406000
- SANITIZER_ARG=--sanitize=thread

shell:
Expand Down
8 changes: 4 additions & 4 deletions docker/docker-compose.1804.50.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ services:
integration-tests:
image: swift-nio-http2:18.04-5.0
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=67000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=384810
- MAX_ALLOCS_ALLOWED_client_server_request_response=358000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=425000

performance-test:
Expand All @@ -30,9 +30,9 @@ services:
test:
image: swift-nio-http2:18.04-5.0
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=67000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=384810
- MAX_ALLOCS_ALLOWED_client_server_request_response=358000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=425000

shell:
Expand Down
12 changes: 6 additions & 6 deletions docker/docker-compose.1804.52.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ services:
integration-tests:
image: swift-nio-http2:18.04-5.2
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=384810
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000
- MAX_ALLOCS_ALLOWED_client_server_request_response=334000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000

performance-test:
image: swift-nio-http2:18.04-5.2
Expand All @@ -30,10 +30,10 @@ services:
test:
image: swift-nio-http2:18.04-5.2
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=384810
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000
- MAX_ALLOCS_ALLOWED_client_server_request_response=334000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000


shell:
Expand Down
12 changes: 6 additions & 6 deletions docker/docker-compose.1804.53.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ services:
integration-tests:
image: swift-nio-http2:18.04-5.3
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=384810
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000
- MAX_ALLOCS_ALLOWED_client_server_request_response=334000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000

performance-test:
image: swift-nio-http2:18.04-5.3
Expand All @@ -30,10 +30,10 @@ services:
test:
image: swift-nio-http2:18.04-5.3
environment:
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=72010
- MAX_ALLOCS_ALLOWED_create_client_stream_channel=63000
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_client_server_request_response=384810
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=409000
- MAX_ALLOCS_ALLOWED_client_server_request_response=334000
- MAX_ALLOCS_ALLOWED_client_server_h1_request_response=403000

shell:
image: swift-nio-http2:18.04-5.3
4 changes: 3 additions & 1 deletion scripts/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
##
##===----------------------------------------------------------------------===##

set +ex

mkdir -p .build # for the junit.xml file
./IntegrationTests/run-tests.sh --junit-xml .build/junit-sh-tests.xml -i
./IntegrationTests/run-tests.sh --junit-xml .build/junit-sh-tests.xml -i $@