-
Notifications
You must be signed in to change notification settings - Fork 5
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
Niche optimization in HalfEdgeMesh #38
Comments
Hi! You said "with HalfEdge defined as" and linked the definition of the Lines 233 to 248 in 80c0e20
But this just stores a bunch of handles, so the end result is the same: handles would need to use And I did consider it back then, but it brings a few disadvantages. So either you have to subtract 1 before doing any index access or waste one element of space or something like that. But I don't know because I haven't tried & measured it. So yes it could very well be worth a shot, but also yes: it would be a bit of work as this "start at 0" assumption is baked in lots of parts of the library. A different approach would be to adjust Is it worth trying? If it's for fun, then for sure. In terms of "product", I think my time would be way more valuable when spent on other things, like re-introducing the IO module. So I certainly won't work on this anytime soon. I don't want to stop you and I am certainly interested in the results, but I can't promise I would be merging this if I find the disadvantages overweight. I hope this answers your questions :) |
Yeah, this does answer my questions, I didn't want to make too much effort if it turned out the reason it isn't here is because it was tried, measured and all the arithmetic makes it worse. I had started working on an attempt based on the I wouldn't expect you to merge it of course, Mostly this is just for getting a better understanding of the implementation by poking at the internals a little, so I guess that counts more as "for fun", than "product". Anyhow if I do manage to get it working, I'll go ahead and make a PR. |
Just looking through the HalfEdge implementation, it looks as though it should be possible to implement a niche optimization
lox/src/core/half_edge/mod.rs
Line 194 in 80c0e20
with HalfEdge defined as
lox/src/core/half_edge/mod.rs
Line 101 in 80c0e20
If that were switched from using
DenseMap
which uses aStableVec
internally to a map using InlineStableVec which would useOption
, then defineHalfEdge
using theNonZero
variants then adding/subtracting on creation indexing.It looks like trying it out would be a bit involved but overall doesn't really require any major refactors that would impact other parts of the code base, with the main thing being the alternative to
DenseMap
and NonZeroHandle
implementation. Was curious if you had tried that, or if feel like it's worth trying.Edit:
What would be really nice here if there was a
NonMax*
as mentioned in rust-lang/rust#45842That would allow for just checking when the handle is created rather than having to do arithmetic whenever it is used.
unfortunately afaik nothing in
std
which implements niches for_::MAX
.There is this crate though that emulates it https://crates.io/crates/nonmax but it is just a wrapper around
NonZero*
.The text was updated successfully, but these errors were encountered: