@@ -904,33 +904,33 @@ pub const SourceLocation = struct {
904904
905905** Benchmark 1 (3 runs)** : ` glibc/bin/zig build -Dno-lib -p trash`
906906
907- | Measurement | Mean ± σ | Min … Max | Outliers | Delta |
908- | -------------------- | ------------------ | ------------------- | ---------- | ------- |
909- | Wall Time | 12.2s ± 99.4ms | 12.1s … 12.3s | 0 (0%) | 0% |
910- | Peak RSS | 975MB ± 21.7MB | 951MB … 993MB | 0 (0%) | 0% |
911- | CPU Cycles | 88.7G ± 68.3M | 88.7G … 88.8G | 0 (0%) | 0% |
912- | Instructions | 188G ± 1.40M | 188G … 188G | 0 (0%) | 0% |
913- | Cache References | 5.88G ± 33.2M | 5.84G … 5.90G | 0 (0%) | 0% |
914- | Cache Misses | 383M ± 2.26M | 381M … 385M | 0 (0%) | 0% |
915- | Branch Misses | 368M ± 1.77M | 366M … 369M | 0 (0%) | 0% |
907+ | Measurement | Mean ± σ | Min … Max | Outliers | Delta |
908+ | ---------------- | -------------- | ------------- | -------- | ----- |
909+ | Wall Time | 12.2s ± 99.4ms | 12.1s … 12.3s | 0 (0%) | 0% |
910+ | Peak RSS | 975MB ± 21.7MB | 951MB … 993MB | 0 (0%) | 0% |
911+ | CPU Cycles | 88.7G ± 68.3M | 88.7G … 88.8G | 0 (0%) | 0% |
912+ | Instructions | 188G ± 1.40M | 188G … 188G | 0 (0%) | 0% |
913+ | Cache References | 5.88G ± 33.2M | 5.84G … 5.90G | 0 (0%) | 0% |
914+ | Cache Misses | 383M ± 2.26M | 381M … 385M | 0 (0%) | 0% |
915+ | Branch Misses | 368M ± 1.77M | 366M … 369M | 0 (0%) | 0% |
916916
917917** Benchmark 2 (3 runs)** : ` SmpAllocator/fast/bin/zig build -Dno-lib -p trash`
918918
919- | Measurement | Mean ± σ | Min … Max | Outliers | Delta |
920- | -------------------- | ------------------ | ------------------- | ---------- | ---------------------- |
921- | Wall Time | 12.2s ± 49.0ms | 12.2s … 12.3s | 0 (0%) | + 0.0% ± 1.5% |
922- | Peak RSS | 953MB ± 3.47MB | 950MB … 957MB | 0 (0%) | - 2.2% ± 3.6% |
923- | CPU Cycles | 88.4G ± 165M | 88.2G … 88.6G | 0 (0%) | - 0.4% ± 0.3% |
924- | Instructions | 181G ± 6.31M | 181G … 181G | 0 (0%) | ⚡- 3.9% ± 0.0% |
925- | Cache References | 5.48G ± 17.5M | 5.46G … 5.50G | 0 (0%) | ⚡- 6.9% ± 1.0% |
926- | Cache Misses | 386M ± 1.85M | 384M … 388M | 0 (0%) | + 0.6% ± 1.2% |
927- | Branch Misses | 377M ± 899K | 377M … 378M | 0 (0%) | 💩+ 2.6% ± 0.9% |
919+ | Measurement | Mean ± σ | Min … Max | Outliers | Delta |
920+ | ---------------- | -------------- | ------------- | -------- | --------------- |
921+ | Wall Time | 12.2s ± 49.0ms | 12.2s … 12.3s | 0 (0%) | + 0.0% ± 1.5% |
922+ | Peak RSS | 953MB ± 3.47MB | 950MB … 957MB | 0 (0%) | - 2.2% ± 3.6% |
923+ | CPU Cycles | 88.4G ± 165M | 88.2G … 88.6G | 0 (0%) | - 0.4% ± 0.3% |
924+ | Instructions | 181G ± 6.31M | 181G … 181G | 0 (0%) | ⚡- 3.9% ± 0.0% |
925+ | Cache References | 5.48G ± 17.5M | 5.46G … 5.50G | 0 (0%) | ⚡- 6.9% ± 1.0% |
926+ | Cache Misses | 386M ± 1.85M | 384M … 388M | 0 (0%) | + 0.6% ± 1.2% |
927+ | Branch Misses | 377M ± 899K | 377M … 378M | 0 (0%) | 💩+ 2.6% ± 0.9% |
928928
929929设计思路:
930930
931931每个线程都有一个单独的空闲列表,但是,当线程退出时,数据必须是可恢复的。我们不会直接知道线程何时退出,因此有时一个线程必须尝试回收另一个线程的资源。
932932
933- 超过一定大小的分配直接进行内存映射,不存储分配元数据。这是可行的,因为这个分配器实现拒绝 resize(将从小的 buffer 移动到大的 buffer或反过来的行为 )。
933+ 超过一定大小的分配直接进行内存映射,不存储分配元数据。这是可行的,因为这个分配器实现拒绝 resize(将从小的 buffer 移动到大的 buffer 或反过来的行为 )。
934934
935935每个分配器操作从线程局部变量检查线程标识符,以确定访问全局状态中的哪个元数据,并尝试获取其锁。这通常会在没有争用的情况下成功,除非另一个线程被分配了相同的 ID。在这种争用的情况下,线程会移动到下一个线程元数据槽,并重复尝试获取锁的过程。
936936
@@ -957,7 +957,7 @@ pub fn main() !void {
957957
958958更多的信息可以看开发日志 [No-Libc Zig Now Outperforms Glibc Zig](https://ziglang.org/devlog/2025/# 2025-02-07)。
959959
960- # ## Allocator API 变动 (remap)
960+ # ## Allocator API 变动 (remap)
961961
962962此版本在 ` std.mem.Allocator.VTable` 中引入了一个新函数 ` remap` 。
963963
@@ -1068,15 +1068,15 @@ try child.collectOutput(allocator, &stdout, &stderr, max_output_bytes);
10681068
10691069Zig 是为数不多的直接生成 LLVM 位代码的编译器之一,而不是依赖于具有不稳定 API 且非常庞大的 libLLVM。这是我们努力完全消除 Zig 中 LLVM 依赖的一部分([# 16270](https://github.com/ziglang/zig/issues/16270))。Roc 项目最近[决定](https://gist.github.com/rtfeldman/77fb430ee57b42f5f2ca973a3992532f)用 Zig 重写他们的编译器,部分原因是能够重用 Zig 的 LLVM 位代码构建器。为了使这一过程更加容易,我们决定将构建器 API 移动到 `std.zig.llvm` 以供第三方项目使用。请注意,与 `std.zig` 命名空间中的内容一样,这是 Zig 编译器的实现细节,不一定遵循与标准库其他部分相同的 API 稳定性和弃用规范。
10701070
1071- # ## 拥抱 “Unmanaged” 风格的容器
1071+ # ## 拥抱“Unmanaged”风格的容器
10721072
10731073` std.ArrayHashMap` 现在已被弃用,并别名到了 ` std.ArrayHashMapWithAllocator` 。
10741074
10751075要迁移代码,请切换到 ` ArrayHashMapUnmanaged` ,这将需要更新函数调用以向需要分配器的方法传递一个分配器。在 Zig ` 0.14.0` 发布后,` std.ArrayHashMapWithAllocator` 将被移除,` std.ArrayHashMapUnmanaged` 将成为 ` ArrayHashMap` 的弃用别名。在 Zig ` 0.15.0` 发布后,弃用的别名 ` ArrayHashMapUnmanaged` 将被移除。
10761076
1077- 这一举措来自于资深 Zig 用户的一致意见,他们已经趋向于使用 “Unmanaged” 容器。它们作为更好的构建块,避免了冗余存储相同的数据,并且分配器参数的存在 / 不存在与保留容量 / 保留插入模式很好地契合。
1077+ 这一举措来自于资深 Zig 用户的一致意见,他们已经趋向于使用“Unmanaged”容器。它们作为更好的构建块,避免了冗余存储相同的数据,并且分配器参数的存在 / 不存在与保留容量 / 保留插入模式很好地契合。
10781078
1079- 其他 “Unmanaged” 容器的派生也被弃用,例如 ` std.ArrayList` 。
1079+ 其他“Unmanaged”容器的派生也被弃用,例如 ` std.ArrayList` 。
10801080
10811081` ` ` zig
10821082var list = std.ArrayList(i32).init(gpa);
@@ -1359,7 +1359,7 @@ const std = @import("std");
13591359
13601360此功能的一个用例是让依赖项向其依赖包暴露一个生成的文件。例如,在以下示例中,依赖包 bar 暴露了一个生成的 Zig 文件,主包将其用作可执行文件的模块导入:
13611361
1362- *** build.zig * **
1362+ ** _build.zig_ **
13631363
13641364` ` ` zig
13651365pub fn build(b: * std.Build) void {
@@ -1377,7 +1377,7 @@ pub fn build(b: *std.Build) void {
13771377}
13781378` ` `
13791379
1380- *** bar /build.zig * **
1380+ ** _bar /build.zig_ **
13811381
13821382` ` ` zig
13831383pub fn build(b: * std.Build) {
@@ -1418,4 +1418,3 @@ const dep_foo_bar = b.dependency("foo_bar", .{
14181418
14191419mod.linkLibrary(dep_foor_bar.artifact(" foo_bar" ));
14201420` ` `
1421-
0 commit comments