common: add missing include, reduce header dependencies#60253
common: add missing include, reduce header dependencies#60253
Conversation
2d92d81 to
860e502
Compare
|
"stderr: fatal: unable to access 'https://github.com/ceph/ceph.git/': Could not resolve host: github.com" sigh ... |
d0a3fff to
ee138e7
Compare
|
Added a patch for |
ee138e7 to
38fd16c
Compare
38fd16c to
eeaf577
Compare
src/common/buffer.cc
Outdated
| #include "include/spinlock.h" | ||
| #include "include/scope_guard.h" | ||
|
|
||
| #include <iostream> |
|
Just to make sure: crimson compiled OK after your changes? |
I don't know what crimson is, and I didn't build all combinations of all Ceph features - I struggled a lot until I could build Ceph at all. |
|
Google's cppguide forbids forward declarations.
I do not agree with that, but since Ceph mandates the use of Google's cppguide, I should follow it. What shall I do? Remove forward declarations? (From this PR and submit PRs to remove existing forward declarations) |
eeaf577 to
7567e11
Compare
I do not think we are following this. I, for one, certainly use fwd declarations. |
I'll post a PR for CodingStyle explicitly allowing forward declarations. Sounds like it may get accepted. IMHO forward declarations reduce the pain of C++'s unbearable header bloat. (I wish we could use C++20 modules. They solve this issue once and for all. But modules cause headaches of its own; unfortunately it's an extremely badly designed language feature.) |
4c6e294 to
847cfef
Compare
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
This header uses `std::string`, but not `std::system_error`. Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
And add a few missing includes. Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
Signed-off-by: Max Kellermann <[email protected]>
847cfef to
df422f9
Compare
|
@ronen-fr all (bogus) CI failures are now fixed, and since Crimson is part of the CI, I suppose it's fine. |
Good work! It's great to see that one merged so quickly |
| #include <cstdint> | ||
|
|
||
| #include "common/perf_histogram.h" | ||
| #include "include/utime.h" |
There was a problem hiding this comment.
That's the final issue I have with this commit set:
utime_t is an integral part of the interface of the perf-counters.
(and - a random sampling of files that include this header show that almost all of those files make use of 'utime_t').
I am not sure it makes sense to forward-declare it here.
There was a problem hiding this comment.
The header defines dozens of functions, but only 3 of those have utime_t in their signature. These 3 methods are just one special case, but not what I'd call "integral part".
Look at the heavy dependencies of utime.h - it pulls in the whole encoding/denc library with all its dependencies (= all C++ containers plus a bunch of Boost containers, the buffer library), SubProcess.h (iostreams + sstream), strtol.h (charconv!).
utime.h is one of those headers that gets included everywhere by everybody, implicitly. Yes, it is used often, but those sources that really need it should include it explicitly. Forward-declaring it from perf_counters.h helps identifying those sources that mistakenly forgot to include utime.h. That improves code correctness.
That code correctness is not just a theoretical principle; it helps finding bugs early that may occur in different build-time configurations. Ceph has lots of build failures when certain features are disabled - look at #60547 for just one of many examples (I have a dozen similar patches not-yet-submitted on my stgit stack).
One idea I'm currently exploring is making more features compile-time optional, for example ceph_assert() (see #60160); that reduces executable size (improved CPU cache hit rate, better branch prediction) and reduces runtime overhead (by omitting evaluations that are only useful in debug builds). The perf_counters feature is one such thing that could be made optional, to be disabled when performance is utterly important. Once perf_counters are optional, those missing utime.h includes will become build failures, and more build failures may sneak in at any time. Therefore, reducing header dependencies has practical advantages - it makes the build more robust.
There was a problem hiding this comment.
for example
ceph_assert()(see #60160);
Not related to the current PR, but still - we now use ceph_assert() with the knowledge that it will
be active in release builds. It would be a bad idea to "disappear" it (using Catch-22 phrasing)
There was a problem hiding this comment.
OK - that's convincing enough
(although I don't buy in making the per_counters optional. I think there are strong reasons not to do that)
There was a problem hiding this comment.
I saw how much performance can be gained by disabling assertions and (debug-)logging, and that's why we will disable both at compile time, and maybe more. If the code is correct, that's easier. Thanks for supporting my fight for better and more correct code!
Ceph build times are pretty bad, even for a C++ project; part of that is because Ceph has too much header+template bloat. I have started reducing header dependencies, but found many build failures because
#includelines were missing everywhere. This PR starts adding them, to prepare for the actual cleanup.Checklist