<div dir="ltr">Thank you Jordan! This is a great starting off point.<div><br></div><div>I&#39;m thinking about proposing a &quot;strict import&quot; mode in swift: A compile flag that when turned on would require you to explicitly import any file that contained a dependency you needed (like in objective-c).</div><div><br></div><div>I&#39;m going to spend more time looking over the docs and the output logs to see if this would be a feasible. If anyone has opinions or insights into this I would love to hear from you. </div><div><br></div><div>Sam</div><div><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 5, 2016 at 9:08 PM, Jordan Rose <span dir="ltr">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi, Sam. I don&#39;t think we currently have a good answer for this built into xcodebuild or xctool, and it&#39;s a reasonable idea. (Ideally all builds would be fast enough that it wouldn&#39;t matter! That&#39;s obviously not where we are.)</div><div><br></div><div>Since &#39;-debug-time-function-bodies&#39; is now public knowledge, I&#39;ll share another one of our debugging flags, &#39;-driver-show-incremental&#39;. You can add this to your &quot;Other Swift Flags&quot;. The output isn&#39;t very detailed, though:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Tree.swift (initial)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing AdventureScene.swift (initial)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing AdventureScene.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing AppDelegate.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing ChaseArtificialIntelligence.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Character.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing SpawnArtificialIntelligence.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Goblin.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Cave.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing AdventureSceneOSXEvents.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing HeroCharacter.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing EnemyCharacter.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Boss.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing SharedAssetManagement.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Warrior.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Archer.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing Player.swift because of dependencies discovered later</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(76,47,45);background-color:rgb(223,219,196)"><span>Queuing ArtificialIntelligence.swift because of dependencies discovered later</span></div></div><div><span><br></span></div><div><span>In this case, I took a version of the Adventure sample project and modified &quot;Tree.swift&quot;; that triggered recompilation of several other files. Unfortunately this view doesn&#39;t tell you how they&#39;re related, only which ones are actually getting rebuilt.</span></div><div><span><br></span></div><div>The next step (and moving into the territory of &quot;working on Swift&quot; rather than just &quot;trying to figure out why it&#39;s repeating work&quot;) would be to look at the &quot;swiftdeps&quot; files stored in your DerivedData folder. These are currently just YAML files describing what Swift thinks the file depends on, as well as what will trigger rebuilding of other files. This is intended to be a conservative estimate, since <i>not</i> recompiling something would result in an invalid binary. (Unfortunately I say &quot;intended&quot; because there are known bugs; fortunately, archive builds are always clean builds anyway.)</div><div><br></div><div>There&#39;s a document in the Swift repo describing the logic behind Swift&#39;s dependency analysis: <a href="https://github.com/apple/swift/blob/master/docs/DependencyAnalysis.rst" target="_blank">https://github.com/apple/swift/blob/master/docs/DependencyAnalysis.rst</a>. The one thing that&#39;s <i>not</i> in there is the notion of changes that don&#39;t affect other files at all. This is accomplished by computing a hash of all the tokens that <i>could</i> affect other files, and seeing if that hash has changed.</div><div><br></div><div>We definitely have room for improvement here.</div><div><br></div><div>Jordan</div><div><br></div><br><div><blockquote type="cite"><div><div class="h5"><div>On Mar 31, 2016, at 11:24 , Samantha John via swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt; wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div style="font-size:12.8px">I have a large project (308 swift files, 441 objective c, 66k lines of code) where incremental builds can be extremely slow. I&#39;m trying to do some profiling to figure out what type of things cause large scale recompiles. The problem is that I can&#39;t find a good way of telling which files get recompiled on an incremental build and which do not. It seems like files that are not recompiled still get listed in xcode, but the compiler just passes over them really fast. </div><div style="font-size:12.8px"><span style="font-size:12.8px"><br></span></div><div style="font-size:12.8px"><span style="font-size:12.8px">Does anyone know if xctool or xcodebuild has this type of functionality? Or is there some other way to get this info?</span><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thank you,<br>Sam</div>
</div></div></div>
_______________________________________________<br>swift-dev mailing list<br><a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br></div></blockquote></div><br></div></blockquote></div><br></div></div>