summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-23 17:11:12 -0300
committerGabriel Schneider <[email protected]>2026-10-23 17:11:12 -0300
commitef0de36bf473f22d37cc885054bf4eed98bf275f (patch)
treefc5d8522a13efc72a945cc04e872e35e44b111a6 /src/main.zig
parent1b0ce981c7a0f0feac926023ed6be53da45a36aa (diff)
downloadpardes-ef0de36bf473f22d37cc885054bf4eed98bf275f.tar.gz
pardes-ef0de36bf473f22d37cc885054bf4eed98bf275f.zip
Arenas are regions mapped once with a page bitmap under a DebugAllocator; the shells allocate from one too
Each arena (pardes, frame, lsp, tree_sitter, image, pdf and the new host) maps its region once and tracks 4 KiB pages in a bitmap; a full region spills to malloc and counts it. Freed runs of 64 KiB to 1 MiB go back at once, the rest at memory.trim. In a release build init.gpa is memory.host over libc's malloc. Measured against the old arenas: typing in a 7.4 MB file 1.95 ms a key (was 2.0), a V8 Callstack page 142 MiB (was 134) and 42 MiB after close (was 69). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main.zig b/src/main.zig
index 52093b9a..9086fa90 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -317,16 +317,13 @@ fn webMain() !void {
try @import("gui/gui.zig").run(.{}, .{}, null);
}
-// init.gpa, what the tty, gui and detached shells allocate from, is
-// std.start's: a DebugAllocator in Debug and, since we link libc, libc's
-// malloc otherwise. Kept on purpose: glibc's malloc was measured at least as
-// fast as std.heap.smp_allocator on every scenario and faster on MuPDF's
-// page-sized rasters. macos.zig makes the same choice for itself.
+// init.gpa, what the tty, gui and detached shells allocate from, is their
+// own fixed arena (memory.host) in a release build, spilling to libc's
+// malloc, and std.start's DebugAllocator in Debug. Zig 0.17's std.start
+// gives a safe build a SafeAllocator over the page allocator instead.
fn nativeMain(std_init: std.process.Init) !void {
var init = std_init;
- // Zig 0.17's std.start gives a safe build a SafeAllocator over the page
- // allocator, not libc's malloc: hand the shells malloc, as above.
- if (builtin.mode != .debug) init.gpa = std.heap.c_allocator;
+ if (builtin.mode != .debug) init.gpa = pardes.memory.host(std.heap.c_allocator);
var stderr_probe: [64]u8 = undefined;
_ = std.debug.lockStderr(&stderr_probe);
std.debug.unlockStderr();