diff --git a/dev/boxed-existentials.d b/dev/boxed-existentials.d new file mode 100755 index 00000000000..49d1d1a9668 --- /dev/null +++ b/dev/boxed-existentials.d @@ -0,0 +1,23 @@ +#!/usr/sbin/dtrace -q -s +/*===----------------------------------------------------------------------===* + * + * This source file is part of the SwiftNIO open source project + * + * Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors + * Licensed under Apache License v2.0 + * + * See LICENSE.txt for license information + * See CONTRIBUTORS.txt for the list of SwiftNIO project authors + * + * SPDX-License-Identifier: Apache-2.0 + * + *===----------------------------------------------------------------------===*/ + +/* + * example invocation: + * sudo dev/boxed-existentials.d -c .build/release/NIOHTTP1Server + */ + +pid$target::__swift_allocate_boxed_opaque_existential*:entry { + ustack(); +} diff --git a/dev/malloc-aggregation.d b/dev/malloc-aggregation.d new file mode 100755 index 00000000000..6e723c686bf --- /dev/null +++ b/dev/malloc-aggregation.d @@ -0,0 +1,37 @@ +#!/usr/sbin/dtrace -q -s +/*===----------------------------------------------------------------------===* + * + * This source file is part of the SwiftNIO open source project + * + * Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors + * Licensed under Apache License v2.0 + * + * See LICENSE.txt for license information + * See CONTRIBUTORS.txt for the list of SwiftNIO project authors + * + * SPDX-License-Identifier: Apache-2.0 + * + *===----------------------------------------------------------------------===*/ + +/* + * example invocation: + * sudo dev/malloc-aggregation.d -c .build/release/NIOHTTP1Server + */ + +::BEGIN { + printf("\n\n"); + printf("=====\n"); + printf("This will collect stack shots of allocations and print it when "); + printf("you exit dtrace.\n"); + printf("So go ahead, run your tests and then press Ctrl+C in this window "); + printf("to see the aggregated result\n"); + printf("=====\n"); +} + +pid$target::malloc:entry { + @malloc_calls[ustack()] = count(); +} + +::END { + printa(@malloc_calls); +} diff --git a/scripts/sanity.sh b/scripts/sanity.sh index 36a5058cc3f..b7611af611b 100755 --- a/scripts/sanity.sh +++ b/scripts/sanity.sh @@ -31,7 +31,7 @@ fi printf "=> Checking license headers... " tmp=$(mktemp /tmp/.swift-nio-sanity_XXXXXX) -for language in swift-or-c bash; do +for language in swift-or-c bash dtrace; do declare -a matching_files declare -a exceptions expections=( ) @@ -73,6 +73,25 @@ EOF ## SPDX-License-Identifier: Apache-2.0 ## ##===----------------------------------------------------------------------===## +EOF + ;; + dtrace) + matching_files=( -name '*.d' ) + cat > "$tmp" <<"EOF" +#!/usr/sbin/dtrace -q -s +/*===----------------------------------------------------------------------===* + * + * This source file is part of the SwiftNIO open source project + * + * Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors + * Licensed under Apache License v2.0 + * + * See LICENSE.txt for license information + * See CONTRIBUTORS.txt for the list of SwiftNIO project authors + * + * SPDX-License-Identifier: Apache-2.0 + * + *===----------------------------------------------------------------------===*/ EOF ;; *)