@@ -9312,11 +9312,14 @@ flow as):
9312
9312
}
9313
9313
9314
9314
The benefits of this attribute are:
9315
+
9315
9316
- **Avoid heap allocations for coro frames**: Allocating short-circuiting
9316
9317
coros on the stack makes code more predictable under memory pressure.
9317
9318
Without this attribute, LLVM cannot elide heap allocation even when all
9318
9319
awaiters are short-circuiting.
9320
+
9319
9321
- **Performance**: Significantly faster execution and smaller code size.
9322
+
9320
9323
- **Build time**: Faster compilation due to less IR being generated.
9321
9324
9322
9325
Marking your ``await_suspend_destroy`` method as ``noexcept`` can sometimes
@@ -9343,11 +9346,13 @@ Here is a toy example of a portable short-circuiting awaiter:
9343
9346
9344
9347
If all suspension points use (i) trivial or (ii) short-circuiting awaiters,
9345
9348
then the coroutine optimizes more like a plain function, with 2 caveats:
9349
+
9346
9350
- **Behavior:** The coroutine promise provides an implicit exception boundary
9347
9351
(as if wrapping the function in ``try {} catch { unhandled_exception(); }``).
9348
9352
This exception handling behavior is usually desirable in robust,
9349
9353
return-value-oriented programs that need short-circuiting coroutines.
9350
9354
Otherwise, the promise can always re-throw.
9355
+
9351
9356
- **Speed:** As of 2025, there is still an optimization gap between a
9352
9357
realistic short-circuiting coro, and the equivalent (but much more verbose)
9353
9358
function. For a guesstimate, expect 4-5ns per call on x86. One idea for
0 commit comments