Ideal data block size from allocator
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
When programming dynamically allocated data structures, it's often desirable to pick the allocation block size that provides best performance and/or causes least memory overhead or fragmentation waste per unit of data. This, however, may depend on the allocator and even on the data layout. I'm proposing to add a method or methods to the Alloc trait that would return an estimation of the "best" allocation block size for the given Layout. The fuzzy value function for "best" may mean "fastest" or "most space-efficient", which two might conceivably be different. The upper bound for the resulting data block size should be the size of the OS memory page (unless a larger size is significantly more efficient with the allocator), and the default implementation could divide the page size to the array item size.
pub trait Alloc {
// ...
fn fastest_array_size(&self, layout: &Layout) -> usize;
fn densest_array_size(&self, layout: &Layout) -> usize;
}
I can write up an RFC if the idea does not merit disapproval.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing issue #2223 and the proposed Alloc trait methods, including how the given Layout and allocator characteristics affect the estimate. The work is done when the proposal's performance and memory-efficiency goals are resolved into a clearly scoped RFC or the idea is rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100