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

refactor: consolidate allocators #16061

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

refactor: consolidate allocators #16061

wants to merge 12 commits into from

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Dec 30, 2024

What does this PR do?

Moves all memory allocators into src/allocators. The following allocators are affected:

  • NullableAllocator
  • MimallocArena
  • MaxHeapAllocator
  • LinuxMemFdAllocator
  • All allocators in memory_allocator.zig (CAllocator, ZAllocator, HugeAllocator, etc)

I also added an underflow check to LinuxMemFdAllocator in case a consumer calls deref() without first calling ref()

@robobun
Copy link

robobun commented Dec 30, 2024

Updated 7:16 PM PT - Jan 1st, 2025

@DonIsaac, your commit aa02a42 has 1 failures in #8800:


🧪   try this PR locally:

bunx bun-pr 16061

@DonIsaac DonIsaac enabled auto-merge January 2, 2025 01:51
},
0 => {
// TODO: @branchHint(.cold) after Zig 0.14 upgrade
std.debug.panic("LinuxMemFdAllocator ref_count underflow", .{});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's throw this in a if (Environment.isDebug) {... } block. I'm not familiar with how/where this allocator is dereferenced, but we don't want to introduce a panic for something that could be a noop

Copy link
Member

@dylan-conway dylan-conway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment

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.

3 participants