<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>That setting breaks incremental compilation, so you're getting clean build speed at the expense of incremental builds. </div><div><br></div><div><br></div><div><br></div><div>Jon</div><div><br>On Mar 28, 2017, at 7:35 AM, Bartłomiej Nowak via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">I’ve had the same issue and adding a user-defined setting `<span style="color: rgb(36, 39, 41); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">SWIFT_WHOLE_MODULE_OPTIMIZATION = YES` seemed to fix this. Down from 12 minutes to 2.5 after clean -> build.</span></div><div class=""><br class=""></div><div class="">The question is why do we have to set such flags in Xcode ourselves, when it most probably should be the default setting?</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">Wiadomość napisana przez Mark Lacey via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> w dniu 23.03.2017, o godz. 18:06:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 23, 2017, at 10:02 AM, piotr gorzelany <<a href="mailto:piotr.gorzelany@gmail.com" class="">piotr.gorzelany@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">I tried using it with the latest Xcode release (version 8.2).<br class=""></div></blockquote><div class=""><br class=""></div><div class="">That was released prior to the addition of the new option. Recent snapshot builds from <a href="https://swift.org/download/#snapshots" class="">https://swift.org/download/#snapshots</a> as well as the more recent Xcode 8.3 betas have it.</div><div class=""><br class=""></div><div class="">Mark</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">W dniu czw., 23.03.2017 o 17:57 Mark Lacey <<a href="mailto:mark.lacey@apple.com" class="">mark.lacey@apple.com</a>> napisał(a):<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Mar 23, 2017, at 1:58 AM, piotr gorzelany <<a href="mailto:piotr.gorzelany@gmail.com" class="gmail_msg" target="_blank">piotr.gorzelany@gmail.com</a>> wrote:</div><br class="gmail_msg m_-715454834713398955Apple-interchange-newline"><div class="gmail_msg"><div dir="ltr" class="gmail_msg">Hi Mark,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks for the answer, its great to know that somebody is working on it!</div><div class="gmail_msg"><br class="gmail_msg">I tried to add the <span style="font-size:13px" class="gmail_msg">-Xfrontend -debug-time-expression-type-ch</span><span style="font-size:13px" class="gmail_msg">ecking in Xcode in the Other Swift Flags section but that gives me an error when compiling </span></div><div class="gmail_msg"><span style="font-size:13px" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><div style="margin:0px 0px 0px 12px;font-size:11px;line-height:normal;font-family:menlo" class="gmail_msg"><unknown>:0: error: unknown argument: '-debug-time-expression-type-checking'</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Should I rather compile it on the command line using this option?</div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I added this to the compiler within the last couple months so you need to be using a recent build in order to use this command-line option. Where did the compiler that you tried it with come from?</div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Mark</div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Regards,</div><div class="gmail_msg">Piotr</div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">czw., 23 mar 2017 o 08:54 użytkownik Mark Lacey via swift-users <<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>> napisał:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
> On Mar 23, 2017, at 12:32 AM, Rien via swift-users <<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
>> On 23 Mar 2017, at 08:27, David Hart <<a href="mailto:david@hartbit.com" class="gmail_msg" target="_blank">david@hartbit.com</a>> wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> Yes, it's best to avoid concatenating strings with +. Not only for performance reasons, but it's also less readable than string interpolation:<br class="gmail_msg">
>><br class="gmail_msg">
>> str += "No: \(count), HostIp: \(clientIp ?? "?") at port: \(service ?? "?")\n”<br class="gmail_msg">
><br class="gmail_msg">
> Concatenation may cause the increase, but this solved it too:<br class="gmail_msg">
><br class="gmail_msg">
> let (clientIpOrNil, serviceOrNil) = sockaddrDescription(info.pointee.ai_addr)<br class="gmail_msg">
> let clientIp = clientIpOrNil ?? "?"<br class="gmail_msg">
> let service = serviceOrNil ?? "?"<br class="gmail_msg">
> str += "No: \(count), HostIp: " + clientIp + " at port: " + service + "\n”<br class="gmail_msg">
<br class="gmail_msg">
To make a long story short, expressions combining the results of nil-coalescing with other operators tend to be very slow to type check at the moment. I’m working on fixing this (really the more general issue as it is not specific to ?? but I’ve seen several bug reports that involve that operator).<br class="gmail_msg">
<br class="gmail_msg">
I added another command-line option to help track issues like this down (at the expression level, rather than function level):<br class="gmail_msg">
-Xfrontend -debug-time-expression-type-checking<br class="gmail_msg">
<br class="gmail_msg">
If you use that you’ll see a line for every expression that is type-checked, with source location information, and the time to type check the expression. In some cases we may not have valid source information (I believe this generally happens for things the compiler synthesizes rather than user code), and you’ll see ‘<invalid loc>’ rather than the file/line/column info.<br class="gmail_msg">
<br class="gmail_msg">
Mark<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
><br class="gmail_msg">
> Regards,<br class="gmail_msg">
> Rien.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
>><br class="gmail_msg">
>> On 23 Mar 2017, at 08:11, Rien via swift-users <<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>> wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>>> Thanks for that link, used it to track down the worst compile time offender:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> This piece of code:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> public func logAddrInfoIPAddresses(_ infoPtr: UnsafeMutablePointer<addrinfo>) -> String {<br class="gmail_msg">
>>><br class="gmail_msg">
>>> let addrInfoNil: UnsafeMutablePointer<addrinfo>? = nil<br class="gmail_msg">
>>> var count: Int = 0<br class="gmail_msg">
>>> var info: UnsafeMutablePointer<addrinfo> = infoPtr<br class="gmail_msg">
>>> var str: String = ""<br class="gmail_msg">
>>><br class="gmail_msg">
>>> while info != addrInfoNil {<br class="gmail_msg">
>>><br class="gmail_msg">
>>> let (clientIp, service) = sockaddrDescription(info.pointee.ai_addr)<br class="gmail_msg">
>>> str += "No: \(count), HostIp: " + (clientIp ?? "?") + " at port: " + (service ?? "?") + "\n"<br class="gmail_msg">
>>> count += 1<br class="gmail_msg">
>>> info = info.pointee.ai_next<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> return str<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Took 38 seconds to compile.<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Removing the “str” assignment:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> public func logAddrInfoIPAddresses(_ infoPtr: UnsafeMutablePointer<addrinfo>) -> String {<br class="gmail_msg">
>>><br class="gmail_msg">
>>> let addrInfoNil: UnsafeMutablePointer<addrinfo>? = nil<br class="gmail_msg">
>>> var count: Int = 0<br class="gmail_msg">
>>> var info: UnsafeMutablePointer<addrinfo> = infoPtr<br class="gmail_msg">
>>> var str: String = ""<br class="gmail_msg">
>>><br class="gmail_msg">
>>> while info != addrInfoNil {<br class="gmail_msg">
>>><br class="gmail_msg">
>>> let (clientIp, service) = sockaddrDescription(info.pointee.ai_addr)<br class="gmail_msg">
>>> // str += "No: \(count), HostIp: " + (clientIp ?? "?") + " at port: " + (service ?? "?") + "\n"<br class="gmail_msg">
>>> count += 1<br class="gmail_msg">
>>> info = info.pointee.ai_next<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> return str<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Brought it down to 6.6ms<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Obviously I have to rewrite, but it does show how just one line of code can be responsible for approx 80% of the compile time.<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Regards,<br class="gmail_msg">
>>> Rien<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Site: <a href="http://balancingrock.nl/" rel="noreferrer" class="gmail_msg" target="_blank">http://balancingrock.nl</a><br class="gmail_msg">
>>> Blog: <a href="http://swiftrien.blogspot.com/" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftrien.blogspot.com</a><br class="gmail_msg">
>>> Github: <a href="http://github.com/Balancingrock" rel="noreferrer" class="gmail_msg" target="_blank">http://github.com/Balancingrock</a><br class="gmail_msg">
>>> Project: <a href="http://swiftfire.nl/" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftfire.nl</a><br class="gmail_msg">
>>><br class="gmail_msg">
>>><br class="gmail_msg">
>>><br class="gmail_msg">
>>><br class="gmail_msg">
>>><br class="gmail_msg">
>>>> On 22 Mar 2017, at 23:41, Greg Parker via swift-users <<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>> wrote:<br class="gmail_msg">
>>>><br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> On Mar 22, 2017, at 1:03 PM, piotr gorzelany via swift-users <<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>> wrote:<br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> Hi, I hope I reached the right mailing list to ask a question about tooling.<br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> Can somebody from the compiler or Xcode team share some tips on how to improve compilation times of larger Swift projects?<br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> I am an iOS developer and the largest issue my team has with Swift so far is that when the project gets semi large (~30 000 lines) the compilation times start to be high (~10 minutes from clean). This is a MAJOR downside since iOS development oftentimes requires rapid changes to UI or logic. Every person of my team compiles a project at least 10 times a day to test new features or functionalities. When compilation times start to be higher than 10 minutes that gets us to ~1.5h a day of developer time spend just on compiling. Not to mention the focus lost when this is happening.<br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> I know the Swift Evolution list is buzzing with new ideas and features but from my experience the compilation times is a CRITICAL thing to improve in the next Swift release since it cost real money to waste all those developer hours. Just think of all the hours lost on compiling across all Swift devs worldwide and you will get to probably dozens of thousand of dev hours a day.<br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> Is the core compiler team going to address compilation performance in the next release?<br class="gmail_msg">
>>>>><br class="gmail_msg">
>>>>> Maybe there is an existing solution to long compilation times that we don't know of? It would be great if anybody could share.<br class="gmail_msg">
>>>>> I was thinking maybe of dividing the app into multiple frameworks since I think frameworks are compiled only once only on change?<br class="gmail_msg">
>>>><br class="gmail_msg">
>>>> Build time is always a goal. Pretty much every version of Swift has had changes intended to improve compilation time or decrease the frequency of recompilation.<br class="gmail_msg">
>>>><br class="gmail_msg">
>>>> Often a large part of the build time is spent in a handful of places where the compiler's type inference system behaves poorly. You can use the -debug-time-function-bodies and -debug-time-expression-type-checking flags to look for these places. You can often get huge decreases in compile time by adding an explicit type declaration in the right place in order to simplify the type inference engine's job.<br class="gmail_msg">
>>>><br class="gmail_msg">
>>>> Here's a walkthough of one such analysis:<br class="gmail_msg">
>>>> Profiling your Swift compilation times<br class="gmail_msg">
>>>> <a href="http://irace.me/swift-profiling" rel="noreferrer" class="gmail_msg" target="_blank">http://irace.me/swift-profiling</a><br class="gmail_msg">
>>>><br class="gmail_msg">
>>>><br class="gmail_msg">
>>>> --<br class="gmail_msg">
>>>> Greg Parker <a href="mailto:gparker@apple.com" class="gmail_msg" target="_blank">gparker@apple.com</a> Runtime Wrangler<br class="gmail_msg">
>>>><br class="gmail_msg">
>>>><br class="gmail_msg">
>>>> _______________________________________________<br class="gmail_msg">
>>>> swift-users mailing list<br class="gmail_msg">
>>>> <a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
>>>> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg">
>>><br class="gmail_msg">
>>> _______________________________________________<br class="gmail_msg">
>>> swift-users mailing list<br class="gmail_msg">
>>> <a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
>>> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> swift-users mailing list<br class="gmail_msg">
> <a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-users mailing list<br class="gmail_msg">
<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg">
</blockquote></div></div></div>
</div></blockquote></div></div></blockquote></div>
</div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-users mailing list</span><br><span><a href="mailto:swift-users@swift.org">swift-users@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a></span><br></div></blockquote></body></html>