Skip to content

C: Implement merging arena pages#719

Merged
marcoroth merged 11 commits intomarcoroth:mainfrom
timkaechele:merging-arena-pages
Mar 4, 2026
Merged

C: Implement merging arena pages#719
marcoroth merged 11 commits intomarcoroth:mainfrom
timkaechele:merging-arena-pages

Conversation

@timkaechele
Copy link
Contributor

@timkaechele timkaechele commented Oct 22, 2025

Based on the arena pages proposed in #708 by @marcoroth, this PR builds on the concept and adds a more refined reset behavior that merges obsolete pages into one big page.

This has the advantage that we won't have a bunch of small pages, and instead have more contiguous memory available.

How it works

# Initial state
| Page 1 (4kb) | - next > | Page 2 (4kb) | - next > | Page 1 (16kb) | 

# reset to  4kb
| Page 1 (4kb) | - next > | Page 2 (24kb) |

# reset to 0kb
| Page 1 (4kb) | - next > | Page 2 (24kb) |

For now the first page is never deallocated and merged into a bigger page for two reasons:

  1. It's an edge case that needs to be handled.
  2. If the allocation of a new arena page fails at least you still have the first page. 🤷‍♂️

Related: #1155

@marcoroth marcoroth added feature New feature or request refactor c labels Oct 22, 2025
@timkaechele timkaechele force-pushed the merging-arena-pages branch 2 times, most recently from f31b7bb to 0255d2c Compare October 23, 2025 06:34
@timkaechele timkaechele marked this pull request as draft October 23, 2025 07:06
@marcoroth marcoroth force-pushed the merging-arena-pages branch from 761fb2f to 096985d Compare March 4, 2026 14:22
@marcoroth marcoroth marked this pull request as ready for review March 4, 2026 14:22
@marcoroth marcoroth merged commit 1615346 into marcoroth:main Mar 4, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants