-
Notifications
You must be signed in to change notification settings - Fork 208
File Hashing for Incremental Builds #1923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please smoke test Broken tree state because swiftlang/swift#82153 had not landed yet. |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just had a few minor comments
@@ -44,6 +45,14 @@ extension Driver.ErrorDiagnostics: CustomStringConvertible { | |||
} | |||
} | |||
|
|||
public struct FileMetadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be marked @_spi(Testing)
? I don't think it needs to be API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this needs to be exposed in the DriverExecutor protocol, so I think it needs to be public
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I forgot this showed up in that API. We may need a strategy to stage in the changes to the DriverExecutor protocol so they don't break https://github.com/swiftlang/swift-build, or make synchronized changes to the repos. Maybe you could keep the old execute
requirements around temporarily for default implementations of the new ones to call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realise there was an API here exposed to swift-build.
I've added a commit that restores the original methods to DriverExecutor
, with an extension that gives default implementations of the new methods, and added in definitions with fatalError()
if these legacy methods are called on the implementations defined in swift-driver itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this to move to a file in SwiftDriver/Utilities/
. Remember to update the CMakeFile if you add a new file.
I had to fix the added tests - the old logic stopped working after rebasing this branch past 7c709c5 Honestly, I'm not sure my tests are the right approach, however the majority of tests in IncrementalCompilationTests are failing for me locally on main, so I don't want to copy those approaches directly. Maybe I am doing something wrong locally? Most other tests are passing for me, though. |
What kinds of failures are you seeing? I recommend building and running tests against most-recent |
I'll try with a snapshot. |
I'm still getting lots of failures in IncrementalCompilationTests on current main (8c130e3):
Although I see strictly speaking there are '0 unexpected' failures, but I'm not sure how or why these are defined as being 'expected'. |
@owenv Is there anything I'm missing to unblock this PR? |
No, sorry, I lost track of this. Let's kick off the CI tests and see how those results look. @swift-ci test |
@swift-ci test Windows |
@swift-ci test |
@swift-ci test Windows platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some incremental state reporter messages need to be adjusted, or report a different message. Like reportExplicitDependencyOutOfDate
says older than input file
.
The logic changes are good to me.
@@ -44,6 +45,14 @@ extension Driver.ErrorDiagnostics: CustomStringConvertible { | |||
} | |||
} | |||
|
|||
public struct FileMetadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer this to move to a file in SwiftDriver/Utilities/
. Remember to update the CMakeFile if you add a new file.
This message is still accurate, alas. I haven't added hash logic here, and I don't think this PR can help in this case without adding a lot more work. I may have understood this wrong, but I think in this case we are comparing swiftmodule files that are dependencies or transitive dependencies of a file under compilation in the current module ("Module A"). And if the timestamp of a dependency-of-a-dependency ("Module C") is newer than that of the dependency ("Module B"), this is taken as meaning we have to recompile Module B before we can proceed. Of course, if the hash of Module C is unchanged, we could skip it. However, I don't think there's an easy place to store the hash data for these (and we are not storing timestamps for them). Furthermore, I think you would want to compare the hash of Module C with that recorded during the compilation of Module B, not during the previous compilation of the current module (Module A). I also think this logic is invoked during WMO compilation, and not just during Incremental mode. Does this sound right? |
Ah, this is the report for module dependency only and I guess we are not extending hash check to module dependencies yet (and that is not computed in swift driver, but in scanner). The remark for incremental build only says Thanks for looking and address the feedback. I think the newly added |
Whoops, fixed. Thanks for your review. |
Can someone with the power run the required swift-ci checks again, please? |
@swift-ci test |
@swift-ci test Windows platform |
@swift-ci test Windows platform |
Rebased past b0a01d3 to fix merge conflicts, now we need to run the CI tests again… |
@swift-ci test |
@swift-ci test Windows platform |
@@ -536,7 +536,7 @@ final class ExplicitModuleBuildTests: XCTestCase { | |||
main.nativePathString(escaped: true)] + sdkArgumentsForTesting | |||
var driver = try Driver(args: args) | |||
let _ = try driver.planBuild() | |||
let dependencyGraph = try XCTUnwrap(driver.explicitDependencyBuildPlanner?.dependencyGraph) | |||
let dependencyGraph = try XCTUnwrap(driver.intermoduleDependencyGraph) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
I can't see the merge button - does a committer need to merge on my behalf? |
This PR:
--enable-incremental-file-hashing
, and a corresponding--disable-incremental-file-hashing
, defaulting to disabledRFC discussion here: https://forums.swift.org/t/rfc-file-hashes-for-swift-incremental-compilation/