fitzgen / fitzgen/bumpalo

Too large allocation because of doubling last allocation

Open
#152 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.3k
Forks
157
Avg merge
3d 17h
Merged PRs (30d)
1

Description

Consider this scenario:

* allocate 10 bytes
* allocate 1 Mb
* allocate 10 bytes

`bumpalo` will allocate 3M, because third allocation will create third chunk double the size of second chunk.

Instead `bumpalo` could do the following: if allocation size is larger than 1M, always allocate in the fresh chunk of size exact of allocation size, attach it to the tail of current chunk, and then continue allocating in the current chunk.

This will break this invariant of `iter_allocated_chunks`:

```
/// The chunks are returned ordered by allocation time, with the most
/// recently allocated chunk being returned first, and the least recently
/// allocated chunk being returned last.
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing bumpalo's chunk allocation path and reading the iter_allocated_chunks documentation; reproduce the 10-byte/1 MiB/10-byte sequence to inspect chunk sizes and ordering. Confirm the proposed exact-size large-chunk behavior and add regression coverage for allocation size and iteration order.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.