-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add allocation counter tests for isolated EL operations (#3068)
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
Showing
13 changed files
with
352 additions
and
2 deletions.
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
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
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
34 changes: 34 additions & 0 deletions
34
...s_04_performance/test_01_resources/test_assume_isolated_scheduling_10000_executions.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,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 | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
IntegrationTests/tests_04_performance/test_01_resources/test_flat_schedule_10000_tasks.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,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 | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...sts_04_performance/test_01_resources/test_flat_schedule_assume_isolated_10000_tasks.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,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 | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ts/tests_04_performance/test_01_resources/test_schedule_assume_isolated_10000_tasks.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) 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 | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ests/tests_04_performance/test_01_resources/test_schedule_with_deadline_10000_tasks.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,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 | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...rformance/test_01_resources/test_schedule_with_deadline_assume_isolated_10000_tasks.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,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 | ||
} | ||
} |
Oops, something went wrong.