authorgravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2025-11-03 18:37:47-05:00
committergravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2026-02-13 17:58:09-05:00
log1a9d75ebe0037bd908ed263bb7f4228f9a8681ef
tree5570585f73d01633a9100c557da8bd166ec56fee
parentaf1e196db3bca66c29979c685b1c9c896c275211

fix fuzzing speed with prior runs


3 files changed, 8 insertions(+), 1 deletions(-)

lib/build-web/fuzz.zig+3-1
......@@ -1,5 +1,6 @@
11// Server timestamp.
22var start_fuzzing_timestamp: i64 = undefined;
3var start_fuzzing_n_runs: u64 = undefined;
34
45const js = struct {
56 extern "fuzz" fn requestSources() void;
......@@ -36,6 +37,7 @@ pub fn sourceIndexMessage(msg_bytes: []u8) error{OutOfMemory}!void {
3637 const source_locations: []const Coverage.SourceLocation = @alignCast(std.mem.bytesAsSlice(Coverage.SourceLocation, msg_bytes[source_locations_start..source_locations_end]));
3738
3839 start_fuzzing_timestamp = header.start_timestamp;
40 start_fuzzing_n_runs = header.start_n_runs;
3941 try updateCoverageSources(directories, files, source_locations, string_bytes);
4042 js.ready();
4143}
......@@ -271,7 +273,7 @@ fn updateStats() error{OutOfMemory}!void {
271273
272274 const avg_speed: f64 = speed: {
273275 const ns_elapsed: f64 = @floatFromInt(nsSince(start_fuzzing_timestamp));
274 const n_runs: f64 = @floatFromInt(hdr.n_runs);
276 const n_runs: f64 = @floatFromInt(hdr.n_runs -% start_fuzzing_n_runs);
275277 break :speed n_runs / (ns_elapsed / std.time.ns_per_s);
276278 };
277279
lib/std/Build/Fuzz.zig+4
......@@ -64,6 +64,7 @@ const CoverageMap = struct {
6464 /// Elements are indexes into `source_locations` pointing to the unit tests that are being fuzz tested.
6565 entry_points: std.ArrayList(u32),
6666 start_timestamp: i64,
67 start_n_runs: u64,
6768
6869 fn deinit(cm: *CoverageMap, gpa: Allocator) void {
6970 std.posix.munmap(cm.mapped_memory);
......@@ -299,6 +300,7 @@ pub fn sendUpdate(
299300 .source_locations_len = @intCast(coverage_map.source_locations.len),
300301 .string_bytes_len = @intCast(coverage_map.coverage.string_bytes.items.len),
301302 .start_timestamp = coverage_map.start_timestamp,
303 .start_n_runs = coverage_map.start_n_runs,
302304 };
303305 var iovecs: [5][]const u8 = .{
304306 @ptrCast(&header),
......@@ -390,6 +392,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO
390392 .source_locations = undefined, // populated below
391393 .entry_points = .{},
392394 .start_timestamp = ws.now(),
395 .start_n_runs = undefined, // populated below
393396 };
394397 errdefer gop.value_ptr.coverage.deinit(gpa);
395398
......@@ -467,6 +470,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO
467470
468471 for (sorted_pcs.items(.index), sorted_pcs.items(.sl)) |i, sl| source_locations[i] = sl;
469472 gop.value_ptr.source_locations = source_locations;
473 gop.value_ptr.start_n_runs = header.n_runs;
470474
471475 ws.notifyUpdate();
472476}
lib/std/Build/abi.zig+1
......@@ -219,6 +219,7 @@ pub const fuzz = struct {
219219 string_bytes_len: u32,
220220 /// When, according to the server, fuzzing started.
221221 start_timestamp: i64 align(4),
222 start_n_runs: u64 align(4),
222223 };
223224
224225 /// WebSocket server->client.