-
Notifications
You must be signed in to change notification settings - Fork 9
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
Reduce number of allocations when creating a Gc<T> #28
Comments
As you can probably tell, I optimized for ergonomics, then collection performance, and have barely looked at optimizing memory overhead. I'm not sure your idea works. We need to track handles with unique identifiers, which means that we must allocate twice. (Once for the handle, and once for the data.) Making a The allocation for the Lockout could definitely be removed (just store it inline in the I may break this into a bunch of issues, since this is touching on a lot of different problems with the code. This is a very new library after all :) |
Okay we're down to 3 allocations after #34. I think we can go down to two, but it's slightly tricky because of how deallocating currently works. I think removing that allocation should be done in conjunction with #23, because it will involve a refactoring of the deallocation logic. Also I'm not sure this is actually the slowest part of |
Still tracking this. I think that this is probably more of an issue now that I got rid of the concurrent hash tables (since the speed of |
Another complicating factor is the new support for unsized data. I found that compelling, but it complicates this since embedding unsized data in the |
Is it still 3 allocations? I would like to give it a try and work with #23 at the same time. Is there any suggestion I could get some insights first? |
Currently it seems that allocating a Gc<T> requires a whopping 4 heap allocations, of the T itself, a GcHandle, a GcData and a Lockout.
There seems to be no reason why a design can't be done with just 1 allocation and with a 1-pointer wide Gc<T>, by removing GcHandle and using Arc<GcData> directly instead of Arc<GcHandle> pointing to Arc<GcData>, and putting the Lockout and data inside the GcData.
The text was updated successfully, but these errors were encountered: