Skip to content
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

Improve compilation times on Windows #172

Merged

Conversation

vittorioromeo
Copy link
Contributor

Thank you for the very useful library!

Few improvements:

  • Better header hygiene
  • Isolate windows.h to .cpp whenever possible
  • Use WIN32_LEAN_AND_MEAN
  • Remove unused headers

Tested on Windows with

cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 
  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-ftime-trace -Wall -Wextra -Wpedantic 
  -Wno-ignored-attributes" -DCMAKE_COLOR_DIAGNOSTICS=1 -DCPPTRACE_BUILD_TESTING=1 
  -DCPPTRACE_BUILD_BENCHMARKING=0

There's a lot more that can be improved if you are interested.

Copy link
Owner

@jeremy-rifkin jeremy-rifkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to contribute! Header hygiene is always appreciated, as is tidying up includes. I definitely agree there's a lot more that can be improved 😄 I have a small handful of comments, mostly straightforward

struct object_frame;
struct safe_object_frame;

using frame_ptr = std::uintptr_t;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we #include <cpptrace/cpptrace.hpp> here instead. My main concern is this falling out of line with the definition there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I measured this change making a noticeable difference via ClangBuildAnalyzer. If there is a mismatch between these forward declarations and cpptrace.hpp, compilation will fail with an hard error (i.e. you won't silently introduce any UB).

Given that, would you reconsider?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that’s reasonable, I appreciate you measuring. I had also been thinking of splitting ip the cpptrace.hpp file so one option in the future might be to have a more minimal header providing the type.

src/cpptrace.cpp Show resolved Hide resolved
src/from_current.cpp Show resolved Hide resolved
src/platform/dbghelp_syminit_manager.hpp Show resolved Hide resolved
src/unwind/unwind.hpp Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@
#include <link.h> // needed for dladdr1's link_map info
#endif
#elif IS_WINDOWS
#define WIN32_LEAN_AND_MEAN
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it'd be worthwhile to just do target_compile_definitions(... PRIVATE WIN32_LEAN_AND_MEAN)?

src/utils/common.hpp Show resolved Hide resolved
src/utils/microfmt.cpp Outdated Show resolved Hide resolved
src/utils/utils.cpp Outdated Show resolved Hide resolved
src/utils/utils.hpp Show resolved Hide resolved
@jeremy-rifkin
Copy link
Owner

Looks like some CI is failing, unfortunately one of the hard things about developing this library is how much code can't be tested on a single platform. Happy to help however I can.

@vittorioromeo
Copy link
Contributor Author

vittorioromeo commented Sep 15, 2024

@jeremy-rifkin: could CI be retriggered, please?

@vittorioromeo
Copy link
Contributor Author

@jeremy-rifkin: and again please :)

If possible, could you make CI not require approval until this PR is merged? I need to iterate a bit to figure out what includes are missing on various platforms.

@jeremy-rifkin
Copy link
Owner

I’ll look to see if I can set it to not need approval, sorry for the iteration hassle

@vittorioromeo
Copy link
Contributor Author

I’ll look to see if I can set it to not need approval, sorry for the iteration hassle

Seems like approval is still required :(

@jeremy-rifkin
Copy link
Owner

Sorry for the hassle here, I think the setting is correct now. I can take a stab at getting things correct later too.

@jeremy-rifkin jeremy-rifkin changed the base branch from main to dev October 2, 2024 15:52
Copy link
Owner

@jeremy-rifkin jeremy-rifkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again so much for the contribution, taking the time to do this, and putting up with all the iteration pain. I went ahead and added a couple commits to get remaining stuff working. Everything here LGTM, thanks again!

@jeremy-rifkin jeremy-rifkin merged commit 0ddbbf4 into jeremy-rifkin:dev Oct 2, 2024
156 of 157 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants