aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-30 20:23:51 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:57 -0700
commit82f6f164a1af6557451e580dcf3197ad94e5437e (patch)
tree6a88050cac9da741c2ae8434ef0fe2989c411ee5 /src/value.zig
parentc7d65fa3685a5f48cfedaa7a1adf758e1dc6d219 (diff)
downloadzig-82f6f164a1af6557451e580dcf3197ad94e5437e.tar.gz
zig-82f6f164a1af6557451e580dcf3197ad94e5437e.zip
InternPool: improve hashing performance
Key.PtrType is now an extern struct so that hashing it can be done by reinterpreting bytes directly. It also uses the same representation for type_pointer Tag encoding and the Key. Accessing pointer attributes now requires packed struct access, however, many operations are now a copy of a u32 rather than several independent fields. This function moves the top two most used Key variants - pointer types and pointer values - to use a single-shot hash function that branches for small keys instead of calling memcpy. As a result, perf against merge-base went from 1.17x ± 0.04 slower to 1.12x ± 0.04 slower. After the pointer value hashing was changed, total CPU instructions spent in memcpy went from 4.40% to 4.08%, and after additionally improving pointer type hashing, it further decreased to 3.72%.
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/value.zig b/src/value.zig
index 92dd3a3c3f..fe6a15154c 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -2080,8 +2080,8 @@ pub const Value = struct {
else => val,
};
var ptr_ty_key = mod.intern_pool.indexToKey(elem_ptr_ty.toIntern()).ptr_type;
- assert(ptr_ty_key.size != .Slice);
- ptr_ty_key.size = .Many;
+ assert(ptr_ty_key.flags.size != .Slice);
+ ptr_ty_key.flags.size = .Many;
return (try mod.intern(.{ .ptr = .{
.ty = elem_ptr_ty.toIntern(),
.addr = .{ .elem = .{