Created by: xianwen
TL;DR;
Update SwiftCompile
to support SupportsInputBasedRuleKey
interface, so that we could avoid unnecessary Swift module recompilation if its input Swift modules' .swiftmodule
artifacts weren't changed.
Details
Suppose Swift moduleA depends on Swift moduleB.
The current behavior of Buck is that whenever you touch the source code of moduleB, moduleA will always be rebuilt, even if you didn't change the public interface of moduleB. This has a heavy cost and unnecessarily slows incremental builds down a lot.
This PR avoids the recompilation of moduleA in this given example by evaluating the md5sum of moduleB.swiftmodule
, which is a binary superset of moduleB's all public interfaces. As long as a Swift module's .swiftmodule
remains unchanged after its compilation, it is safe to not recompile its dependents.
I verified this PR is working in an Airbnb demo project Buck Sample here: https://github.com/airbnb/BuckSample/pull/132
By applying this PR internally at the Airbnb's fork of Buck here, https://github.com/airbnb/buck/pull/23/, our p50 of local iOS build time has reduced more than 30% in the last 2 weeks.