Skip to content

Commit f8101fe

Browse files
committed
chore(#191): gitignore profiling artifacts, shrink verifier stack, document profiling
- .gitignore: perf.data*, sizecheck, and the built go-embed example binary - chunk_verifier: func_ips as [4096]u32 (16KB stack instead of 32KB on 64-bit; ips are bounded by MaxCode = 1 MiB) - CONTRIBUTING: profiling recipe — --call-graph dwarf is required for trustworthy call graphs on the ReleaseFast binary (frame-pointer unwinding misattributes inlined frames), plus pointers to -Dperf counters, gc_stats_ext, and the bench baselines
1 parent b98e8e0 commit f8101fe

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ gengo_acl.so
2222
site/
2323
examples/bundle-c/quiz_grader
2424
examples/bundle-c/scoring.zip
25+
26+
# Profiling and local analysis artifacts
27+
perf.data*
28+
sizecheck
29+
examples/go-embed/go-embed

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ make parity
4444

4545
`parity` checks that the native and WASM backends produce the same output. Run it when touching the VM or compiler.
4646

47+
## Profiling
48+
49+
Build the timing binary and profile with DWARF call graphs:
50+
51+
```bash
52+
zig build -Dpreset=1m cli-fast
53+
perf record --call-graph dwarf -F 999 -- ./zig-out/bin/gengo-fast tests/bench/007_dispatch_loop.gengo
54+
perf report
55+
```
56+
57+
Do not trust call-graph percentages from plain `perf record -g` on the
58+
ReleaseFast binary: frame-pointer unwinding misattributes inlined frames
59+
(e.g. allocation helpers showing up hot inside functions that never
60+
allocate). `--call-graph dwarf` resolves inline frames correctly.
61+
62+
For per-opcode counters and allocation stats, build with `-Dperf=true` and
63+
check `std.core.gc_stats_ext()` from scripts (`alloc_object_calls`,
64+
`gc_runs`, `gc_time_ns`). Timing baselines for the benchmark set live in
65+
`tests/bench/time_baseline.txt`.
66+
4767
## Docs
4868

4969
The public docs site is sourced from `docs/` and built by Gengoscript itself

src/lang/chunk_verifier.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,16 @@ pub fn verify(state: anytype) !void {
259259

260260
{
261261
var func_body_count: usize = 0;
262-
var func_ips: [4096]usize = undefined;
262+
// u32 halves the stack footprint (16KB vs 32KB on 64-bit) — ips are
263+
// bounded by MaxCode (1 MiB), well inside u32.
264+
var func_ips: [4096]u32 = undefined;
263265
{
264266
for (state.consts[0..state.const_count]) |cv| {
265267
if (cv == .object) {
266268
switch (cv.object.*) {
267269
.function => |f| {
268270
if (f.ip < state.code_len and Bits.has(starts, f.ip)) {
269-
func_ips[func_body_count] = f.ip;
271+
func_ips[func_body_count] = @intCast(f.ip);
270272
func_body_count += 1;
271273
}
272274
},

0 commit comments

Comments
 (0)