Refactor offset-allocator to improve readability - #10
Draft
patowen wants to merge 1 commit into
Draft
Conversation
This commit makes the following changes: * Add documentation to better explain how the allocator works * Use the slab crate for managing free node indexes * Set up a newtype for SmallFloat * Create `SmallFloatMap`, which SmallFloat is used as an index for * Create `BinsMap` as a layer of abstraction for `used_bins` etc. * Set up a custom NodeIndexOption type to remove nonmax crate dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few months ago, as part of my work on Hypermine, I was looking into this crate as something to potentially use to manage allocations in Vulkan. While evaluating this crate, I studied the code carefully to understand how it worked, and while doing so, I made some rather extensive refactors to make it easier for me to understand this code. Eventually, I was happy enough with the refactors that I was in favor of vendoring this dependency in Hypermine so that I could take advantage of these refactors.
However, it was suggested that I look into trying to contribute my refactor upstream. I was initially hesitant to do so because this crate was meant to be a port of a C++ package, which itself is considered an "early one weekend prototype", and it seemed like this crate is meant to be as faithful to that C++ package as well.
Regardless, I'm submitting this draft PR in case you are interested in seeing what I have so far, in case such a refactor is worthwhile to have upstream. If you are interested in such a PR, please let me know, and I can try to clean it up to make it easier to review (and ready for the library, as I still left a TODO in here).
This PR makes the following changes:
SmallFloatMap, which SmallFloat is used as an index forBinsMapas a layer of abstraction forused_binsetc.For further historical context on how these changes came to be, see these commit history of https://github.com/patowen/offset-allocator/commits/rewrite-wip/.