-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
split-off input_context.h
from input.h
; run iwyu to always include input.h
directly
#71141
Conversation
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.
Auto-requesting reviews from non-collaborators: @andrei8l
If the tests pass, this is ready to be merged! |
Clang tidy says
|
input_context.h
from input.h
; run iwyu to always include input.h
directly
input_context.h
from input.h
; run iwyu to always include input.h
directlyinput_context.h
from input.h
; run iwyu to always include input.h
directly
input_context.h
from input.h
; run iwyu to always include input.h
directlyinput_context.h
from input.h
; run iwyu to always include input.h
directly
It should be resolved now. |
b4b3a3e
to
c6698ae
Compare
Before
After
|
I wondered if the includes in that file could repeat, so I did this, and they don't seem to be repeating. % grep -m 1 input_context.h obj/*.inc | wc -l
240 |
split-off "input_context.h" and "input_enums.h" from "input.h" and "input_context.cpp" from "input.cpp" "input_enums.h" contains things that both of the other header files need. Therefor it is included in both of the header files.
…xcessive includes for all files that iwyu reports as (it should add or remove "input.h" or "input_context.h") { add / remove "input.h" and "input_context.h" according to iwyu; remove everything iwyu reports to remove; while (doesn't compile) {add directly what needs to be added}; /* note: thanks to indirect includes, we don't need to include most of what iwyu reports we obey iwyu only for "input.h" and "input_context.h", everything else is a suggestion if it doesn't compile without it */ }
Nooooooooooooooooo Looks so simple. |
Sorry! Ping me in discord when it's passed tests after merge conflict resolution. |
Let's just try including both, what could go wrong? |
test failed, restarting |
trying to restart again
|
widget_test segfaulted on both windows and mac, which is slightly suspicious. If it were just one, I wouldn't care, but those are two wildly different platforms. |
That's my fault. See #71213 |
As promised, I now need to recompile only 38 files, which is over 6x improvement. I love it! |
Summary
None
Purpose of change
Split-off
input_context.h
fromsrc/input.h
to reduce compilation time when changing something in header files.Test how well did I do.
I want to split.src/input.h
in another PRI realize that, since there are unneeded includes, it still can happen, that I recompile more than I need to (when working withinput.h
). But the ratio (of files needing recompilation after the futureinput.h
split vs before) will say what the ideal (lowest) recompilation file count would be if all indirect includes were sorted out.Sorting out these unneeded includes would take too much time. I do only small bites.Describe the solution
run iwyu
lightmap.h
include)input.h
,input.cpp
according to iwyu.#include "input.h"
is directly exposed everywhere. On affected files, remove whatever iwyu reports to remove, but add only the minimum needed for compilation (take advantage of indirect includes).input_context.h
andinput_enums.h
frominput.h
andinput_context.cpp
frominput.cpp
input_enums.h
contains things that both of the other header files need. It is included in both of the header files.input.h
andinput_context.h
, if neither is needed, butinput_enums.h
, include it.Conclusion
Test results bellow.
I set out to reduce re-compilation times for
class input_manager
insrc/input.h
. It is now (indirectly) included in 36 rather than 240 files! So this was a resounding success.I believe, however, that the success comes from splitting the
input.h
file, not from running iwyu alone. As can be seen from not reducing includes for split-offinput_context.h
. Therefore I don't think running iwyu on the whole codebase is worth my time right now. However, it seems that splitting monolithic header files would have a significant impact.Describe alternatives you've considered
Running over the whole codebase. But I want something merge-able. And small bites.
Testing
compiling locally
compiling in this pr
(running) iwyu
input.h
andinput.cpp
input_context.h
andinput_context.cpp
input.h
orinput_context.h
anywhereinput_enums.h
only ifinput.h
orinput_context.h
are already includedAdditional context
Not a draft, so that all tests run.Ready to merge now!