diff --git a/IntegrationTests/tests_04_performance/Thresholds/5.10.json b/IntegrationTests/tests_04_performance/Thresholds/5.10.json index 844e978418..fd2d7003ad 100644 --- a/IntegrationTests/tests_04_performance/Thresholds/5.10.json +++ b/IntegrationTests/tests_04_performance/Thresholds/5.10.json @@ -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, @@ -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, @@ -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 } diff --git a/IntegrationTests/tests_04_performance/Thresholds/5.9.json b/IntegrationTests/tests_04_performance/Thresholds/5.9.json index 6e9df5a2fb..760bb3b20b 100644 --- a/IntegrationTests/tests_04_performance/Thresholds/5.9.json +++ b/IntegrationTests/tests_04_performance/Thresholds/5.9.json @@ -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, @@ -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, @@ -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 } diff --git a/IntegrationTests/tests_04_performance/Thresholds/6.0.json b/IntegrationTests/tests_04_performance/Thresholds/6.0.json index 5235f29b38..fd2d7003ad 100644 --- a/IntegrationTests/tests_04_performance/Thresholds/6.0.json +++ b/IntegrationTests/tests_04_performance/Thresholds/6.0.json @@ -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, @@ -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, @@ -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 } diff --git a/IntegrationTests/tests_04_performance/Thresholds/nightly-6.0.json b/IntegrationTests/tests_04_performance/Thresholds/nightly-6.0.json index 5235f29b38..fd2d7003ad 100644 --- a/IntegrationTests/tests_04_performance/Thresholds/nightly-6.0.json +++ b/IntegrationTests/tests_04_performance/Thresholds/nightly-6.0.json @@ -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, @@ -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, @@ -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 } diff --git a/IntegrationTests/tests_04_performance/Thresholds/nightly-main.json b/IntegrationTests/tests_04_performance/Thresholds/nightly-main.json index 5500c5235f..194000e8e0 100644 --- a/IntegrationTests/tests_04_performance/Thresholds/nightly-main.json +++ b/IntegrationTests/tests_04_performance/Thresholds/nightly-main.json @@ -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, @@ -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, @@ -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 } diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_assume_isolated_scheduling_10000_executions.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_assume_isolated_scheduling_10000_executions.swift new file mode 100644 index 0000000000..7087e17aa7 --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_assume_isolated_scheduling_10000_executions.swift @@ -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 + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_10000_tasks.swift new file mode 100644 index 0000000000..1d80f8d43f --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_10000_tasks.swift @@ -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 + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_assume_isolated_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_assume_isolated_10000_tasks.swift new file mode 100644 index 0000000000..4f980a00b0 --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_assume_isolated_10000_tasks.swift @@ -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 + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_assume_isolated_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_assume_isolated_10000_tasks.swift new file mode 100644 index 0000000000..7d63b19fbc --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_assume_isolated_10000_tasks.swift @@ -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 + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_with_deadline_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_with_deadline_10000_tasks.swift new file mode 100644 index 0000000000..8b10c78eb6 --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_with_deadline_10000_tasks.swift @@ -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 + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_with_deadline_assume_isolated_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_with_deadline_assume_isolated_10000_tasks.swift new file mode 100644 index 0000000000..b0e157b0c9 --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_schedule_with_deadline_assume_isolated_10000_tasks.swift @@ -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 + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_submit_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_submit_10000_tasks.swift new file mode 100644 index 0000000000..88ae885422 --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_submit_10000_tasks.swift @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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.submit { + counter &+= 1 + return counter + } + } + + return counter + }.wait() + + try! group.syncShutdownGracefully() + return counter + } +} diff --git a/IntegrationTests/tests_04_performance/test_01_resources/test_submit_assume_isolated_10000_tasks.swift b/IntegrationTests/tests_04_performance/test_01_resources/test_submit_assume_isolated_10000_tasks.swift new file mode 100644 index 0000000000..47f16587ab --- /dev/null +++ b/IntegrationTests/tests_04_performance/test_01_resources/test_submit_assume_isolated_10000_tasks.swift @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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().submit { + counter &+= 1 + return counter + } + } + + return counter + }.wait() + + try! group.syncShutdownGracefully() + return counter + } +}