[swift-evolution] Draft: Add @noescape and rethrows to ManagedBuffer API

Károly Lőrentey karoly at lorentey.hu
Mon Feb 8 09:08:33 CST 2016

> On 2016-02-07, at 16:18, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> On first look this seems to be a great idea.  Have you checked for
> performance impact?

Yes, although I found it challenging to create a good 
microbenchmark for this. Subtle changes in the benchmarking code
lead to large swings in runtime performance, which makes me question
the usefulness of my results.

Keeping that in mind, for a trivial ManagedBuffer subclass, I found 
that @noescape makes for a ~15-18% improvement when whole module 
optimization is disabled, or when the subclass is imported.

Throwing in the rethrows declarations reduces the improvement to 
~9-13%, or (in the case of a particular subscript getter test) even 
reverses it, making the code ~3% slower.

The proposal has no discernible impact on ManagedBuffer subclasses
that the optimizer has full access to. (I.e., when they’re defined
in the same file as the code that’s using them, or in the same 
module with WMO.) Unoptimized code also seems unaffected by these 

My benchmarking code is on GitHub; feedback would be very welcome:



More information about the swift-evolution mailing list