[swift-evolution] [Review] SE-0007 Remove C-style for-loops with conditions and incrementers

David Owens II david at owensd.io
Fri Dec 11 12:18:56 CST 2015


> On Dec 11, 2015, at 9:39 AM, Paul Cantrell <cantrell at pobox.com> wrote:
> 
> Did you get 1000x performance differences in optimized code? Or even >2x?
> 
> Is there any sign that the 1000x differences at -Onone are not solvable? We’ve speculated sufficiently already; I’d want to hear from the compiler developers on that question.
> 
> One should not design a language around its current performance quirks, but certainly _should_ design it around any inherent performance limitations. “Inherent” is open question here.
> 
> P


For optimized code, yes, I’ve seen greater than 2x. The example I’ve shown on this thread is nearly 2x.

Many of the performance issues I ran into had to do with ARC aggressively adding retain/release, especially in the context of array access. The optimizer then goes through and removes a bunch of those it determines are not necessary.

Abstractions aren’t performance quirks; they will _always_ introduce overhead, especially in debug builds. The hope is that the optimizer can be sufficiently magical to turn those abstractions into the equivalent fast code.

I completely agree that for many use cases, the performance overhead of for-in will not have a user measurable impact. I’m simply asking for a way to write the cstyle-loop when I need to without jumping through arbitrary hoops of converting the functionality into a while-loop, and not introducing subtle bugs that I need to validate.

-David


More information about the swift-evolution mailing list