authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-04 18:48:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-11-04 18:48:08-07:00
log9e81222d9281f8d26e32578fe3cef54e0c7d5232
treea815f901a46916c8b3b1e5c833395229159e44b9
parent88acdb9aa6cdb8ea20e02c4d0f85be81f696897c

zig reduce: some adjustments to make it go faster

* don't reset the rng. it seems like it was getting stuck trying the same transforms over and over again. * slide the window over after failing a large transform set, idea being that transformations in the failed set are more likely to be problematic.

1 files changed, 9 insertions(+), 4 deletions(-)

src/reduce.zig+9-4
......@@ -166,7 +166,10 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
166166 var start_index: usize = 0;
167167
168168 while (start_index < transformations.items.len) {
169 subset_size = @max(1, subset_size / 2);
169 const prev_subset_size = subset_size;
170 subset_size = @max(1, subset_size * 3 / 4);
171 if (prev_subset_size > 1 and subset_size == 1)
172 start_index = 0;
170173
171174 const this_set = transformations.items[start_index..][0..subset_size];
172175 std.debug.print("trying {d} random transformations: ", .{subset_size});
......@@ -237,9 +240,6 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
237240 tree = new_tree;
238241
239242 try Walk.findTransformations(arena, &tree, &transformations);
240 // Resetting based on the seed again means we will get the same
241 // results if restarting the reduction process from this new point.
242 rng = std.rand.DefaultPrng.init(seed);
243243 sortTransformations(transformations.items, rng.random());
244244
245245 continue :fresh;
......@@ -249,6 +249,11 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
249249 // If we tested only one transformation, move on to the next one.
250250 if (subset_size == 1) {
251251 start_index += 1;
252 } else {
253 start_index += subset_size;
254 if (start_index + subset_size > transformations.items.len) {
255 start_index = 0;
256 }
252257 }
253258 },
254259 }