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

Remove unnecessary functions from headers #71

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

stephenswat
Copy link
Member

I've noticed that actsvg has most of its code in header files. While this is well managed using the static and inline keywords, it still leads to some rather undesirable effects. For example, I ran into an issue where a detray CUDA file was crashing because of some code in actsvg, that that kind of very deep dependency is not very maintainable. For that reason, I suggest we move as much of the code from actsvg into sources files. This will help reduce compilation times and memory usage.

@stephenswat
Copy link
Member Author

stephenswat commented May 31, 2024

Note that this PR doesn't contain any actual code changes, because reviewing a 7000 line diff with actual code changes would be cruel. Also, I couldn't figure out the correct recipe to format code. Do you use clang-format? If so, which version? Also, the includes from the header files could possibly be pruned.

@stephenswat
Copy link
Member Author

I feel obliged to mention that there is one downside to this: is makes the ABI more fragile. Because Actsvg has a lot of STL types on its API boundary, turning that API boundary into an ABI boundary will make the code a bit more fragile to compiler changes. However, I don't think this outweighs the potential benefits.

Copy link
Member

@krasznaa krasznaa left a comment

Choose a reason for hiding this comment

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

I am super on board with this development. I really dislike myself as well how many of the Acts projects put everything into header files. Generally I just would like to avoid using extern in the code. (And rather use static variables defined inside structs.)

But other than that, I'm very much on the side of this PR.

core/CMakeLists.txt Outdated Show resolved Hide resolved
core/include/actsvg/core/defs.hpp Outdated Show resolved Hide resolved
data/CMakeLists.txt Show resolved Hide resolved
data/include/actsvg/data/odd_pixel_endcap.hpp Show resolved Hide resolved
Comment on lines 39 to +40
template <size_t DIM>
static inline std::pair<svg::object, svg::object> cluster(
std::pair<svg::object, svg::object> cluster(
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR for sure, but I wonder if we could move the implementation of this template (or in fact most of the templates) into .cpp files, and just provide implementations for the specializations that make sense. 🤔

meta/include/actsvg/styles/defaults.hpp Show resolved Hide resolved
@asalzburger
Copy link
Contributor

Indeed, there can be a lot shifted to headers, let's try to do this as first step.

@stephenswat
Copy link
Member Author

@asalzburger do you use any formatters for this repository?

@asalzburger
Copy link
Contributor

asalzburger commented Jun 20, 2024

@asalzburger do you use any formatters for this repository?

Not yet, we should probably just use the .clang-format definition from detray

This is done, I have merged #74 which adds clang-format and applies it.

I've noticed that actsvg has most of its code in header files. While
this is well managed using the `static` and `inline` keywords, it still
leads to some rather undesirable effects. For example, I ran into an
issue where a detray CUDA file was crashing because of some code in
actsvg, that that kind of very deep dependency is not very maintainable.
For that reason, I suggest we move as much of the code from actsvg into
sources files. This will help reduce compilation times and memory usage.
@stephenswat
Copy link
Member Author

Okay, this is ready to go. I suggest we can sort out the extern issue later as it is not so pressing.

@asalzburger asalzburger merged commit a357e0e into acts-project:main Jun 21, 2024
3 checks passed
@asalzburger
Copy link
Contributor

Great to have this merged before the summer student arrives!

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.

3 participants