diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 23:31:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 07:26:38 -0300 |
| commit | 2d30f3781ab40c38710835806a1029359509d27b (patch) | |
| tree | 282b4cee975ee2d74a53691acd99cfc03d55ef89 /core/Core.zig | |
| parent | 5e162e2e8b208367720b8be8de3bfe51b010aa68 (diff) | |
| download | pardes-2d30f3781ab40c38710835806a1029359509d27b.tar.gz pardes-2d30f3781ab40c38710835806a1029359509d27b.zip | |
frontends: the terminal and the window draw and turn input into events from the frame and one record beside it (the reorganisation's runners, step 10a, on the line as it is now): surface.Facts, the core's (Pardes.facts) and pointed at by the frame it is filled for (Surface.facts), filled by draw.place in the walk over the panes it makes anyway and by a runner after an input it applied (draw.facts), carries what a frontend took from the core (the view's size, cell pixels and row metrics, each open pane's rectangle, tag rows, context rows, serial, whether a terminal whose program takes the wheel or a kind's, its mode, the jumps' back and forward, the settings it draws by); the window keeps a copy (Gui.facts) with the frame it shows (Gui.frame) and its hit tests, wheel, touchpad rows, timedemo, blink, overlays and dim read only those; Host.present returns whether the frame was shown, so present_skipped leaves the core and nothing writes it; the frame statistics are the runner's (Options.frames, Pardes.frames a pointer to them), which the frontends write and the core's draw reads; Replica.draw returns the shown and keeps needs_frame itself, so the two client loops put nothing back; OwnView and Replica.within are deleted (the window client's own pass reads its facts, its inputs fed after each event as before); rollback-bench compiles again; the tape's watched fields lose present_skipped and present answers a bool, so the semantics word moves (0900e560fd6395ef, pardes-seam-b's, -> 2f615168fe07b35f). The first version (psvoxrup, on pardes-tree) kept the record by value in every Surface, and every Surface a tag line builds for a moment copied its 1.3 KB more: +1,556 instructions an image-frame, +3,763 a render (perf record: memcpy); now perfops against tree1 97 counts within 0.1%, largest image-frame +0.029%. Brought onto pardes-seam-b: the client set-up keeps the Distrusted list beside the runner's frame statistics, Options' local fields both, and the rollback test's present answers a bool. Gate: frames 77/77 byte-identical in Debug, the alternated windows' pictures identical in all 10 ReleaseFast runs, corpus2x -0.039% (PASS); tui core-test 836/979 (143 skipped), shell-test 1014/1017, term-test 15/15, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test lspcomplete and lspcompletemoved (the base's) and grep (passed alone three times of three); gui unit-test 1612/1616 with the base's BaselineHarnessMismatch; replicas --clients 5 diverged 0, unequal 0, deltas wrong 0, quiet 470/0, 600/0, 764/0; daemon.py plain, --far, --games, --window-clients, --upgrade both ways (from pardes-tree's pfx-base); the macOS library for Linux and aarch64-macos and the FreeBSD tui configure; rollback-bench runs
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/core/Core.zig b/core/Core.zig index 398d5973..0e37f945 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -282,8 +282,12 @@ theme_file_loaded: config.Runtime.Text(limits.host_path_cap) = .{}, theme_file_generation: u32 = 0, theme_file_pane: u8 = 0, chrome: colors.ChromeTheme = colors.initial_chrome, -/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES). -frames: FrameStats = .{}, +/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES): +/// its runner's (`Options.frames`), which its frontend writes as it draws +/// and reads input, never the core's memory; a core with no runner (a +/// test's) has its own. +frames: *FrameStats = undefined, +own_frames: FrameStats = .{}, quit: bool = false, /// A detached session with no frontend attached: nothing renders, so /// no input ever dismisses a message (Messages.expireUnattended). @@ -334,9 +338,6 @@ boot: Boot = .shell, /// Is there a frame worth drawing? Cleared once one is presented, set by /// anything that can change what is on screen. The first frame always is. needs_frame: bool = true, -/// Set by a shell whose present was skipped (no swapchain image): the -/// frame is still owed, and the next pump draws it again. -present_skipped: bool = false, clock: Clock = .{}, /// Builtins announce themselves on the message row. Off while startup /// configuration is applied: those lines are nobody clicking, and should @@ -388,6 +389,9 @@ restore_req: ?[]const u8 = null, restore_buf: [1024]u8 = @splat(0), surface: Surface = .{}, +/// What a frontend reads beside the frame's cells (surface.Facts), filled +/// as it is placed (draw.place); the frame points at it. +facts: pardes.Facts = .{}, /// A replica's predicted echo (core/term/echo.zig), drawn over its terminals: /// presentation, its own, in no digest and no rollback copy. Null on a /// session's own core. @@ -427,9 +431,11 @@ diff_output: pardes.ansi.DiffOutput = .{}, pub const replica = .{ .local = .{ // A frame, and the timings that make it. - "surface", "frames", "chrome", + "surface", "facts", "frames", + "own_frames", + "chrome", "frame_arena", "scratch", "needs_frame", - "present_skipped", "echo", + "echo", // Drained by every pump before its digest; a replica's queues // are its own. "effects", @@ -522,6 +528,7 @@ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes { .fallback = .{ .gpa = gpa }, .db = .{ .kind = opts.state }, }; + p.frames = opts.frames orelse &p.own_frames; errdefer p.deinit(); p.fs.started = ctlfs.events.now(); for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); @@ -1499,23 +1506,23 @@ pub fn pump(p: *Pardes, host: Host) !void { if (v.watched) |f| if (!f(h.ctx)) return; // The one view this process shows (a replica client's is its own // process's to draw), drawn as it is if another's is live. + // Not shown by the frontend (Host.present): owed. + var skipped = false; const shown = Views.shown(p); if (shown != p.live) { - if (shown) |k| try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present }); + if (shown) |k| skipped = !try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present }); } else { _ = p.frame_arena.reset(.{ .retain_with_limit = memory.limits.frame_kept }); p.frames.mark_update = FrameStats.nowNs(); p.frames.view = if (p.panes[p.view().active]) |pane| pane.scroll() else 0; const surface = try p.render(p.frame_arena.allocator()); p.frames.mark_render = FrameStats.nowNs(); - if (v.present) |f| f(h.ctx, surface); + if (v.present) |f| skipped = !f(h.ctx, surface); Stream.askAhead(p); } // Settled before post_present: a shell ticks there, and what that // tick moves owes the next frame. - const skipped = p.present_skipped; - p.needs_frame = p.present_skipped; - p.present_skipped = false; + p.needs_frame = skipped; if (v.post_present) |f| f(h.ctx); // Still moving: the next frame is owed a period from now. const owed = if (p.nextWake()) |due| due <= p.clock.stepped_ns + frame_ns else false; @@ -2234,7 +2241,9 @@ pub const Boot = enum { }; pub const Options = struct { - pub const replica = .{ .local = .{"distrusted"} }; + /// Not taped: the client's list of distrusted kinds, and where its + /// runner keeps its frame statistics. + pub const replica = .{ .local = .{ "distrusted", "frames" } }; tty_only: bool = false, /// The first view's frontend is a window (`Pardes.frontend`), as a /// window's build says: an option, taped with the rest, so that a @@ -2285,6 +2294,8 @@ pub const Options = struct { /// Where each frame's Surface text is built. Hosts pass a purpose-built /// stack-fallback arena; null means the general allocator. frame_allocator: ?std.mem.Allocator = null, + /// The runner's frame statistics (`Pardes.frames`); null: the core's own. + frames: ?*FrameStats = null, cols: u16 = 80, rows: u16 = 24, }; @@ -2715,8 +2726,9 @@ test "a frame no one watches is not drawn, and is drawn once someone does" { var presents: usize = 0; var seen = false; const vtable: Host.VTable = .{ .present = present, .watched = watched }; - fn present(_: ?*anyopaque, _: *const Surface) void { + fn present(_: ?*anyopaque, _: *const Surface) bool { presents += 1; + return true; } fn watched(_: ?*anyopaque) bool { return seen; |
