-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.zig
More file actions
173 lines (153 loc) · 7.62 KB
/
build.zig
File metadata and controls
173 lines (153 loc) · 7.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// ========================================================================
// LIBRARY MODULE
// ========================================================================
const ringmpsc_mod = b.addModule("ringmpsc", .{
.root_source_file = b.path("src/ringmpsc.zig"),
.target = target,
.optimize = optimize,
});
// Benchmarks need the library compiled with ReleaseFast regardless of
// the user-selected optimize mode, otherwise the hot-path ring buffer
// code runs unoptimised and benchmarks are ~50,000x slower.
const ringmpsc_fast = b.addModule("ringmpsc_fast", .{
.root_source_file = b.path("src/ringmpsc.zig"),
.target = target,
.optimize = .ReleaseFast,
});
// ========================================================================
// UNIT TESTS
// ========================================================================
const test_mod = b.createModule(.{
.root_source_file = b.path("src/ringmpsc.zig"),
.target = target,
.optimize = optimize,
});
const unit_tests = b.addTest(.{
.root_module = test_mod,
});
const run_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests.step);
// ========================================================================
// INTEGRATION TESTS
// ========================================================================
inline for (.{
.{ "test-spsc", "tests/spsc_test.zig", "Run SPSC integration tests" },
.{ "test-mpsc", "tests/mpsc_test.zig", "Run MPSC integration tests" },
.{ "test-fifo", "tests/fifo_test.zig", "Run FIFO ordering tests" },
.{ "test-chaos", "tests/chaos_test.zig", "Run chaos/concurrency tests" },
.{ "test-determinism", "tests/determinism_test.zig", "Run determinism tests" },
.{ "test-fuzz", "tests/fuzz_test.zig", "Run fuzz tests" },
.{ "test-mpmc", "tests/mpmc_test.zig", "Run MPMC tests" },
.{ "test-spmc", "tests/spmc_test.zig", "Run SPMC tests" },
.{ "test-simd", "tests/simd_test.zig", "Run SIMD tests" },
.{ "test-blocking", "tests/blocking_test.zig", "Run blocking/wait strategy tests" },
.{ "test-wraparound", "tests/wraparound_test.zig", "Run u64 wraparound tests" },
}) |entry| {
const exe = b.addExecutable(.{
.name = entry[0],
.root_module = b.createModule(.{
.root_source_file = b.path(entry[1]),
.target = target,
.optimize = .ReleaseFast,
.imports = &.{.{ .name = "ringmpsc", .module = ringmpsc_fast }},
}),
});
const run = b.addRunArtifact(exe);
const step = b.step(entry[0], entry[2]);
step.dependOn(&run.step);
}
// stress_test.zig uses Zig test blocks (no main), so it needs addTest
{
const stress_mod = b.createModule(.{
.root_source_file = b.path("tests/stress_test.zig"),
.target = target,
.optimize = .ReleaseFast,
.imports = &.{.{ .name = "ringmpsc", .module = ringmpsc_fast }},
});
const stress_tests = b.addTest(.{ .root_module = stress_mod });
const run_stress = b.addRunArtifact(stress_tests);
const stress_step = b.step("test-stress", "Run stress tests");
stress_step.dependOn(&run_stress.step);
}
// ========================================================================
// BENCHMARKS
// ========================================================================
inline for (.{
.{ "bench-high-perf", "benchmarks/src/high_perf.zig", "Run high performance MPSC benchmark" },
.{ "bench-mpsc", "benchmarks/src/mpsc.zig", "Run MPSC throughput benchmark" },
.{ "bench-spsc", "benchmarks/src/spsc.zig", "Run SPSC latency benchmark" },
.{ "bench-simd", "benchmarks/src/simd_bench.zig", "Run SIMD performance benchmarks" },
.{ "bench-analysis", "benchmarks/src/analysis.zig", "Run bottleneck analysis" },
.{ "bench-cross-process", "benchmarks/src/cross_process.zig", "SharedRing vs in-process Ring" },
.{ "bench-zero-copy", "benchmarks/src/zero_copy.zig", "BufferPool zero-copy vs inline copy" },
.{ "bench-wake-latency", "benchmarks/src/wake_latency.zig", "Spin vs futex vs eventfd wake latency" },
}) |entry| {
const exe = b.addExecutable(.{
.name = entry[0],
.root_module = b.createModule(.{
.root_source_file = b.path(entry[1]),
.target = target,
.optimize = .ReleaseFast,
.imports = &.{.{ .name = "ringmpsc", .module = ringmpsc_fast }},
}),
});
const install = b.addInstallArtifact(exe, .{});
const run = b.addRunArtifact(exe);
run.step.dependOn(&install.step);
const step = b.step(entry[0], entry[2]);
step.dependOn(&run.step);
}
// Bench suite and full bench import report.zig as a file dependency
inline for (.{
.{ "bench-suite", "benchmarks/src/suite.zig", "Run full benchmark suite" },
.{ "bench", "benchmarks/src/bench.zig", "Run benchmark suite with multi-run statistics and HTML report" },
}) |entry| {
const exe = b.addExecutable(.{
.name = entry[0],
.root_module = b.createModule(.{
.root_source_file = b.path(entry[1]),
.target = target,
.optimize = .ReleaseFast,
.imports = &.{.{ .name = "ringmpsc", .module = ringmpsc_fast }},
}),
});
const install = b.addInstallArtifact(exe, .{});
const run = b.addRunArtifact(exe);
run.step.dependOn(&install.step);
const step = b.step(entry[0], entry[2]);
step.dependOn(&run.step);
}
// ========================================================================
// EXAMPLES
// ========================================================================
inline for (.{
.{ "example-basic", "examples/basic.zig", "Run basic SPSC example" },
.{ "example-mpsc", "examples/mpsc_pipeline.zig", "Run MPSC pipeline example" },
.{ "example-backpressure", "examples/backpressure.zig", "Run backpressure example" },
.{ "example-shutdown", "examples/graceful_shutdown.zig", "Run graceful shutdown example" },
.{ "example-event-loop", "examples/event_loop.zig", "Run event loop example" },
.{ "example-event-notifier", "examples/event_notifier.zig", "Run eventfd + epoll example" },
.{ "example-zero-copy", "examples/zero_copy.zig", "Run zero-copy BufferPool example" },
.{ "example-shared-memory", "examples/shared_memory.zig", "Run cross-process shared memory example" },
.{ "example-cross-process", "examples/cross_process.zig", "Run full cross-process IPC with fd passing" },
.{ "example-logging", "examples/logging_pipeline.zig", "Run structured logging pipeline example" },
}) |entry| {
const exe = b.addExecutable(.{
.name = entry[0],
.root_module = b.createModule(.{
.root_source_file = b.path(entry[1]),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "ringmpsc", .module = ringmpsc_mod }},
}),
});
const run = b.addRunArtifact(exe);
const step = b.step(entry[0], entry[2]);
step.dependOn(&run.step);
}
}