diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 14:44:08 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 15:36:57 -0300 |
| commit | a86e213e3e8053906df5ed4a37821c41a4afd932 (patch) | |
| tree | 9e22bf5bbe7b988757d10f80ac2348f8e5da27cf /core/Stream.zig | |
| parent | 8152cf383c8296be29e80175b57e40f8d41049bf (diff) | |
| download | pardes-a86e213e3e8053906df5ed4a37821c41a4afd932.tar.gz pardes-a86e213e3e8053906df5ed4a37821c41a4afd932.zip | |
layers: `Changes` does not hold the loop (P43), in Stream.zig's model: the word records what is asked (`jj.Ask`: the pane by serial, the file, the revision annotated, the revset; `Stream.changes`, one at a time, one asked meanwhile in `changes_next`) and emits the `search` effect with a generation of its own (`jj.gen_bit`); the shell's worker (`jj.start`, through Stream.start) runs jj's two commands (the log with each change's diff of the file, the annotation) and posts their raw answers as ONE input (`Event.search`, its new `jj` field naming the pane: the log in `rows`, the annotation in `styles`, a refusal with `end` failed), which the step takes (`jj.receive`): the last asked is parsed (`jj.parse`: pins, provenance, hunks, nest) and pinned, an earlier one's or a closed pane's dropped, then the one asked meanwhile goes; a replica replays that input and never runs jj; a host with no workers (a test) runs both as sites on the loop, a host whose worker cannot start hands the answer in as an input; while it runs the pane says `Changes: jj…` and what it showed stays until the answer lands; round 3's `may_wait` row for `Changes` is gone (the far-client walk: nothing stops there now); tests through the replica's surface with a worker host: the word returns before jj answers and says so, the answer lands as one input and a client replaying it ends equal; a second Changes before the first's answer pins only the second's; the pane closed before the answer: nothing pinned, nothing kept (no leak); measured (ReleaseSafe, `Changes xpxluunz..pvtvmpzx` on core/replica.zig, 16 changes, 8,328 lines, 112 hunks, jj's answers taken by hand): the step that takes the answer holds the loop 2.3-2.8 ms, where the word held it 588-603 ms (jj's two runs, 253 and 349 ms here, are the worker's now); core-test 899/1059 (160 skipped), shell-test 1101/1104 (3 skipped)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Stream.zig')
| -rw-r--r-- | core/Stream.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/core/Stream.zig b/core/Stream.zig index f65d0683..80812840 100644 --- a/core/Stream.zig +++ b/core/Stream.zig @@ -25,6 +25,7 @@ const look = @import("look.zig"); const panes = @import("panes.zig"); const syntax = @import("syntax.zig"); const Pardes = pardes.Pardes; +const jj = @import("jj.zig"); pub const Kind = enum { grep, files }; pub const Engine = enum { rg, walk }; @@ -74,6 +75,10 @@ pub const Batch = struct { /// at `revision` from byte `start`, one syntax.Syn a byte. painted: ?struct { serial: u32, revision: u32, start: usize } = null, styles: []u8 = &.{}, + /// A `Changes` answer (jj.zig) for pane `jj`, by serial: jj's log in + /// `rows` and its annotate in `styles`, or its refusal in `rows` and + /// `end` failed. + jj: ?u32 = null, pub const End = enum { done, failed }; @@ -138,7 +143,7 @@ const TextTask = struct { /// A worker joined, the turn out for it as for any blocking call (it may /// be reading through a mount of this very session): canceled, or waited /// for once it has sent its last. -fn join(future: std.Io.Future(void), io: std.Io, how: enum { cancel, wait }) void { +pub fn join(future: std.Io.Future(void), io: std.Io, how: enum { cancel, wait }) void { pardes.turn.yield(); var f = future; if (how == .cancel) f.cancel(io) else f.await(io); @@ -254,8 +259,14 @@ rows_asked_at: u8 = 0, /// Rows asked for their colours while a 9P write was served: asked again /// on the next step (Query.produceAll). rows_later: bool = false, +/// The `Changes` asked of jj and its worker, the one asked while it ran, +/// and how many were asked (jj.zig: one at a time, the last one pinned). +changes: ?jj.Task = null, +changes_next: ?*jj.Ask = null, +changes_count: u32 = 0, pub fn deinit(s: *Stream, gpa: std.mem.Allocator) void { + jj.cancel(s); s.cancelTask(); s.cancelParse(); s.cancelPaint(); @@ -584,6 +595,7 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, p: *Pardes, gen: u32, ctx: ?*an }; return; } + if (gen & jj.gen_bit != 0) return jj.start(io, gpa, p, gen, ctx, sink); // A parse's generation: its own task. if (s.parse) |*t| if (gen == s.parse_gen and t.job.gen == gen and t.future == null) { t.job.out = gpa; @@ -637,6 +649,7 @@ pub fn runHere(p: *Pardes, gen: u32, comptime in_call: bool) void { }; return; } + if (gen & jj.gen_bit != 0) return jj.runHere(p, gen, in_call); const s = &p.stream; if (gen != s.gen or s.state != .searching) return; const job = makeJob(p.gpa, s) catch |err| { @@ -687,6 +700,7 @@ const Collect = struct { pub fn receive(p: *Pardes, b: *const Batch) void { const s = &p.stream; if (b.parsed) |parsed| return receiveParse(p, b, parsed.serial, parsed.revision); + if (b.jj) |serial| return jj.receive(p, b, serial); if (b.painted != null) return receivePaint(p, b); if (b.gen != s.gen or (s.state != .searching and s.state != .capped)) { s.dropped += 1; |
