From cfd2b993feda1b3f7474225bb32db8cac8edc5ae Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 11:21:15 -0300 Subject: targets: the ESP32-P4 board port goes (src/esp32p4*.zig and src/esp32p4/, -Dplatform=esp32p4 with its pinned riscv32 target, -Desp32p4-cols and -rows, the Peek, Poke, Hexdump and Gpio words and the Board behind them, the board's 9P engine options, the gpio_toggle host slot), and with it every guard and limit only the board needed: terminal_panes and terminal.enabled (ghostty is in every build), memory.limits' board branching (the desktop values stay), MAX_PANES 64 and MAX_COLS 16 fixed, the board's boot buffer and its embedded boot, the pager's and the terminal's emulator-less paths; tests: the board's GPIO, ring and Board ones go, the boot-OOM and transition-grid ones stay under their own names; the perf harness loses the board's fixture, so the Debug baselines of both frontends are recorded again (--only medium --reps 10) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/memory.zig | 55 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'src/memory.zig') diff --git a/src/memory.zig b/src/memory.zig index 8ce3ad12..c4e0e6fd 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -3,7 +3,6 @@ const builtin = @import("builtin"); const walk = @import("walk.zig"); const config = @import("pardes_config"); -const board = config.platform == .esp32p4; const reduced_target = builtin.os.tag == .freestanding; const KiB = 1024; const MiB = 1024 * KiB; @@ -11,59 +10,56 @@ const MiB = 1024 * KiB; pub const limits = struct { pub const max_file_bytes = 256 * MiB; pub const max_stream_bytes = 4 * MiB; - // P4: 384 KiB heap; static buffers and stack share a separate 240 KiB region. - pub const board_heap_bytes = 384 * KiB; - pub const effect_cap = if (board) 128 else 4096; - pub const pending_write_cap: usize = if (board) 0 else 4 * MiB; - pub const wrap_rows = if (board) 128 else 256; - pub const undo_max = if (board) 16 else 256; + pub const effect_cap = 4096; + pub const pending_write_cap: usize = 4 * MiB; + pub const wrap_rows = 256; + pub const undo_max = 256; /// The text a file's undo and redo steps hold together, kept by dropping /// the oldest; the newest step always stays, so the bound per file is /// this plus one snapshot (at most max_file_bytes). - pub const undo_bytes: usize = if (board) 64 * KiB else 64 * MiB; - pub const message_log = if (board) 16 else 128; + pub const undo_bytes: usize = 64 * MiB; + pub const message_log = 128; /// ranges one selection holds; helix has no limit, and a `%s` over a /// file's words wants hundreds - pub const selections = if (board) 64 else 1024; + pub const selections = 1024; /// /log's ring, which records whether or not anyone reads it. - pub const log_bytes: usize = if (board) 4 * KiB else 64 * KiB; - pub const max_tag_tail: usize = if (board) 512 else 4096; + pub const log_bytes: usize = 64 * KiB; + pub const max_tag_tail: usize = 4096; /// Pixels one image may decode to (RGBA, 4 bytes each): checked from its /// header before stb_image allocates them. - pub const image_decode_pixels: usize = if (board) 0 else 64 * 1024 * 1024; + pub const image_decode_pixels: usize = 64 * 1024 * 1024; /// What the core's per-step scratch arena and the frame arena keep /// between steps: a step that needed more (a huge Callstack's sources) /// gives the rest back instead of holding its high-water mark. - pub const scratch_kept: usize = if (board) 4 * KiB else 16 * MiB; - pub const frame_kept: usize = if (board) 4 * KiB else 16 * MiB; + pub const scratch_kept: usize = 16 * MiB; + pub const frame_kept: usize = 16 * MiB; /// The other open files one language query copies for its server, in /// bytes: past it the rest are left out (the asked file always goes). - pub const lsp_snapshot_bytes: usize = if (board) 0 else 64 * MiB; + pub const lsp_snapshot_bytes: usize = 64 * MiB; /// One paste, from any shell: past it, the rest is left out and said. - pub const max_paste_bytes: usize = if (board) 16 * KiB else 4 * MiB; - pub const host_path_cap: usize = if (board) 0 else 4095; + pub const max_paste_bytes: usize = 4 * MiB; + pub const host_path_cap: usize = 4095; /// -Dembed-sources: the editor serves its own sources under /src. pub const embedded_sources = config.embed_sources; - pub const hexdump_row_bytes: u32 = if (board) 8 else 16; /// Each arena's fixed region. On a native target these are address /// space reserved at startup, resident only where used (`Pages`), so /// they are sized for the worst case: the core holds a 256 MiB file, its /// edit's copy and its undo. pub const arena = struct { - pub const pardes = if (board) 4 * KiB else if (reduced_target) 8 * MiB else 1024 * MiB; - pub const frame = if (board) 4 * KiB else if (reduced_target) 4 * MiB else 64 * MiB; - pub const lsp = if (board or reduced_target) 0 else 512 * MiB; + pub const pardes = if (reduced_target) 8 * MiB else 1024 * MiB; + pub const frame = if (reduced_target) 4 * MiB else 64 * MiB; + pub const lsp = if (reduced_target) 0 else 512 * MiB; /// What a native shell allocates itself (`host`): its screen, the /// bytes its ptys read, its 9P connections, its pipe jobs. - pub const host = if (board or reduced_target) 0 else 512 * MiB; - pub const tree_sitter = if (board) 0 else if (reduced_target) 4 * MiB else 256 * MiB; - pub const image = if (board) 0 else if (reduced_target) 64 * KiB else 256 * MiB; - pub const pdf = if (board) 0 else if (reduced_target or !config.mupdf) 64 * KiB else 512 * MiB; + pub const host = if (reduced_target) 0 else 512 * MiB; + pub const tree_sitter = if (reduced_target) 4 * MiB else 256 * MiB; + pub const image = if (reduced_target) 64 * KiB else 256 * MiB; + pub const pdf = if (reduced_target or !config.mupdf) 64 * KiB else 512 * MiB; /// One language query's working memory (its parsed answers, the rows /// it writes): a hard bound, nothing spills. Callstack walks until it /// would leave less than its rendering reserve. - pub const lsp_query = if (board or reduced_target) 0 else 256 * MiB; + pub const lsp_query = if (reduced_target) 0 else 256 * MiB; }; }; @@ -79,7 +75,7 @@ pub const Allocators = struct { pdf: Allocator, }; -/// A freestanding target's arena (web, board): `std.heap.StackFallbackAllocator` +/// A freestanding target's arena (the web's): `std.heap.StackFallbackAllocator` /// with the buffer taken through its lock-free interface. A /// FixedBufferAllocator frees only its last block, so once a big operation /// fills the buffer everything after spills; a native target uses `Pages`. The core's allocator is used from two threads: a 9P @@ -598,7 +594,7 @@ test "a region's runs: aligned first fit, growth in place, release" { } test "memory limits preserve desktop capacities" { - if (board or reduced_target) return error.SkipZigTest; + if (reduced_target) return error.SkipZigTest; try std.testing.expectEqual(4096, limits.effect_cap); try std.testing.expectEqual(@as(usize, 4 * MiB), limits.pending_write_cap); try std.testing.expectEqual(256, limits.wrap_rows); @@ -608,7 +604,6 @@ test "memory limits preserve desktop capacities" { try std.testing.expectEqual(@as(usize, 4096), limits.max_tag_tail); try std.testing.expectEqual(@as(usize, 4095), limits.host_path_cap); try std.testing.expectEqual(config.embed_sources, limits.embedded_sources); - try std.testing.expectEqual(@as(u32, 16), limits.hexdump_row_bytes); try std.testing.expectEqual(1024 * MiB, limits.arena.pardes); try std.testing.expectEqual(64 * MiB, limits.arena.frame); try std.testing.expectEqual(512 * MiB, limits.arena.lsp); -- cgit v1.3