Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Variants with different index/generation type sizes #1

Open
Nemikolh opened this issue Aug 23, 2018 · 4 comments
Open

Variants with different index/generation type sizes #1

Nemikolh opened this issue Aug 23, 2018 · 4 comments

Comments

@Nemikolh
Copy link

Hi! Thanks a lot for putting this crate up, this is quite a clever idea (thanks @kyren !).
I have a question: would you be interested in adding variants where Index would be smaller in size?

I'm thinking of games where you might have an upper bound in the number of objects that would ever be in your Arena or how many generation you would get. In those case, it's preferable to have Index with a smaller size. For instance:

struct Index32 {
    index: u32,
    generation: u32
}

I guess depending on the use case, indexorgeneration could be made even smaller. We would also need some additional checks to detect whether the maximum generation or sized was reached.

What do you think?

@Nemikolh Nemikolh changed the title Variants for the index/generation sizes Variants with different index/generation type sizes Aug 23, 2018
@fitzgen
Copy link
Owner

fitzgen commented Sep 4, 2018

I think u32 is too small, since it only takes a few seconds to wrap around.

I am interested in various ways to improve the current implementation in regards to the number of generation tags and their sizes, but need to find time to investigate some more.

@Nemikolh
Copy link
Author

I totally agree with you on that last point. We need to experiment more. I came across this article where they use a generation index of 8 bits. The implementation is a bit different, it uses a queue of free indices and enforce that they are not reused unless the queue has reached its maximum capacity.

Once I have the time, I will submit a PR with the experiments I have made.

@HenryTheCat
Copy link

While it's only a minor change, I submitted PR #16 to optimize the case of Index wrappend into an Option by changing the type of generation to a non-zero integer. Would that be acceptable/useful?

@mmstick
Copy link

mmstick commented Jul 5, 2019

Seems this has been achieved by this fork

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants