feat(minor): Use Swift 6's isolated(any) feature to unblock the main actor and run benchmarks in whatever isolation context they require (#358) - #359
Conversation
…un benchmarks in whatever isolation context they require (ordo-one#358).
isolated(any) feature to unblock the main actor and run benchmarks in whatever isolation context they require (#358)isolated(any) feature to unblock the main actor and run benchmarks in whatever isolation context they require (#358)
|
Awesome, thanks for the contribution! Just a few concerns:
let closure = { @MainActor in
print("hello")
}
|
|
I think we can drop pre 6.0 swift now if needed, no problem - in general the official stance is the last 3 major releases at any given time (same as most Apple projects). |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #359 +/- ##
==========================================
+ Coverage 69.27% 70.50% +1.23%
==========================================
Files 35 35
Lines 3296 3393 +97
==========================================
+ Hits 2283 2392 +109
+ Misses 1013 1001 -12
... and 1 file with indirect coverage changes
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Description
See #358 for full details, but in short: previously, the main thread / actor was being blocked by a wait on a semaphore inside
runAsync, which meant any benchmark which relied on executing something on the main thread / actor / queue would deadlock.Now, the main actor / thread / queue is not blocked - and furthermore, benchmarks can annotate themselves with a global actor (e.g.
@MainActor) and be run there directly, by the Benchmark framework.How Has This Been Tested?
I added three new unit tests covering two critical cases:
@MainActorbenchmark runs on the main actor.(hopefully the explicit-hop case is made uncommon by being able to just
@MainActorthe benchmark to begin with, but the big concern is the indirect use of code which does that, such as in some library or deep down a callchain)Note: I've only tested this with Swift 6.2.4 on Sequoia.
Minimal checklist:
I have addedDocCcode-level documentation for any public interfaces exported by the package