-
Notifications
You must be signed in to change notification settings - Fork 26
Only rewrite unit files when outdated #32
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
Only rewrite unit files when outdated #32
Conversation
kastiglione
left a comment
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.
Thanks @xianwen! I have a couple inline comments.
Can you format with clang-format?
index-import.cpp
Outdated
| StringRef inputFile, | ||
| IndexUnitWriter &writer) { | ||
| std::string error; | ||
| auto IsUptodateOpt = writer.isUnitUpToDateForOutputFile(outputFile, inputFile, error); |
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.
In this file/project variables start with a lower case letter.
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.
👍
index-import.cpp
Outdated
|
|
||
| // Check if the unit file is already up to date | ||
| SmallString<256> outputFileFullPath; | ||
| path::append(outputFileFullPath, workingDir, outputFile); |
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.
Is outputFile guaranteed to be relative? I think it can be absolute, I'll have to check.
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.
In our case, we'd want to use the output file path before it gets remapped. For our builds, we don't copy the .o files, but we remap because that's what Xcode uses to lookup records in the index.
Maybe we should check both the path before and after remapping?
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.
@kastiglione, thanks for your comment!
Is
outputFileguaranteed to be relative? I think it can be absolute, I'll have to check.
You're right, it can be absolute. I'll update this part.
For our builds, we don't copy the .o files, but we remap because that's what Xcode uses to lookup records in the index.
We need to use the remapped output file path even though the file wouldn't exist. This outputFileFullPath here is only used by isUnitUpToDate to calculate the Unit file name and therefore determine whether the Unit file is already up to date. Even though the ".o" file doesn't exist, we still need to calculate the Unit file path based on the remapped path. Because as you mentioned, that's what Xcode uses to lookup the Unit file.
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'll rename outputFileFullPath to remappedOutputFilePath to make it clearer.
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.
Got it, thanks. I misinterpreted this logic. Carry on :)
|
I think I have a need for this now. @xianwen do you plan to pick this back up any time soon? |
|
Hi, @kastiglione, happy new year! |
|
Hi, @kastiglione: |
|
@xianwen looks like you'll need to rebase before we can merge. |
|
Thanks for coming back to it. |
# Conflicts: # index-import.cpp
|
@kastiglione, merge conflict resolved :) |
|
I'll try this out on Wednesday. |
|
ok, looking at this today! |
|
I believe this may not help all use cases, particularly for Bazel and Buck. It depends how you integrate with Xcode. Since the timestamp check is based on the For this to work, external build system integrations would have to copy object files from their build directories, into Xcode's build directory (ie DerivedData). What do you think about instead comparing the time stamps of the input unit files, to the outputs. If the input unit file is not newer than an existing file at the output path, then we could skip writing reading->remapping->writing that unit file. This would improve performance for incremental imports. |
|
also very sorry this took me forever to reply too, I love the idea |
The timestamp check is actually just based on the two unit files. The output filename is only used to generate the destination unit filename. The timestamp check is based on the two unit files: I ran this locally and it reduced a 22 second import to a 10 second import. |
|
thanks for clarifying that @brentleyjones. I misinterpreted that API, the name alone sounds like the object file is involved. |
|
Inlining the check, and not creating a |
|
that's great, when you showed the numbers my instinct was that it could be optimized to avoid more work |
|
@DavidGoldman has also talked parallelizing along unit files instead of along indexstores. That would also help the perf. |
|
seems like it's safe to merge this then |
|
@kastiglione thoughts on getting this merged / released? |
|
@segiddins I'm going to review #46 first, I believe it subsumes this change. |
Compare the timestamps of target Unit file and the source Unit file, and skip the Unit remapping and writing if the target Unit file is newer than the source Unit file.
This PR addresses #6