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

Precompiled validation.h #201

Open
mpsijm opened this issue Apr 5, 2022 · 2 comments
Open

Precompiled validation.h #201

mpsijm opened this issue Apr 5, 2022 · 2 comments

Comments

@mpsijm
Copy link
Collaborator

mpsijm commented Apr 5, 2022

From a discussion with @RagnarGrootKoerkamp on Slack.

The compilation of validation.h starts getting slightly slow. Because this file doesn't regularly change, we can reduce the compile time for the validators by using precompiled headers: https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

These precompiled headers can probably be stored in /tmp for each problem. If every problem uses a symlink to a shared validation.h, we might even be able to generate one precompiled header file for all these problems, but will probably be a bit messy.

@mpsijm
Copy link
Collaborator Author

mpsijm commented Feb 27, 2024

I tried this a few days back. On my machine, it reduced the compilation time of a simple input validator (basically only v.read_integer and v.newline) from 1.7–1.9 seconds down to 1.2–1.4 seconds. I don't think this reduction in compile time is large enough to start going through the trouble of implementing this in BAPCtools.

A different idea (thanks to some discussion with more C++-savvy people) could be to rewrite validation.h as a .cpp file, and only include the interfaces of the validators in the header file. We could then try to dynamically link this new validation.cpp to the validators in BAPCtools. DOMjudge doesn't need to know about any of that, since it will just call g++ with all .cpp files combined in one go. But this requires a bit more time to experiment with 😛

@RagnarGrootKoerkamp
Copy link
Owner

Hmm bummer that precompiled headers only make such a small difference. Dynamic linking does sound like a solution that would work but indeed also not very straightforward.

Maybe we could investigate which part of compilation is slow and speed that up somehow. We use templates for integer vs floating point input but instantiating things twice shouldn't be too bad.

Another thing to try could be to just lower the optimization level?

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

No branches or pull requests

2 participants