Skip to content

Refactor offset-allocator to improve readability - #10

Open
patowen wants to merge 13 commits into
pcwalton:mainfrom
patowen:refactor-for-rust-practices
Open

Refactor offset-allocator to improve readability#10
patowen wants to merge 13 commits into
pcwalton:mainfrom
patowen:refactor-for-rust-practices

Conversation

@patowen

@patowenpatowen commented Aug 3, 2026

Copy link
Copy Markdown

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, in case such a refactor is worthwhile to have upstream. I've rebased the commit history to hopefully ease reivew.

This PR makes the following changes (which have been separated out by commit):

  • Add and update documentation to better explain how the allocator works
  • Create various abstractions, including SmallFloat, BinsMap, and NodeSlab
  • Move some code into separate modules, including NodeIndex, BinsMap, and NodeSlab
  • Add various bugfixes and tweaks

Please let me know if you have any further questions about this PR. I promise that I did not use an LLM to write any of the code in this PR.

@patowen
patowenforce-pushed the refactor-for-rust-practices branch from 3e4f1c6 to 5a1a110CompareAugust 22, 2026 04:55
@patowen

Copy link
Copy Markdown
Author

I've updated this PR so that it's actually readable, as well as removing some of the more controversial changes (such as adding the slab dependency and removing the nonmax dependency).

@patowen
patowenforce-pushed the refactor-for-rust-practices branch from 5a1a110 to 3064f95CompareAugust 22, 2026 05:05
@patowen
patowenforce-pushed the refactor-for-rust-practices branch from 3064f95 to 2da1cccCompareAugust 22, 2026 05:05
@patowen
patowen marked this pull request as ready for review August 22, 2026 05:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@patowen