-
Notifications
You must be signed in to change notification settings - Fork 652
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
Dn loop bound box benchmark #2778
Open
dnadoba
wants to merge
14
commits into
apple:main
Choose a base branch
from
dnadoba:dn-loop-bound-box-benchmark
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
33e3a55
Add NIOLoopBoundBox benchmark
dnadoba 3842f7c
run `./dev/update-benchmark-thresholds.sh`
dnadoba 7927b1f
Merge branch 'main' into dn-loop-bound-box-benchmark
dnadoba 6bc8978
run CI again
dnadoba 90863cb
Merge branch 'dn-loop-bound-box-benchmark' of github.com:dnadoba/swif…
dnadoba a87b349
Merge branch 'main' into dn-loop-bound-box-benchmark
dnadoba 05ab847
Update benchmark loop
dnadoba d14d7a9
Fix benchmark thresholds update script
FranzBusch 014e903
Merge branch 'fb-benchmark-update-thresholds' into dn-loop-bound-box-…
dnadoba 1dd1710
run `./dev/update-benchmark-thresholds.sh`
dnadoba e9b71b7
Remove inner loop
dnadoba 4b4181b
Merge branch 'main' into dn-loop-bound-box-benchmark
dnadoba b25527a
run ./dev/update-benchmark-thresholds.sh
dnadoba 986dc2e
run ./dev/update-benchmark-thresholds.sh again
dnadoba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
37 changes: 37 additions & 0 deletions
37
Benchmarks/Benchmarks/NIOCoreBenchmarks/NIOLoopBoundBox.swift
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,37 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the SwiftNIO open source project | ||
// | ||
// Copyright (c) 2024 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import NIOCore | ||
import NIOEmbedded | ||
import Benchmark | ||
|
||
func runNIOLoopBoundBoxInPlaceMutation(benchmark: Benchmark) { | ||
let embeddedEventLoop = EmbeddedEventLoop() | ||
let boundBox = NIOLoopBoundBox([Int](), eventLoop: embeddedEventLoop) | ||
boundBox.value.reserveCapacity(1000) | ||
|
||
benchmark.startMeasurement() | ||
|
||
for _ in benchmark.scaledIterations { | ||
boundBox.value.removeAll(keepingCapacity: true) | ||
for i in 0..<1000 { | ||
boundBox.value.append(i) | ||
} | ||
} | ||
|
||
benchmark.stopMeasurement() | ||
|
||
precondition(boundBox.value.count == 1000) | ||
precondition(boundBox.value.reduce(0, +) == 499500) | ||
} |
2 changes: 1 addition & 1 deletion
2
Benchmarks/Thresholds/5.10/NIOCoreBenchmarks.NIOAsyncChannel.init.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 12 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Benchmarks/Thresholds/5.10/NIOCoreBenchmarks.NIOLoopBoundBox.value.p90.json
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,3 @@ | ||
{ | ||
"mallocCountTotal" : 0 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/5.10/NIOPosixBenchmarks.TCPEcho.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 108 | ||
} | ||
"mallocCountTotal" : 90 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/5.10/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 165000 | ||
} | ||
"mallocCountTotal" : 163578 | ||
} |
2 changes: 1 addition & 1 deletion
2
Benchmarks/Thresholds/5.8/NIOCoreBenchmarks.NIOAsyncChannel.init.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 12 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Benchmarks/Thresholds/5.8/NIOCoreBenchmarks.NIOLoopBoundBox.value.p90.json
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,3 @@ | ||
{ | ||
"mallocCountTotal" : 0 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/5.8/NIOPosixBenchmarks.TCPEcho.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 110 | ||
} | ||
"mallocCountTotal" : 92 | ||
} |
2 changes: 1 addition & 1 deletion
2
Benchmarks/Thresholds/5.9/NIOCoreBenchmarks.NIOAsyncChannel.init.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 12 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Benchmarks/Thresholds/5.9/NIOCoreBenchmarks.NIOLoopBoundBox.value.p90.json
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,3 @@ | ||
{ | ||
"mallocCountTotal" : 0 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/5.9/NIOPosixBenchmarks.TCPEcho.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 110 | ||
} | ||
"mallocCountTotal" : 92 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/5.9/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 164000 | ||
} | ||
"mallocCountTotal" : 164224 | ||
} |
2 changes: 1 addition & 1 deletion
2
Benchmarks/Thresholds/nightly-main/NIOCoreBenchmarks.NIOAsyncChannel.init.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 12 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Benchmarks/Thresholds/nightly-main/NIOCoreBenchmarks.NIOLoopBoundBox.value.p90.json
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,3 @@ | ||
{ | ||
"mallocCountTotal" : 0 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/nightly-main/NIOPosixBenchmarks.TCPEcho.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 108 | ||
} | ||
"mallocCountTotal" : 90 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/nightly-main/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 165000 | ||
} | ||
"mallocCountTotal" : 164212 | ||
} |
2 changes: 1 addition & 1 deletion
2
Benchmarks/Thresholds/nightly-next/NIOCoreBenchmarks.NIOAsyncChannel.init.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 12 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Benchmarks/Thresholds/nightly-next/NIOCoreBenchmarks.NIOLoopBoundBox.value.p90.json
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,3 @@ | ||
{ | ||
"mallocCountTotal" : 0 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/nightly-next/NIOPosixBenchmarks.TCPEcho.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 108 | ||
} | ||
"mallocCountTotal" : 90 | ||
} |
4 changes: 2 additions & 2 deletions
4
Benchmarks/Thresholds/nightly-next/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"mallocCountTotal" : 165000 | ||
} | ||
"mallocCountTotal" : 164204 | ||
} |
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
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,91 @@ | ||
version: "3" | ||
|
||
services: | ||
|
||
runtime-setup: | ||
image: swift-nio:22.04-next | ||
build: | ||
args: | ||
base_image: "swiftlang/swift:nightly-6.0-jammy" | ||
|
||
unit-tests: | ||
image: swift-nio:22.04-next | ||
|
||
integration-tests: | ||
image: swift-nio:22.04-next | ||
|
||
documentation-check: | ||
image: swift-nio:22.04-next | ||
|
||
test: | ||
image: swift-nio:22.04-next | ||
environment: | ||
- SWIFT_VERSION=nightly-next | ||
- MAX_ALLOCS_ALLOWED_10000000_asyncsequenceproducer=21 | ||
- MAX_ALLOCS_ALLOWED_1000000_asyncwriter=1000050 | ||
- MAX_ALLOCS_ALLOWED_1000_addHandlers=45050 | ||
- MAX_ALLOCS_ALLOWED_1000_addHandlers_sync=38050 | ||
- MAX_ALLOCS_ALLOWED_1000_addRemoveHandlers_handlercontext=8050 | ||
- MAX_ALLOCS_ALLOWED_1000_addRemoveHandlers_handlername=8050 | ||
- MAX_ALLOCS_ALLOWED_1000_addRemoveHandlers_handlertype=8050 | ||
- MAX_ALLOCS_ALLOWED_1000_autoReadGetAndSet=18050 | ||
- MAX_ALLOCS_ALLOWED_1000_autoReadGetAndSet_sync=0 | ||
- MAX_ALLOCS_ALLOWED_1000_copying_bytebufferview_to_array=1050 | ||
- MAX_ALLOCS_ALLOWED_1000_copying_circularbuffer_to_array=1050 | ||
- MAX_ALLOCS_ALLOWED_1000_getHandlers=8050 | ||
- MAX_ALLOCS_ALLOWED_1000_getHandlers_sync=36 | ||
- MAX_ALLOCS_ALLOWED_1000_reqs_1_conn=26400 | ||
- MAX_ALLOCS_ALLOWED_1000_rst_connections=147000 | ||
- MAX_ALLOCS_ALLOWED_1000_tcpbootstraps=3050 | ||
- MAX_ALLOCS_ALLOWED_1000_tcpconnections=155050 | ||
- MAX_ALLOCS_ALLOWED_1000_udp_reqs=6050 | ||
- MAX_ALLOCS_ALLOWED_1000_udpbootstraps=2050 | ||
- MAX_ALLOCS_ALLOWED_1000_udpconnections=76050 | ||
- MAX_ALLOCS_ALLOWED_1_reqs_1000_conn=393000 | ||
- MAX_ALLOCS_ALLOWED_bytebuffer_lots_of_rw=2050 | ||
- MAX_ALLOCS_ALLOWED_creating_10000_headers=0 | ||
- MAX_ALLOCS_ALLOWED_decode_1000_ws_frames=2050 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_holding_buffer=3 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_holding_buffer_with_mask=2050 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_holding_buffer_with_space=3 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_holding_buffer_with_space_with_mask=2050 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_new_buffer=3050 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_new_buffer_with_mask=5050 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_new_buffer_with_space=3050 | ||
- MAX_ALLOCS_ALLOWED_encode_1000_ws_frames_new_buffer_with_space_with_mask=5050 | ||
- MAX_ALLOCS_ALLOWED_execute_hop_10000_tasks=0 | ||
- MAX_ALLOCS_ALLOWED_future_erase_result=4050 | ||
- MAX_ALLOCS_ALLOWED_future_lots_of_callbacks=53050 | ||
- MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form=700050 | ||
- MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace=700050 | ||
- MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_long_string=700050 | ||
- MAX_ALLOCS_ALLOWED_get_100000_headers_canonical_form_trimming_whitespace_from_short_string=700050 | ||
- MAX_ALLOCS_ALLOWED_modifying_1000_circular_buffer_elements=0 | ||
- MAX_ALLOCS_ALLOWED_modifying_byte_buffer_view=6050 | ||
- MAX_ALLOCS_ALLOWED_ping_pong_1000_reqs_1_conn=343 | ||
- MAX_ALLOCS_ALLOWED_read_10000_chunks_from_file=110200 | ||
- MAX_ALLOCS_ALLOWED_schedule_10000_tasks=50100 | ||
- MAX_ALLOCS_ALLOWED_schedule_and_run_10000_tasks=50050 | ||
- MAX_ALLOCS_ALLOWED_scheduling_10000_executions=89 | ||
- MAX_ALLOCS_ALLOWED_udp_1000_reqs_1_conn=6200 | ||
- MAX_ALLOCS_ALLOWED_udp_1_reqs_1000_conn=165050 | ||
- WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors | ||
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error | ||
# - SANITIZER_ARG=--sanitize=thread # TSan broken still | ||
|
||
performance-test: | ||
image: swift-nio:22.04-next | ||
|
||
update-benchmark-baseline: | ||
image: swift-nio:22.04-next | ||
environment: | ||
- SWIFT_VERSION=nightly-next | ||
|
||
shell: | ||
image: swift-nio:22.04-next | ||
|
||
echo: | ||
image: swift-nio:22.04-next | ||
|
||
http: | ||
image: swift-nio:22.04-next |
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 should only have the scaled iterations loop, not this inner one.
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.
How does that protect against runtime allocations?
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.
Also, this is now no longer testing what I wanted to test: the performance of repeated mutation of value. CoW types like Array generally can have one off allocations but that isn't the real problem. The problem is if it happens on every iteration in a loop.
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.
For the future, the reason looping
scaledIterations
times helps is that the malloc values output are divided byscaledIterations
. This means any allocation that doesn't happen every loop iteration is folded away, so spurious runtime allocations that may slightly differ between runs don't affect our thresholds.