Skip to content
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

POC: A dynamic memory allocator for BTreeMap #105

Closed
wants to merge 45 commits into from
Closed

Conversation

ielashi
Copy link
Contributor

@ielashi ielashi commented Jul 19, 2023

This PR introduces a dynamic memory allocator implementation, which will be used in the BTreeMap to allow for unbounded types. The allocator uses a two-level segregated free list to manage allocations, which is described in this paper by Masmano et al.

The implementation is functionally complete, but there are a few missing pieces:

  1. Logic for upgrading from the BTreeMap's current constant-size allocator.
  2. More testing, better documentation, and some minor cleanups.
  • tlsf.rs
  • tlsf/blocks.rs
  • tlfs/free_lists.rs

This PR will be broken down into smaller bite-sized PRs.

While this allocator will initially only be used by BTreeMap, it is designed to be general-purpose and can be used by other structures in the future.

@ielashi ielashi force-pushed the ielashi/tlsf branch 2 times, most recently from 5f17e66 to b900c0c Compare July 19, 2023 11:13
@ielashi ielashi changed the title WIP: A dynamic memory allocator for BTreeMap POC: A dynamic memory allocator for BTreeMap Jul 19, 2023
@ielashi ielashi closed this Aug 21, 2023
@ielashi ielashi reopened this Aug 21, 2023
@ielashi
Copy link
Contributor Author

ielashi commented Oct 25, 2023

Closing this PR as we ended up using a different approach for BTreeMap that relies on fixed-size pages. The reason we opted for the latter solution rather than a dynamic memory allocator is that it's safer. A dynamic memory allocator may be more efficient, but depending on the usage pattern the amount of external fragmentation is unbounded.

We many potentially revisit this idea in the future though.

@ielashi ielashi closed this Oct 25, 2023
Sign up for free to 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