Skip to content
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

Add EventLoop APIs for simpler scheduling of callbacks #2759

Merged
merged 43 commits into from
Oct 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift click to select a range
5f7065f
benchmarks: Add benchmark for MTELG.scheduleTask(in:_:)
simonjbeaumont Jun 28, 2024
33e82e0
api: Add NIOTimer, NIOTimerHandler, and EventLoop.setTimer(for:_:)
simonjbeaumont Jun 28, 2024
b59e31d
benchmarks: Add benchmark for MTELG.setTimer(for:_:)
simonjbeaumont Jun 28, 2024
17cf105
internal: Add NIOCustomTimerImplementation conformance to SelectableE…
simonjbeaumont Jun 28, 2024
0afb3a2
test: Add Linux pre-5.9.2 backport for fulfillment(of:timeout:enforce…
simonjbeaumont Jul 1, 2024
df3cdb1
test: Increase timer used in shutdown test
simonjbeaumont Jul 1, 2024
b0d3f66
feedback: Make NIOTimer Sendable
simonjbeaumont Jul 5, 2024
907c087
feedback: Rename timerFired(loop:) to timerFired(eventLoop:)
simonjbeaumont Jul 8, 2024
b3e4903
feedback(attempted): Store a closure instead of UInt64
simonjbeaumont Jul 8, 2024
fb5e835
feedback(reverted, allocates): Store a closure instead of UInt64
simonjbeaumont Jul 8, 2024
89c57ec
feedback(unsure): Replace extra protocol with runtime checks
simonjbeaumont Jul 8, 2024
59a04de
feedback(unsure): Generic timerFired protocol witness
simonjbeaumont Jul 8, 2024
06a4ce7
feedback(unsure): Make setTimer generic over the handler
simonjbeaumont Jul 8, 2024
950db0c
feedback: Use labelled parameter for handler
simonjbeaumont Jul 8, 2024
d6ae472
feedback: Use separate prepositions for TimeAmount and NIODeadline APIs
simonjbeaumont Jul 8, 2024
4439ac6
Remove DocC disambiguation for now until API is decided
simonjbeaumont Jul 8, 2024
abd4b28
feedback: Add documentation to NIOTimerHandler.timerFired protocol re…
simonjbeaumont Jul 8, 2024
ceabc7b
feedback: Change API terms from setTimer to scheduleCallback
simonjbeaumont Jul 8, 2024
80d91f6
feedback: Local variable rename: taskId -> taskID
simonjbeaumont Jul 10, 2024
2ec5543
feedback: Reanme NIOScheduledCallbackHandler.onSchedule to handleSche…
simonjbeaumont Jul 10, 2024
5d6ac17
feedback: Update protocol requirement documentation comments to use D…
simonjbeaumont Jul 10, 2024
bbf8f9f
feedback: Remove explicit benchmark.stopMeasurement calls
simonjbeaumont Jul 11, 2024
21fd1cc
feedback: Remove TODO following discussion about internal inits
simonjbeaumont Jul 11, 2024
9bf65f6
feedback: Make scheduleCallback throwing
simonjbeaumont Jul 11, 2024
dbba9e3
feedback: Add a missing explicit self
simonjbeaumont Jul 11, 2024
86b8ac3
Merge remote-tracking branch 'upstream/main' into sb/timer-api
simonjbeaumont Jul 12, 2024
b16a575
Remove broken DocC disambiguatoin and fix test calls
simonjbeaumont Jul 12, 2024
4e71ffb
Update implementation comments in EmbeddedEventLoop and AsyncTestingE…
simonjbeaumont Jul 15, 2024
b909365
feedback: Fix preconditionFailure message
simonjbeaumont Jul 15, 2024
5559772
feedback: Move SheduledTask.Kind and kind above other properties
simonjbeaumont Jul 15, 2024
7f159be
feedback: Measure .instructions instead of .cpuTotal
simonjbeaumont Jul 15, 2024
3ad5647
feedback: Remove vestigial references to setTimer in impl comments
simonjbeaumont Jul 15, 2024
bd8fa73
Merge remote-tracking branch 'upstream/main' into HEAD
simonjbeaumont Jul 25, 2024
6af561d
Add cancellation callback and implicitly cancel on shutdown
simonjbeaumont Jul 19, 2024
81cc415
format: Update for new format and lint rules
simonjbeaumont Jul 25, 2024
37ebfde
Merge remote-tracking branch 'upstream/main' into sb/timer-api
simonjbeaumont Jul 30, 2024
4467728
Remove use of Task.sleep(for:) in tests
simonjbeaumont Jul 30, 2024
6544461
Merge remote-tracking branch 'upstream/main' into sb/timer-api
simonjbeaumont Aug 15, 2024
c48b7aa
Update benchmark to use same config as other benchmarks
simonjbeaumont Aug 15, 2024
151c2c8
Rename onCancelScheduledCallback to didCancelScheduledCallback
simonjbeaumont Aug 15, 2024
5e61930
Merge branch 'main' into sb/timer-api
simonjbeaumont Sep 30, 2024
0a2baf3
Merge branch 'main' into sb/timer-api
simonjbeaumont Oct 3, 2024
ba63fda
Make AsyncStream.makeStream backfill internal
simonjbeaumont Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
benchmarks: Add benchmark for MTELG.setTimer(for:_:)
  • Loading branch information
simonjbeaumont committed Jun 28, 2024
commit b59e31d63c1c7b5741032d774191217ebdf40297
25 changes: 24 additions & 1 deletion Benchmarks/Benchmarks/NIOPosixBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 13,8 @@
//===----------------------------------------------------------------------===//

import Benchmark
import NIOPosix
import NIOCore
import NIOPosix

private let eventLoop = MultiThreadedEventLoopGroup.singleton.next()

Expand Down Expand Up @@ -83,4 83,27 @@ let benchmarks = {
}
benchmark.stopMeasurement()
simonjbeaumont marked this conversation as resolved.
Show resolved Hide resolved
}

Benchmark(
"MTELG.setTimer(for:_:)",
configuration: Benchmark.Configuration(
metrics: [.mallocCountTotal, .cpuTotal],
scalingFactor: .kilo
)
) { benchmark in
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { try! group.syncShutdownGracefully() }
let loop = group.next()

final class Timer: NIOTimerHandler {
func timerFired(loop: any EventLoop) {}
}
let timer = Timer()

benchmark.startMeasurement()
for _ in benchmark.scaledIterations {
let handle = loop.setTimer(for: .hours(1), timer)
simonjbeaumont marked this conversation as resolved.
Show resolved Hide resolved
}
benchmark.stopMeasurement()
}
}