[swift-dev] Zero-cost 'Service Provider Interface'/Signature Packages

Joe Groff jgroff at apple.com
Fri Nov 10 17:05:32 CST 2017



> On Nov 8, 2017, at 9:59 PM, Erik Eckstein via swift-dev <swift-dev at swift.org> wrote:
> 
> 
> 
>> On Nov 8, 2017, at 5:27 PM, Johannes Weiß via swift-dev <swift-dev at swift.org> wrote:
>> 
>> Hi Daniel,
>> 
>>> On 2 Nov 2017, at 8:15 pm, Daniel Dunbar <daniel_dunbar at apple.com> wrote:
>>> 
>>> My personal preference is to:
>>> 1. Do nothing for now, but encourage publishing standardized protocols to solve this need.
>>> 2. Hope for a future with WMO+LTO magic which recovers the performance, for the case where the entire application ends up using one implementation.
>> 
>> Hmm, but that'll only work if we get 'whole product optimisation', right?
> 
> yes.
> 
> Even when we have cross-module optimizations (which would be comparable to thin-lto) we could not do that optimization.
> 
>> If we still compile one module at the time I don't think the compiler will be able to figure out that there's just one implementation of that protocol in the whole program.
> 
> exactly

If you know you're building for an executable target, then it should be theoretically possible to look at the whole system and see that there's a single conformance to a protocol. For the situation Johannes is talking about, maybe this could be information that the build system feeds the compiler, so in a configuration file somewhere you'd say "I want to specialize all uses of the Logger.Logger protocol for the FancyLogger.FancyLogger<MyOutputStream> implementation" instead of relying on the compiler magically deriving it.

-Joe


More information about the swift-dev mailing list