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

Refactor RowMajorMatrix with a safe API #600

Open
naure opened this issue Nov 19, 2024 · 4 comments · May be fixed by #624
Open

Refactor RowMajorMatrix with a safe API #600

naure opened this issue Nov 19, 2024 · 4 comments · May be fixed by #624
Labels
cleanup Refactors, simplifications, hindsight 20/20 tasks.

Comments

@naure
Copy link
Collaborator

naure commented Nov 19, 2024

This type uses MaybeInit with the expectation that assignment code will set values in every cell. Moreover, the matrix is usually larger than requested in new(…) because it is padded to a power-of-two size. All in all that is error-prone and hard to debug (been there, #597).

Rewrite this with a safe and easy API.

One idea is to use Vec::with_capacity and extend. Another way could be based on iterators and use collect_vec.

Regarding padding, the type should take the responsibility to fill the padding rows. It is not actually necessary to allocate that padding space. The padding can be represented with a single value to repeat, and the padding is done at the last possible time in de_interleaving. It could look like a method set_padding_strategy(…), see the existing enum InstancePaddingStrategy.

@naure naure added the cleanup Refactors, simplifications, hindsight 20/20 tasks. label Nov 19, 2024
@naure naure changed the title Refactor RowMajorMatrix with safe API Refactor RowMajorMatrix with a safe API Nov 19, 2024
@matthiasgoergens
Copy link
Collaborator

How much time or memory are we actually saving with the uninit shenanigans?

@naure
Copy link
Collaborator Author

naure commented Nov 19, 2024

The proposed approach should be marginally faster than the current one thanks to postponing the padding, but this issue is more about ease of use.

@matthiasgoergens
Copy link
Collaborator

Yes. I'm just curious how much we are gaining from the shenanigans currently in master compared to not doing anything special?

Do you know whether we ever did some benchmarks?

@naure
Copy link
Collaborator Author

naure commented Nov 19, 2024

There is only the one implementation as far as I know.

@naure naure linked a pull request Nov 22, 2024 that will close this issue
@naure naure linked a pull request Nov 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Refactors, simplifications, hindsight 20/20 tasks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants