mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-05 07:08:39 +00:00
terminal/snapshot: gate page verification on slow runtime safety
PAGE decoding verified the complete native integrity of every decoded page unconditionally, building per-cell reference maps that accounted for roughly a fifth of decode time. The decoder normalizes every semantic value while decoding, so a completed decode upholds page invariants by construction and the verification only defends against decoder bugs. Follow the native page policy instead: assertIntegrity and friends run full verification only when slow runtime safety is enabled, which keeps the check in debug and test builds where those bugs are caught. Benchmark deltas at this commit (terminal-snapshot, 1 MB corpora): ascii lines 1-70: decode 15.5 -> 12.2 ms (encode unchanged)
This commit is contained in:
@@ -93,6 +93,7 @@
|
||||
//! Rows and cells use the grid encoding documented in `grid.zig`.
|
||||
|
||||
const std = @import("std");
|
||||
const build_options = @import("terminal_options");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const test_fixture = @import("fixture.zig");
|
||||
const grid = @import("grid.zig");
|
||||
@@ -227,7 +228,15 @@ pub const Decoder = struct {
|
||||
self.header,
|
||||
);
|
||||
try self.record_reader.finish();
|
||||
try destination.verifyIntegrity(alloc);
|
||||
|
||||
// The decoder normalizes every semantic value, so a complete decode
|
||||
// upholds native page invariants by construction. Verifying them
|
||||
// again is a defense against decoder bugs and follows the native
|
||||
// page policy: full integrity verification only when slow runtime
|
||||
// safety is enabled.
|
||||
if (comptime build_options.slow_runtime_safety) {
|
||||
try destination.verifyIntegrity(alloc);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user