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

[Persistence Matrix] Addition of small vectors as a column type #1154

Merged
merged 6 commits into from
Feb 5, 2025

Conversation

hschreiber
Copy link
Collaborator

Replacing std::vector with boost::container::small_vector in Naive_vector_column showed some run time improvements on some particular use cases in multipers. So I added the possibility in the column choices.

Copy link
Member

@mglisse mglisse left a comment

Choose a reason for hiding this comment

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

Would the same templatization make sense for Vector_column? Maybe it does but you consider that class useless?

using STD_naive_vector_column = Naive_vector_column<Master_matrix, std::vector<typename Master_matrix::Matrix_entry*> >;
template <class Master_matrix>
using Small_naive_vector_column =
Naive_vector_column<Master_matrix, boost::container::small_vector<typename Master_matrix::Matrix_entry*, 8> >;
Copy link
Member

Choose a reason for hiding this comment

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

It seems strange to hardcode 8.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree. It would be better to have something general here, but I didn't wanted to add an option for that... And 8 was what worked the best in my benchmarks to compute a barcode. Do you see an easy way to give the possibility to customize this value for the user without having to add an option just for this particular case?

Copy link
Member

Choose a reason for hiding this comment

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

Not "easy": in my opinion, the original issue is that using an enum makes the design not extensible (a user cannot provide their own column type). If you changed the design enough for it to be extensible, then there would be no limitation on parameterizing the column types you provide.
(IIRC, Boost.Graph has a similar limitation with a hard-coded list of possible containers for some data structures)
Without going all the way to an extensible design, using tag classes instead of an enum (i.e. empty classes that are only used with is_same<T,vector_column_tag> or similar) might not require huge changes and could accommodate small_vector_tag<8>.
Anyway, I'll approve this for now, but please make a note somewhere about this (an issue, or a comment in the code, I don't know if you already have a list of potential improvements somewhere).

Copy link
Contributor

Choose a reason for hiding this comment

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

We will keep track of this on #1167

@@ -224,7 +224,13 @@ class Naive_vector_column : public Master_matrix::Row_access_option,
};

template <class Master_matrix>
inline Naive_vector_column<Master_matrix>::Naive_vector_column(Column_settings* colSettings)
using STD_naive_vector_column = Naive_vector_column<Master_matrix, std::vector<typename Master_matrix::Matrix_entry*> >;
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of Naive_std_vector_column and Naive_small_vector_column, to keep the qualifier of vector next to the word vector?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds much better! Changed it.

@hschreiber
Copy link
Collaborator Author

Would the same templatization make sense for Vector_column? Maybe it does but you consider that class useless?

It makes indeed also sense for Vector_column. It's just that Vector_column only works better when a lot of entries are manually cleared inside the column, which for now only happens during vineyard with RU. And in that case, the small vector do not seem to make things much better. At least in multipersistence. And I am wondering a bit, if the class is not indeed useless as you say, as using a set kind of works better in that particular case anyway...

@VincentRouvreau VincentRouvreau merged commit 529281f into GUDHI:master Feb 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11.0 GUDHI version 3.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants