[swift-evolution] Pitch: (Almost) std libs
Trent Nadeau
tanadeau at gmail.com
Tue Jan 26 21:48:49 CST 2016
Okay. That makes more sense. I was wondering where you would even have
dynamic dispatch to a normal function.
On Tue, Jan 26, 2016 at 10:46 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>
> On Jan 26, 2016, at 19:45 , Jordan Rose <jordan_rose at apple.com> wrote:
>
>
> On Jan 26, 2016, at 18:49 , David Turnbull via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> Functions in a module go through dynamic dispatch. Operators are
> functions. So multiplying two complex numbers won't get inlined. The stdlib
> uses internal tricks so what appears as a module you import is available to
> be specialized and inlined.
>
> To see this in action, try the CubeWorld demo from here:
> https://github.com/AE9RB/SwiftGL
> Then change it so the math libraries aren't modules (move the files,
> delete the import statements). On my system, CPU drops from 60% to 6%. It's
> also the difference between 150 cubes and 1200 cubes at 60 fps. Make sure
> you turn on WMO.
>
> I'm told it won't always be this way. But it is today.
>
>
> Yep. We're planning to improve this but right now it's true: inlining and
> generic specialization does not happen across framework boundaries.
>
>
> Only the generics are really "dynamic dispatch", though. Non-generic code
> is just "function calls that aren't inlined".
>
> Jordan
>
>
--
Trent Nadeau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160126/520d0da8/attachment.html>
More information about the swift-evolution
mailing list