authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-27 22:36:56-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-29 14:25:04-07:00
log3d7ae63c6f0b01456a411b31bad2322166634868
treefb935efa944c6c78b79c3b52dcf677381536dba3
parent4e61af404e87d76d1428dd46f85f08afe4ad4a93

stage2: remove c_object_cache_digest_set

This logic was a workaround to prevent cache deadlocks which happened from always using exclusive file locks. Now that the Cache system supports sharing cached artifacts, this workaround is no longer needed. Closes #7596

1 files changed, 0 insertions(+), 22 deletions(-)

src/Compilation.zig-22
...@@ -39,7 +39,6 @@ gpa: *Allocator,...@@ -39,7 +39,6 @@ gpa: *Allocator,
39arena_state: std.heap.ArenaAllocator.State,39arena_state: std.heap.ArenaAllocator.State,
40bin_file: *link.File,40bin_file: *link.File,
41c_object_table: std.AutoArrayHashMapUnmanaged(*CObject, void) = .{},41c_object_table: std.AutoArrayHashMapUnmanaged(*CObject, void) = .{},
42c_object_cache_digest_set: std.AutoHashMapUnmanaged(Cache.BinDigest, void) = .{},
43stage1_lock: ?Cache.Lock = null,42stage1_lock: ?Cache.Lock = null,
44stage1_cache_manifest: *Cache.Manifest = undefined,43stage1_cache_manifest: *Cache.Manifest = undefined,
4544
...@@ -1590,7 +1589,6 @@ pub fn destroy(self: *Compilation) void {...@@ -1590,7 +1589,6 @@ pub fn destroy(self: *Compilation) void {
1590 key.destroy(gpa);1589 key.destroy(gpa);
1591 }1590 }
1592 self.c_object_table.deinit(gpa);1591 self.c_object_table.deinit(gpa);
1593 self.c_object_cache_digest_set.deinit(gpa);
15941592
1595 for (self.failed_c_objects.values()) |value| {1593 for (self.failed_c_objects.values()) |value| {
1596 value.destroy(gpa);1594 value.destroy(gpa);
...@@ -1627,7 +1625,6 @@ pub fn update(self: *Compilation) !void {...@@ -1627,7 +1625,6 @@ pub fn update(self: *Compilation) !void {
1627 defer tracy.end();1625 defer tracy.end();
16281626
1629 self.clearMiscFailures();1627 self.clearMiscFailures();
1630 self.c_object_cache_digest_set.clearRetainingCapacity();
16311628
1632 // For compiling C objects, we rely on the cache hash system to avoid duplicating work.1629 // For compiling C objects, we rely on the cache hash system to avoid duplicating work.
1633 // Add a Job for each C object.1630 // Add a Job for each C object.
...@@ -2615,25 +2612,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P...@@ -2615,25 +2612,6 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P
26152612
2616 try man.hashCSource(c_object.src);2613 try man.hashCSource(c_object.src);
26172614
2618 {
2619 const is_collision = blk: {
2620 const bin_digest = man.hash.peekBin();
2621
2622 const lock = comp.mutex.acquire();
2623 defer lock.release();
2624
2625 const gop = try comp.c_object_cache_digest_set.getOrPut(comp.gpa, bin_digest);
2626 break :blk gop.found_existing;
2627 };
2628 if (is_collision) {
2629 return comp.failCObj(
2630 c_object,
2631 "the same source file was already added to the same compilation with the same flags",
2632 .{},
2633 );
2634 }
2635 }
2636
2637 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);2615 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
2638 defer arena_allocator.deinit();2616 defer arena_allocator.deinit();
2639 const arena = &arena_allocator.allocator;2617 const arena = &arena_allocator.allocator;