aboutsummaryrefslogtreecommitdiff
path: root/src/memory_allocator.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-02 03:00:45 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-02 03:00:45 -0700
commite5eabc0658d2133603596ec17a6e7c956c5fe28c (patch)
tree8e50a0bfa0ca9eba4145191720bb7d412bf8d26f /src/memory_allocator.zig
parent121c2960de87c53cc6bdd5f92fab627a74d21a2b (diff)
downloadbun-e5eabc0658d2133603596ec17a6e7c956c5fe28c.tar.gz
bun-e5eabc0658d2133603596ec17a6e7c956c5fe28c.tar.zst
bun-e5eabc0658d2133603596ec17a6e7c956c5fe28c.zip
Faster ReadableStream
Diffstat (limited to 'src/memory_allocator.zig')
-rw-r--r--src/memory_allocator.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/memory_allocator.zig b/src/memory_allocator.zig
index b6b9283fa..a8fbd116a 100644
--- a/src/memory_allocator.zig
+++ b/src/memory_allocator.zig
@@ -214,7 +214,6 @@ const z_allocator_vtable = Allocator.VTable{
.resize = ZAllocator.resize,
.free = ZAllocator.free,
};
-
const HugeAllocator = struct {
fn alloc(
_: *anyopaque,
@@ -272,6 +271,8 @@ const huge_allocator_vtable = Allocator.VTable{
.free = HugeAllocator.free,
};
+pub const huge_threshold = 1024 * 256;
+
const AutoSizeAllocator = struct {
fn alloc(
_: *anyopaque,
@@ -280,7 +281,7 @@ const AutoSizeAllocator = struct {
len_align: u29,
return_address: usize,
) error{OutOfMemory}![]u8 {
- if (len > 1024 * 1024 * 2) {
+ if (len >= huge_threshold) {
return huge_allocator.rawAlloc(
len,
alignment,
@@ -314,7 +315,7 @@ const AutoSizeAllocator = struct {
a: u29,
b: usize,
) void {
- if (buf.len > 1024 * 1024 * 2) {
+ if (buf.len >= huge_threshold) {
return huge_allocator.rawFree(
buf,
a,