-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
bazel: Add pre-compiled clang header poc #13788
bazel: Add pre-compiled clang header poc #13788
Conversation
Do we have any data re: how this improve the overall build performance locally? |
I'd be willing to do some tests around that. @keith is this in a good enough state for perf testing yet? Is this clang-only, or will it work with gcc? |
It would definitely be great if someone more familiar with these issues could test some configurations and see how it looks. I could look into making it work with gcc as well, off the top of my head I'm not sure how much work that would be, but it might be best if we could prove it out with clang first assuming the performance characteristics would be the same? I think this is ready for some testing, but definitely still in the alpha state since I haven't tried many configurations (and CI makes it look like there's an issue on non clang or maybe non macOS builds already). |
I tried this and get error
Also, I had to make the visibility of the test pch public to fix an bazel error in quic. |
What target were you building? And what platform? |
linux: |
I'll try to repro in docker |
Pushed fixes for both of those, sorry for the trouble |
This version builds, but everytime I rebuild (with no changes since the previous build), it rebuilds v8, which takes forever, and makes any timing measurements useless. |
Interesting. Based on bazel query I see no connections between that target and the pch targets. Would you expect their to be one? Does this query return anything in your configuration?
|
I removed |
|
Hrm. I wouldn't expect this to cause that then, but you don't see it without it? |
Yep, I double-checked that going back to master it does nothing on rebuild when nothing has changed. No idea why this change causes v8 to rebuild. |
Thanks for testing. I'll debug early next week
|
So I actually see this without this change, but only when sandboxing is disabled. It seems like the issue is when the build artifacts are left around the output is not hermetic. Specifically for example some files like the @@ -7598,7 +7598,7 @@
inputs {
path: "external/com_googlesource_chromium_v8/wee8/out/wee8/.ninja_deps"
digest {
- hash: "a378893aa515feadcf3ce240040f076e17778f607507fd348a9e94d9093d8960"
+ hash: "6c83d26de24732e0cf89c8c882968f4d65feae9ccd5a91ea22d5db2110c3597f"
size_bytes: 1199916
hash_function_name: "SHA-256"
}
@@ -7606,8 +7606,8 @@
inputs {
path: "external/com_googlesource_chromium_v8/wee8/out/wee8/.ninja_log"
digest {
- hash: "4f54dc5aa0dbb71d836b63a9a430ccca3fcdbc7b9123c6d25c2dde5c06d8fdd1"
- size_bytes: 119886
+ hash: "6c7a83ad170f7331a3c3b149b94ede9aacce2cc1dd0f45f2f2cf9d5f54caaa84"
+ size_bytes: 119928
hash_function_name: "SHA-256"
}
} I'll debug this some more. |
Fix for that is here: #13866 |
@ggreenway mind taking a pass at this again? |
I got some results. To test, I first did a full build, then timed how long it took to build PCH took 7:17 to rebuild. So that's a pretty good gain, considering we haven't even added a lot of stuff to the PCH yet. I think the next step is to add some of the protobuf generated headers to the PCH and see if we can get more gains. |
I suppose one more sanity test is to benchmark without-pch, and without sandboxing, to make sure the improvement isn't due to the sandboxing. Do you know a bazel invocation that will do that off the top of your head? |
You can delete line 51 from the .bazelrc from this change to do that. Or copy the spawn strategy from line 50 and an exclude this new config from the command line |
7:53 to rebuild with |
I still think the biggest bang for the buck we will get is the mocks. Have you tried that yet? |
I'm trying, but bazel is unhappy. I tried adding a mock header to the test pch, and to do that, I had to add the target as a dependency (to access the header), but that makes a cycle in the dependencies. @keith any idea how to resolve?
|
My assumption (without being at my computer) is that the mocks use the bazel macro where I implicitly added the pch as a dep, leading to that cycle. There's some UX question here of how we want to deal with that. For a quick workaround (assuming the dependency tree doesn't go deeper) you could exclude the pch in the macro if the name matches the target you're trying to add. I can work on a long term improvement here though. |
I won't have time to fix this up until next week |
Sorry I didn't get to this this week, I'm out for the holiday next week but it's on my list for afterwards. In the meantime if anyone has ideas on the UX question above they'd be appreciated! |
Still not sure entirely on what we should do for this case, but for now I've made all mocks not depend on the pch, so the pch can therefore depend on all / any mocks. I've added the one from your previous cycle error as an initial dependency for testing, lmk what you think! |
b19ce01
to
4a5bf82
Compare
looks like this is failing DCO? /wait |
ugh, I edited that in the github UI, thanks fixed |
5325937
to
e30b147
Compare
This adds a custom rule for producing clang pre-compiled headers. The hope is that by using these we reduce significant duplication in some larger headers that get recompiled by many dependees. This works by fetching the normal C++ configuration from bazel's crosstool, and adding custom flags to compile our pch in the right mode. This currently has a few limitations / rough edges: 1. It only supports clang 2. There's no way with the CcInfo provider to propagate compiler flags up the dependency tree. Because of this we instead add the required `-include-pch` flag to all macros. 3. Pch files are timestamp sensitive, this means if you add a include to the pch, build, then remove it and rebuild, it will currently fail. LLVM master has a flag to ignore this timestamp, but it isn't currently available in the release version of Xcode on macOS. 4. The logic to disable isn't implemented yet. Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Removing this from headers stopped it from being built, but it worked locally since sandboxing was disabled. Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
This was overly aggressive. `testonly` being set should be good enough Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
e30b147
to
93555c9
Compare
/retest |
Retrying Azure Pipelines: |
@lizan when you get a chance can you re-review? |
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 let's ship and iterate.
Thanks everyone! |
* bazel: Add pre-compiled clang header poc This adds a custom rule for producing clang pre-compiled headers. The hope is that by using these we reduce significant duplication in some larger headers that get recompiled by many dependees. This works by fetching the normal C++ configuration from bazel's crosstool, and adding custom flags to compile our pch in the right mode. This currently has a few limitations / rough edges: 1. It only supports clang 2. There's no way with the CcInfo provider to propagate compiler flags up the dependency tree. Because of this we instead add the required `-include-pch` flag to all macros. 3. Pch files are timestamp sensitive, this means if you add a include to the pch, build, then remove it and rebuild, it will currently fail. LLVM master has a flag to ignore this timestamp, but it isn't currently available in the release version of Xcode on macOS. 4. The logic to disable isn't implemented yet. Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
This adds a custom rule for producing clang pre-compiled headers. The
hope is that by using these we reduce significant duplication in some
larger headers that get recompiled by many dependees.
This works by fetching the normal C++ configuration from bazel's
crosstool, and adding custom flags to compile our pch in the right mode.
This currently has a few limitations / rough edges:
up the dependency tree. Because of this we instead add the required
-include-pch
flag to all macros.the pch, build, then remove it and rebuild, it will currently fail.
LLVM master has a flag to ignore this timestamp, but it isn't
currently available in the release version of Xcode on macOS.
Signed-off-by: Keith Smiley keithbsmiley@gmail.com