diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 20:57:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 21:34:14 -0300 |
| commit | 9589f6878ffd2501b4ce5a034ead58119d38749c (patch) | |
| tree | bb5dafdd90f552144b29ad3468fac30b38992f2b /src/Kind.zig | |
| parent | 76b493ef40a02931eb86805aa30040a594b72ec8 (diff) | |
| download | pardes-9589f6878ffd2501b4ce5a034ead58119d38749c.tar.gz pardes-9589f6878ffd2501b4ce5a034ead58119d38749c.zip | |
kinds #42, what a Zig kind over a C library needs of the module and the core: addon.zig's `init` at load (a library's own setup, MuPDF's allocator) and a body the kind holds (`body(s) []const u8`, any length: a PDF page's text is past body_max), the Debug budget counting only the kind's own time (the file's hash before `open` and pa_api.heap's allocations are the core's: a region's first took 23 ms of a PDF's open, which was the breach), `current` the loop's thread's (a job's heap call is in no call), an Output's arg set from itself (a kind's rows found after its search refill its +Search with its own arg: the @memcpy aliased), and the docs test reading the words of Zig kinds (`.{ .name = "PdfFit"`) beside C's
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Kind.zig')
| -rw-r--r-- | src/Kind.zig | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Kind.zig b/src/Kind.zig index db3bee49..27cd1a6d 100644 --- a/src/Kind.zig +++ b/src/Kind.zig @@ -279,6 +279,8 @@ pub fn reopen(p: ?*Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool { // Its file not read (not here): it waits for it, a placeholder. if (s.ops != null and bytes == null and s.path.len > 0) _ = cl.refused.print("{s} is not here", .{s.path}) else if (s.ops) |ops| { const path_z = s.arena.allocator().dupeSentinel(u8, s.path, 0) catch ""; + // (the budget's from here: the file's hash and the tag are the core's) + if (checked) cl.began = @import("FrameStats.zig").nowNs(); cl.opening = true; if (ops.open) |f| s.st = f(if (s.path.len > 0) path_z.ptr else null, if (bytes) |b| b.ptr else null, if (bytes) |b| b.len else 0); cl.opening = false; @@ -917,7 +919,8 @@ const Call = struct { return o; } }; -var current: ?*Call = null; +/// (The loop's: a job on a worker is in none.) +threadlocal var current: ?*Call = null; /// A call's budget, in Debug: a frame (17.4; 2 ms in ReleaseFast, which /// Debug's kinds run three to four times slower than). @@ -1052,6 +1055,12 @@ pub const api: c.pa_api = .{ .heap = struct { /// `heap`'s, any thread: realloc's, n 0 a free. fn f(ptr: ?*anyopaque, n: usize) callconv(.c) ?*anyopaque { + // Its time the core's, as an arena's is (a region's first + // allocation in Debug took 23 ms of a PDF's open). + const t0 = if (checked) @import("FrameStats.zig").nowNs(); + defer if (checked) if (current) |cl| { + cl.began += @import("FrameStats.zig").nowNs() -| t0; + }; if (n == 0) { kind_heap.free(ptr); return null; |
