mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
fix fuzzing speed with prior runs
This commit is contained in:
parent
1444e5c5a2
commit
0dbbb93dbe
3 changed files with 8 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// Server timestamp.
|
||||
var start_fuzzing_timestamp: i64 = undefined;
|
||||
var start_fuzzing_n_runs: u64 = undefined;
|
||||
|
||||
const js = struct {
|
||||
extern "fuzz" fn requestSources() void;
|
||||
|
|
@ -36,6 +37,7 @@ pub fn sourceIndexMessage(msg_bytes: []u8) error{OutOfMemory}!void {
|
|||
const source_locations: []const Coverage.SourceLocation = @alignCast(std.mem.bytesAsSlice(Coverage.SourceLocation, msg_bytes[source_locations_start..source_locations_end]));
|
||||
|
||||
start_fuzzing_timestamp = header.start_timestamp;
|
||||
start_fuzzing_n_runs = header.start_n_runs;
|
||||
try updateCoverageSources(directories, files, source_locations, string_bytes);
|
||||
js.ready();
|
||||
}
|
||||
|
|
@ -271,7 +273,7 @@ fn updateStats() error{OutOfMemory}!void {
|
|||
|
||||
const avg_speed: f64 = speed: {
|
||||
const ns_elapsed: f64 = @floatFromInt(nsSince(start_fuzzing_timestamp));
|
||||
const n_runs: f64 = @floatFromInt(hdr.n_runs);
|
||||
const n_runs: f64 = @floatFromInt(hdr.n_runs -% start_fuzzing_n_runs);
|
||||
break :speed n_runs / (ns_elapsed / std.time.ns_per_s);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ const CoverageMap = struct {
|
|||
/// Elements are indexes into `source_locations` pointing to the unit tests that are being fuzz tested.
|
||||
entry_points: std.ArrayList(u32),
|
||||
start_timestamp: i64,
|
||||
start_n_runs: u64,
|
||||
|
||||
fn deinit(cm: *CoverageMap, gpa: Allocator) void {
|
||||
std.posix.munmap(cm.mapped_memory);
|
||||
|
|
@ -318,6 +319,7 @@ pub fn sendUpdate(
|
|||
.source_locations_len = @intCast(coverage_map.source_locations.len),
|
||||
.string_bytes_len = @intCast(coverage_map.coverage.string_bytes.items.len),
|
||||
.start_timestamp = coverage_map.start_timestamp,
|
||||
.start_n_runs = coverage_map.start_n_runs,
|
||||
};
|
||||
var iovecs: [5][]const u8 = .{
|
||||
@ptrCast(&header),
|
||||
|
|
@ -399,6 +401,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO
|
|||
.source_locations = undefined, // populated below
|
||||
.entry_points = .{},
|
||||
.start_timestamp = ws.now(),
|
||||
.start_n_runs = undefined, // populated below
|
||||
};
|
||||
errdefer gop.value_ptr.coverage.deinit(fuzz.gpa);
|
||||
|
||||
|
|
@ -475,6 +478,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO
|
|||
|
||||
for (sorted_pcs.items(.index), sorted_pcs.items(.sl)) |i, sl| source_locations[i] = sl;
|
||||
gop.value_ptr.source_locations = source_locations;
|
||||
gop.value_ptr.start_n_runs = header.n_runs;
|
||||
|
||||
ws.notifyUpdate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ pub const fuzz = struct {
|
|||
string_bytes_len: u32,
|
||||
/// When, according to the server, fuzzing started.
|
||||
start_timestamp: i64 align(4),
|
||||
start_n_runs: u64 align(4),
|
||||
};
|
||||
|
||||
/// WebSocket server->client.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue