-
Notifications
You must be signed in to change notification settings - Fork 277
Remove unnecessary includes #6060
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
Codecov Report
@@ Coverage Diff @@
## develop #6060 +/- ##
===========================================
+ Coverage 74.17% 74.39% +0.21%
===========================================
Files 1446 1447 +1
Lines 157784 157787 +3
===========================================
+ Hits 117036 117383 +347
+ Misses 40748 40404 -344
Continue to review full report at Codecov.
|
54d6fc8
to
d524f42
Compare
4b186f5
to
4e8601f
Compare
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 am really glad this PR exists and even more glad that wasn't the one to have to write it! I think it is definitely a good thing and should reduce build times. Do you have a rough number for how much time it saves? A few concerns:
- Not sure why the coverage metrics drop. Is it counting forward declarations of
class
es as executable code? - This has a very "breaks all existing PRs" feel to it. What, if anything, are we going to do about that?
- Having gone to all of this trouble, is there anything we could add to the CI / review process to avoid accumulating unnecessary includes and forward declarations? Could we have some kind of 'try to remove #include lines from the PR and see if it still builds' task. If it build develop first and then just tried a loop of removing lines adding headers from the diff, applying and seeing if it still builds?
@@ -8,7 +8,9 @@ Author: Daniel Kroening, [email protected] | |||
|
|||
#include "gcc_message_handler.h" | |||
|
|||
#include <util/unicode.h> | |||
#ifdef _MSC_VER |
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.
This seems to be an idiom. Would it be better to have the ifdef
guard in util/unicode.h
?
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.
Well, it's really just the use of widen
(in most of those files) that's required with Visual Studio only. The header provides more functionality than that, so I don't think that's really an option.
4e8601f
to
70b704b
Compare
I've now added data to the commit message. Builds seem approximately 7% faster.
I have no idea, and the Codecov page doesn't seem to be working at the moment. It seems that quite often with code removal the coverage metrics appear to drop by a tiny fraction, which is weird.
Yes, there may be an impact on several PRs, but I don't expect that many actually: most of the includes simply weren't necessary, and when PRs change implementations only and not header files then most likely they're not impacted at all as an
I do think that we could use more recent versions of include-what-you-use in CI, perhaps 8.0 (which is in Ubuntu 20.04) is quite reasonable already. I've worked with 5.0 (from Ubuntu 18.04), which wasn't too great. The issue mainly is around detecting use of types in templates. I'll create a separate PR to play with this (also need to figure out how long it takes to run). |
70b704b
to
c7a5e26
Compare
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.
Wow - thats a lot of work... 👍
Manual removal of includes based on include-what-you-use's output, filtered for includes that should be removed. The goal is to avoid unnecessary build dependencies, reducing the amount of code that needs to be rebuilt during incremental builds. The build time for fresh rebuilds decreases by about 7% as the following experiment shows: ``` rm -rf build && ccache -C cmake -H. -Bbuild -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld -Wl,--threads" /usr/bin/time -v ninja -C build -j32 ``` Repeated execution for both develop and this branch producing the following data, which less than 1s of variation across multiple runs: develop: ``` Command being timed: "ninja -C build -j32" User time (seconds): 2714.02 System time (seconds): 203.75 Percent of CPU this job got: 2833% Elapsed (wall clock) time (h:mm:ss or m:ss): 1:42.96 ``` this PR: ``` Command being timed: "ninja -C build -j32" User time (seconds): 2507.14 System time (seconds): 189.95 Percent of CPU this job got: 2822% Elapsed (wall clock) time (h:mm:ss or m:ss): 1:35.56 ```
c7a5e26
to
450845d
Compare
Manual removal of includes based on include-what-you-use's output,
filtered for includes that should be removed.
A fully automated use of include-what-you-use doesn't seem feasible at this time for there are a number of false positives of includes that iwyu claims can be safely removed.