Repository navigation
build: Use fmt as a header only library everywhere - #36484
adamemerson wants to merge 1 commit into
Conversation
Signed-off-by: Adam C. Emerson <[email protected]>
|
@adamemerson could you elaborate the rationales of this change? i don't like header only libfmt, as it gets more source code pulled into the header, which could have been compiled into the library for saving the compile time. this is also one of the reasons why i packaged fmt for fedora and EPEL8. |
|
@tchaikov It gets around issues I've found (and I think others have, too, considering they were doing it in a few places) with clashing/missing symbols in libraries. Also according to @wjwithagen it helps portability to BSD. |
My general objection was largely with embedding yet another library in het ceph tree, and then have it build in yet again a way that requires fixing it if the system is too Linux specific. And my specific peeve was more about this change I have for Nautilus: I'll run this full PR in jenkins |
|
@tchaikov It could also give the compiler more opportunities for optimization as each translation unit gets to see the full source of the libformat function's it's calling into. |
where did you get the "libraries"? are they from fedora repo? and what are exactly the issues ? what are the clashing/missing symbols? if you get them from fedora, could you file a bug on bugzilla and point me to it?
i'd like to understand more details on this.
i'd like to see the profiling results when it comes to performance. |
this is not related to this chagne. nautilus uses the libfmt submodule in seastar, and in master, seastar removed libfmt, so we are using our own fmt submodule. |
wjwithagen
left a comment
There was a problem hiding this comment.
This has passed Jenkins compile and test on FreeBSD/Clang
My inital reaction was that I liked this change. Perpendicular to that is the The point of compilation is that sense is a lesser argument for me: The compiler does its work anyways, the code might even get better by having a larger optimsing surface, versus sinking the scarce time I have in something that is also available as a package. |
this change has nothing to do with using packaged standard port or not. it's all about using header only library. currently in master, the libfmt installed in system is preferred over the one included as submodule. and again, this is not related to this change. i'd really want to focus on this change instead of starting using this PR as a venue of chitchat.
please note, Seastar does not support FreeBSD yet. i am not sure what you mean by "
i am not sure what problem you ran into so you need to look into the build process of the lib?
i think i've explained my opinion regarding the possible optimisations. without the numbers, i can hardly understand why it matters.
|
I'll then leave it at that. |
| // this seems safe to use, at least for now--arguably, we should | ||
| // prefer header-only fmt, in general | ||
| #undef FMT_HEADER_ONLY | ||
| #define FMT_HEADER_ONLY 1 |
There was a problem hiding this comment.
the reason i requested this PR is because we were repeating this stuff in each translation unit that includes fmt. whether or not we decide to go with header-only, this decision belongs in cmake so it can be applied consistently across the project
There was a problem hiding this comment.
@cbodley so instead of hardwiring the cmake to -DFMT_HEADER_ONLY.
- i need to understand what does
FMT_HEADER_ONLYoffer to us? i asked for details, but no replies so far. - if we need it for some use cases.
- we should have an option for it.
fmt::fmtdoes not only carry the library linkage, it also containsINTERFACE_INCLUDE_DIRECTORIES. instead of removing all occurrences offmt::fmt, we could have afmt::headerlibrary instead which exposes-DFMT_HEADER_ONLYand theINTERFACE_INCLUDE_DIRECTORIES.
There was a problem hiding this comment.
i think we should choose one and stick with it. if we provide both options, we're likely to end up with targets whose dependency chains include both. if there aren't good arguments for header-only, lets stick with static linkage
|
In general, I expect header-only fmt to have better optimization. Not only don't we have those numbers, we have no numbers showing that doing so slows compilation significantly. |
|
Getting some numbers, I wrote a simple benchmark: And I compiled it both as header only and linked with a library: The header only version seems to be notably faster than the linked version |
|
Thanks, @adamemerson. That does seem significant. |
|
thanks @adamemerson, that looks like a good motivation for header-only! |
|
Please note that when compiling with clang, I do not see this kind of speed up |
|
It seems to me the header-style is enabling a type of concrete optimization generally favored in modern c++. We've shown it's advantage with a real compiler. The objections are appealing to affects from object size which are not quantified, and on compilation times, which are also not quantified (but likely negligible). |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
this closed without any resolution, and a bunch of random files are still adding we're now seeing linker errors in we really need to pick one or the other and be consistent about it. given @adamemerson's benchmark on gcc, enabling currently we get the worst of both worlds: we're already paying for header-only compile times, and we're already linking both versions into cephfs, rbd, and rgw |
|
in the meantime, i've opened #50479 to remove all of the #defines |
As suggested in a review elsewhere.