<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.&nbsp;</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 &lt;<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>&gt; 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 -&gt; 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 &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; 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 &lt;<a href="mailto:piotr.gorzelany@gmail.com" class="">piotr.gorzelany@gmail.com</a>&gt; 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&nbsp;<a href="https://swift.org/download/#snapshots" class="">https://swift.org/download/#snapshots</a>&nbsp;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 &lt;<a href="mailto:mark.lacey@apple.com" class="">mark.lacey@apple.com</a>&gt; 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 &lt;<a href="mailto:piotr.gorzelany@gmail.com" class="gmail_msg" target="_blank">piotr.gorzelany@gmail.com</a>&gt; 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&nbsp;<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&nbsp;</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">&lt;unknown&gt;: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&nbsp;użytkownik Mark Lacey via swift-users &lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt; 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">
&gt; On Mar 23, 2017, at 12:32 AM, Rien via swift-users &lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt; wrote:<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;&gt; On 23 Mar 2017, at 08:27, David Hart &lt;<a href="mailto:david@hartbit.com" class="gmail_msg" target="_blank">david@hartbit.com</a>&gt; wrote:<br class="gmail_msg">
&gt;&gt;<br class="gmail_msg">
&gt;&gt; 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">
&gt;&gt;<br class="gmail_msg">
&gt;&gt; str += "No: \(count), HostIp: \(clientIp ?? "?") at port: \(service ?? "?")\n”<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; Concatenation may cause the increase, but this solved it too:<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; let (clientIpOrNil, serviceOrNil) = sockaddrDescription(info.pointee.ai_addr)<br class="gmail_msg">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; let clientIp = clientIpOrNil ?? "?"<br class="gmail_msg">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; let service = serviceOrNil ?? "?"<br class="gmail_msg">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; 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">
&nbsp; -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 ‘&lt;invalid loc&gt;’ 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">
&gt;<br class="gmail_msg">
&gt; Regards,<br class="gmail_msg">
&gt; Rien.<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;&gt;<br class="gmail_msg">
&gt;&gt; On 23 Mar 2017, at 08:11, Rien via swift-users &lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt; wrote:<br class="gmail_msg">
&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Thanks for that link, used it to track down the worst compile time offender:<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; This piece of code:<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; public func logAddrInfoIPAddresses(_ infoPtr: UnsafeMutablePointer&lt;addrinfo&gt;) -&gt; String {<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;let addrInfoNil: UnsafeMutablePointer&lt;addrinfo&gt;? = nil<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;var count: Int = 0<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;var info: UnsafeMutablePointer&lt;addrinfo&gt; = infoPtr<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;var str: String = ""<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;while info != addrInfoNil {<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;let (clientIp, service) = sockaddrDescription(info.pointee.ai_addr)<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;str += "No: \(count), HostIp: " + (clientIp ?? "?") + " at port: " + (service ?? "?") + "\n"<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;count += 1<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;info = info.pointee.ai_next<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;}<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;return str<br class="gmail_msg">
&gt;&gt;&gt; }<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Took 38 seconds to compile.<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Removing the “str” assignment:<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; public func logAddrInfoIPAddresses(_ infoPtr: UnsafeMutablePointer&lt;addrinfo&gt;) -&gt; String {<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;let addrInfoNil: UnsafeMutablePointer&lt;addrinfo&gt;? = nil<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;var count: Int = 0<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;var info: UnsafeMutablePointer&lt;addrinfo&gt; = infoPtr<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;var str: String = ""<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;while info != addrInfoNil {<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;let (clientIp, service) = sockaddrDescription(info.pointee.ai_addr)<br class="gmail_msg">
&gt;&gt;&gt; //&nbsp; &nbsp; &nbsp; &nbsp; str += "No: \(count), HostIp: " + (clientIp ?? "?") + " at port: " + (service ?? "?") + "\n"<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;count += 1<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;info = info.pointee.ai_next<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;}<br class="gmail_msg">
&gt;&gt;&gt;&nbsp; &nbsp;return str<br class="gmail_msg">
&gt;&gt;&gt; }<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Brought it down to 6.6ms<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; 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">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Regards,<br class="gmail_msg">
&gt;&gt;&gt; Rien<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Site: <a href="http://balancingrock.nl/" rel="noreferrer" class="gmail_msg" target="_blank">http://balancingrock.nl</a><br class="gmail_msg">
&gt;&gt;&gt; Blog: <a href="http://swiftrien.blogspot.com/" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftrien.blogspot.com</a><br class="gmail_msg">
&gt;&gt;&gt; Github: <a href="http://github.com/Balancingrock" rel="noreferrer" class="gmail_msg" target="_blank">http://github.com/Balancingrock</a><br class="gmail_msg">
&gt;&gt;&gt; Project: <a href="http://swiftfire.nl/" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftfire.nl</a><br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt; On 22 Mar 2017, at 23:41, Greg Parker via swift-users &lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt; wrote:<br class="gmail_msg">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; On Mar 22, 2017, at 1:03 PM, piotr gorzelany via swift-users &lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt; wrote:<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; Hi, I hope I reached the right mailing list to ask a question about tooling.<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; Is the core compiler team going to address compilation performance in the next release?<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt; 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">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt; Here's a walkthough of one such analysis:<br class="gmail_msg">
&gt;&gt;&gt;&gt; Profiling your Swift compilation times<br class="gmail_msg">
&gt;&gt;&gt;&gt; <a href="http://irace.me/swift-profiling" rel="noreferrer" class="gmail_msg" target="_blank">http://irace.me/swift-profiling</a><br class="gmail_msg">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt; --<br class="gmail_msg">
&gt;&gt;&gt;&gt; Greg Parker&nbsp; &nbsp; &nbsp;<a href="mailto:gparker@apple.com" class="gmail_msg" target="_blank">gparker@apple.com</a>&nbsp; &nbsp; &nbsp;Runtime Wrangler<br class="gmail_msg">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;&gt; _______________________________________________<br class="gmail_msg">
&gt;&gt;&gt;&gt; swift-users mailing list<br class="gmail_msg">
&gt;&gt;&gt;&gt; <a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
&gt;&gt;&gt;&gt; <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">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; _______________________________________________<br class="gmail_msg">
&gt;&gt;&gt; swift-users mailing list<br class="gmail_msg">
&gt;&gt;&gt; <a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
&gt;&gt;&gt; <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">
&gt;<br class="gmail_msg">
&gt; _______________________________________________<br class="gmail_msg">
&gt; swift-users mailing list<br class="gmail_msg">
&gt; <a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg">
&gt; <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>