Skip to content

Commit

Permalink
Add allocation counter tests for isolated EL operations (#3068)
Browse files Browse the repository at this point in the history
Motivation:

As with the ELF operations before them, the isolated EL operations
currently incur overhead above-and-beyond the overhead of their
non-isolated counterparts. That's not what we want to see. However,
before we "fix" them, we need to add regression testing to confirm our
fix actually worked.

Modifications:

- Add isolated variations of all current EL scheduling tests.
- Where isolated methods didn't have alloc counter tests, add new ones
for the non-isolated versions too.

Result:

More tests.
  • Loading branch information
Lukasa authored Jan 17, 2025
1 parent f5773c1 commit 15a38ae
Show file tree
Hide file tree
Showing 13 changed files with 352 additions and 2 deletions.
8 changes: 8 additions & 0 deletions IntegrationTests/tests_04_performance/Thresholds/5.10.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"1000_udpbootstraps": 2050,
"1000_udpconnections": 75050,
"1_reqs_1000_conn": 384050,
"assume_isolated_scheduling_10000_executions": 20100,
"bytebuffer_lots_of_rw": 2050,
"creating_10000_headers": 0,
"decode_1000_ws_frames": 2050,
Expand All @@ -32,6 +33,8 @@
"encode_1000_ws_frames_new_buffer_with_space": 3050,
"encode_1000_ws_frames_new_buffer_with_space_with_mask": 5050,
"execute_hop_10000_tasks": 0,
"flat_schedule_10000_tasks": 130100,
"flat_schedule_assume_isolated_10000_tasks": 150100,
"future_assume_isolated_lots_of_callbacks": 74050,
"future_erase_result": 4050,
"future_lots_of_callbacks": 74050,
Expand All @@ -45,7 +48,12 @@
"read_10000_chunks_from_file": 110050,
"schedule_10000_tasks": 40100,
"schedule_and_run_10000_tasks": 50050,
"schedule_assume_isolated_10000_tasks": 50100,
"schedule_with_deadline_10000_tasks": 40100,
"schedule_with_deadline_assume_isolated_10000_tasks": 50100,
"scheduling_10000_executions": 89,
"submit_10000_tasks": 20100,
"submit_assume_isolated_10000_tasks": 30100,
"udp_1000_reqs_1_conn": 6200,
"udp_1_reqs_1000_conn": 162050
}
8 changes: 8 additions & 0 deletions IntegrationTests/tests_04_performance/Thresholds/5.9.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"1000_udpbootstraps": 2050,
"1000_udpconnections": 75050,
"1_reqs_1000_conn": 393050,
"assume_isolated_scheduling_10000_executions": 20100,
"bytebuffer_lots_of_rw": 2050,
"creating_10000_headers": 0,
"decode_1000_ws_frames": 2050,
Expand All @@ -32,6 +33,8 @@
"encode_1000_ws_frames_new_buffer_with_space": 3050,
"encode_1000_ws_frames_new_buffer_with_space_with_mask": 5050,
"execute_hop_10000_tasks": 0,
"flat_schedule_10000_tasks": 130100,
"flat_schedule_assume_isolated_10000_tasks": 150100,
"future_assume_isolated_lots_of_callbacks": 74050,
"future_erase_result": 4050,
"future_lots_of_callbacks": 74050,
Expand All @@ -45,7 +48,12 @@
"read_10000_chunks_from_file": 110050,
"schedule_10000_tasks": 40100,
"schedule_and_run_10000_tasks": 50050,
"schedule_assume_isolated_10000_tasks": 50100,
"schedule_with_deadline_10000_tasks": 40100,
"schedule_with_deadline_assume_isolated_10000_tasks": 50100,
"scheduling_10000_executions": 89,
"submit_10000_tasks": 20100,
"submit_assume_isolated_10000_tasks": 30100,
"udp_1000_reqs_1_conn": 6200,
"udp_1_reqs_1000_conn": 162050
}
10 changes: 9 additions & 1 deletion IntegrationTests/tests_04_performance/Thresholds/6.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"1000_udp_reqs": 6050,
"1000_udpbootstraps": 2050,
"1000_udpconnections": 75050,
"1_reqs_1000_conn": 384000,
"1_reqs_1000_conn": 384050,
"assume_isolated_scheduling_10000_executions": 20100,
"bytebuffer_lots_of_rw": 2050,
"creating_10000_headers": 0,
"decode_1000_ws_frames": 2050,
Expand All @@ -32,6 +33,8 @@
"encode_1000_ws_frames_new_buffer_with_space": 3050,
"encode_1000_ws_frames_new_buffer_with_space_with_mask": 5050,
"execute_hop_10000_tasks": 0,
"flat_schedule_10000_tasks": 130100,
"flat_schedule_assume_isolated_10000_tasks": 150100,
"future_assume_isolated_lots_of_callbacks": 74050,
"future_erase_result": 4050,
"future_lots_of_callbacks": 74050,
Expand All @@ -45,7 +48,12 @@
"read_10000_chunks_from_file": 110050,
"schedule_10000_tasks": 40100,
"schedule_and_run_10000_tasks": 50050,
"schedule_assume_isolated_10000_tasks": 50100,
"schedule_with_deadline_10000_tasks": 40100,
"schedule_with_deadline_assume_isolated_10000_tasks": 50100,
"scheduling_10000_executions": 89,
"submit_10000_tasks": 20100,
"submit_assume_isolated_10000_tasks": 30100,
"udp_1000_reqs_1_conn": 6200,
"udp_1_reqs_1000_conn": 162050
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"1000_udp_reqs": 6050,
"1000_udpbootstraps": 2050,
"1000_udpconnections": 75050,
"1_reqs_1000_conn": 384000,
"1_reqs_1000_conn": 384050,
"assume_isolated_scheduling_10000_executions": 20100,
"bytebuffer_lots_of_rw": 2050,
"creating_10000_headers": 0,
"decode_1000_ws_frames": 2050,
Expand All @@ -32,6 +33,8 @@
"encode_1000_ws_frames_new_buffer_with_space": 3050,
"encode_1000_ws_frames_new_buffer_with_space_with_mask": 5050,
"execute_hop_10000_tasks": 0,
"flat_schedule_10000_tasks": 130100,
"flat_schedule_assume_isolated_10000_tasks": 150100,
"future_assume_isolated_lots_of_callbacks": 74050,
"future_erase_result": 4050,
"future_lots_of_callbacks": 74050,
Expand All @@ -45,7 +48,12 @@
"read_10000_chunks_from_file": 110050,
"schedule_10000_tasks": 40100,
"schedule_and_run_10000_tasks": 50050,
"schedule_assume_isolated_10000_tasks": 50100,
"schedule_with_deadline_10000_tasks": 40100,
"schedule_with_deadline_assume_isolated_10000_tasks": 50100,
"scheduling_10000_executions": 89,
"submit_10000_tasks": 20100,
"submit_assume_isolated_10000_tasks": 30100,
"udp_1000_reqs_1_conn": 6200,
"udp_1_reqs_1000_conn": 162050
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"1000_udpbootstraps": 2050,
"1000_udpconnections": 75050,
"1_reqs_1000_conn": 384050,
"assume_isolated_scheduling_10000_executions": 20100,
"bytebuffer_lots_of_rw": 2050,
"creating_10000_headers": 0,
"decode_1000_ws_frames": 2050,
Expand All @@ -32,6 +33,8 @@
"encode_1000_ws_frames_new_buffer_with_space": 3050,
"encode_1000_ws_frames_new_buffer_with_space_with_mask": 5050,
"execute_hop_10000_tasks": 0,
"flat_schedule_10000_tasks": 130100,
"flat_schedule_assume_isolated_10000_tasks": 150100,
"future_assume_isolated_lots_of_callbacks": 74050,
"future_erase_result": 4050,
"future_lots_of_callbacks": 74050,
Expand All @@ -45,7 +48,12 @@
"read_10000_chunks_from_file": 110050,
"schedule_10000_tasks": 40100,
"schedule_and_run_10000_tasks": 50050,
"schedule_assume_isolated_10000_tasks": 50100,
"schedule_with_deadline_10000_tasks": 40100,
"schedule_with_deadline_assume_isolated_10000_tasks": 50100,
"scheduling_10000_executions": 89,
"submit_10000_tasks": 20100,
"submit_assume_isolated_10000_tasks": 30100,
"udp_1000_reqs_1_conn": 6200,
"udp_1_reqs_1000_conn": 162050
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2025 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 Dispatch
import NIOPosix

func run(identifier: String) {
measure(identifier: identifier) {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let loop = group.next()
let dg = DispatchGroup()

try! loop.submit {
for _ in 0..<10_000 {
dg.enter()
loop.assumeIsolated().execute { dg.leave() }
}
}.wait()
dg.wait()
try! group.syncShutdownGracefully()
return 10_000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2019-2025 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 Dispatch
import NIOCore
import NIOPosix

func run(identifier: String) {
measure(identifier: identifier) {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let loop = group.next()
let counter = try! loop.submit { () -> Int in
var counter: Int = 0

let deadline = NIODeadline.now() + .hours(1)

for _ in 0..<10000 {
loop.flatScheduleTask(deadline: deadline) {
counter &+= 1
return loop.makeSucceededFuture(counter)
}
}

return counter
}.wait()

try! group.syncShutdownGracefully()
return counter
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2019-2025 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 Dispatch
import NIOCore
import NIOPosix

func run(identifier: String) {
measure(identifier: identifier) {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let loop = group.next()
let counter = try! loop.submit { () -> Int in
var counter: Int = 0

let deadline = NIODeadline.now() + .hours(1)

for _ in 0..<10000 {
loop.assumeIsolated().flatScheduleTask(deadline: deadline) {
counter &+= 1
return loop.makeSucceededFuture(counter)
}
}

return counter
}.wait()

try! group.syncShutdownGracefully()
return counter
}
}
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) 2019-2025 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 Dispatch
import NIOPosix

func run(identifier: String) {
measure(identifier: identifier) {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let loop = group.next()
let counter = try! loop.submit { () -> Int in
var counter: Int = 0

for _ in 0..<10000 {
loop.assumeIsolated().scheduleTask(in: .hours(1)) {
counter &+= 1
}
}

return counter
}.wait()

try! group.syncShutdownGracefully()
return counter
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2019-2025 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 Dispatch
import NIOCore
import NIOPosix

func run(identifier: String) {
measure(identifier: identifier) {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let loop = group.next()
let counter = try! loop.submit { () -> Int in
var counter: Int = 0

let deadline = NIODeadline.now() + .hours(1)

for _ in 0..<10000 {
loop.scheduleTask(deadline: deadline) {
counter &+= 1
}
}

return counter
}.wait()

try! group.syncShutdownGracefully()
return counter
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2019-2025 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 Dispatch
import NIOCore
import NIOPosix

func run(identifier: String) {
measure(identifier: identifier) {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let loop = group.next()
let counter = try! loop.submit { () -> Int in
var counter: Int = 0

let deadline = NIODeadline.now() + .hours(1)

for _ in 0..<10000 {
loop.assumeIsolated().scheduleTask(deadline: deadline) {
counter &+= 1
return counter
}
}

return counter
}.wait()

try! group.syncShutdownGracefully()
return counter
}
}
Loading

0 comments on commit 15a38ae

Please sign in to comment.