@@ -904,33 +904,33 @@ pub const SourceLocation = struct {
904
904
905
905
** Benchmark 1 (3 runs)** : ` glibc/bin/zig build -Dno-lib -p trash`
906
906
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% |
916
916
917
917
** Benchmark 2 (3 runs)** : ` SmpAllocator/fast/bin/zig build -Dno-lib -p trash`
918
918
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% |
928
928
929
929
设计思路:
930
930
931
931
每个线程都有一个单独的空闲列表,但是,当线程退出时,数据必须是可恢复的。我们不会直接知道线程何时退出,因此有时一个线程必须尝试回收另一个线程的资源。
932
932
933
- 超过一定大小的分配直接进行内存映射,不存储分配元数据。这是可行的,因为这个分配器实现拒绝 resize(将从小的 buffer 移动到大的 buffer或反过来的行为 )。
933
+ 超过一定大小的分配直接进行内存映射,不存储分配元数据。这是可行的,因为这个分配器实现拒绝 resize(将从小的 buffer 移动到大的 buffer 或反过来的行为 )。
934
934
935
935
每个分配器操作从线程局部变量检查线程标识符,以确定访问全局状态中的哪个元数据,并尝试获取其锁。这通常会在没有争用的情况下成功,除非另一个线程被分配了相同的 ID。在这种争用的情况下,线程会移动到下一个线程元数据槽,并重复尝试获取锁的过程。
936
936
@@ -957,7 +957,7 @@ pub fn main() !void {
957
957
958
958
更多的信息可以看开发日志 [No-Libc Zig Now Outperforms Glibc Zig](https://ziglang.org/devlog/2025/# 2025-02-07)。
959
959
960
- # ## Allocator API 变动 (remap)
960
+ # ## Allocator API 变动 (remap)
961
961
962
962
此版本在 ` std.mem.Allocator.VTable` 中引入了一个新函数 ` remap` 。
963
963
@@ -1068,15 +1068,15 @@ try child.collectOutput(allocator, &stdout, &stderr, max_output_bytes);
1068
1068
1069
1069
Zig 是为数不多的直接生成 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 稳定性和弃用规范。
1070
1070
1071
- # ## 拥抱 “Unmanaged” 风格的容器
1071
+ # ## 拥抱“Unmanaged”风格的容器
1072
1072
1073
1073
` std.ArrayHashMap` 现在已被弃用,并别名到了 ` std.ArrayHashMapWithAllocator` 。
1074
1074
1075
1075
要迁移代码,请切换到 ` ArrayHashMapUnmanaged` ,这将需要更新函数调用以向需要分配器的方法传递一个分配器。在 Zig ` 0.14.0` 发布后,` std.ArrayHashMapWithAllocator` 将被移除,` std.ArrayHashMapUnmanaged` 将成为 ` ArrayHashMap` 的弃用别名。在 Zig ` 0.15.0` 发布后,弃用的别名 ` ArrayHashMapUnmanaged` 将被移除。
1076
1076
1077
- 这一举措来自于资深 Zig 用户的一致意见,他们已经趋向于使用 “Unmanaged” 容器。它们作为更好的构建块,避免了冗余存储相同的数据,并且分配器参数的存在 / 不存在与保留容量 / 保留插入模式很好地契合。
1077
+ 这一举措来自于资深 Zig 用户的一致意见,他们已经趋向于使用“Unmanaged”容器。它们作为更好的构建块,避免了冗余存储相同的数据,并且分配器参数的存在 / 不存在与保留容量 / 保留插入模式很好地契合。
1078
1078
1079
- 其他 “Unmanaged” 容器的派生也被弃用,例如 ` std.ArrayList` 。
1079
+ 其他“Unmanaged”容器的派生也被弃用,例如 ` std.ArrayList` 。
1080
1080
1081
1081
` ` ` zig
1082
1082
var list = std.ArrayList(i32).init(gpa);
@@ -1359,7 +1359,7 @@ const std = @import("std");
1359
1359
1360
1360
此功能的一个用例是让依赖项向其依赖包暴露一个生成的文件。例如,在以下示例中,依赖包 bar 暴露了一个生成的 Zig 文件,主包将其用作可执行文件的模块导入:
1361
1361
1362
- *** build.zig * **
1362
+ ** _build.zig_ **
1363
1363
1364
1364
` ` ` zig
1365
1365
pub fn build(b: * std.Build) void {
@@ -1377,7 +1377,7 @@ pub fn build(b: *std.Build) void {
1377
1377
}
1378
1378
` ` `
1379
1379
1380
- *** bar /build.zig * **
1380
+ ** _bar /build.zig_ **
1381
1381
1382
1382
` ` ` zig
1383
1383
pub fn build(b: * std.Build) {
@@ -1418,4 +1418,3 @@ const dep_foo_bar = b.dependency("foo_bar", .{
1418
1418
1419
1419
mod.linkLibrary(dep_foor_bar.artifact(" foo_bar" ));
1420
1420
` ` `
1421
-
0 commit comments