Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- "ReleaseSmall"
options:
- ""
- "-Djit_always_on"
- "-Djit_hotspot_always_on"
- "-Djit_always_on -Djit_asynchronous=false"
- "-Djit_hotspot_always_on -Djit_asynchronous=false"

steps:
- name: Checkout project
Expand Down
17 changes: 16 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ FFI, Debugger, and LSP are immature. Treat changes there as higher risk.
- Before editing, check the working tree.
- If the working tree is clean, make the requested changes normally.
- If the working tree only has untracked files, edits are allowed. Do not overwrite or delete unrelated untracked files.
- If the working tree has tracked modifications or staged changes, continue investigation read-only, then show the diff you would have applied and say that no files were modified because the working copy was not clean.
- If the working tree has tracked modifications or staged changes that were not initiated by the current agent/session, continue investigation read-only, then show the diff you would have applied and say that no files were modified because the working copy was not clean.
- If tracked modifications were initiated by the current agent/session for the active task, the agent may continue editing those files and related files needed to finish the same task.
- Do not overwrite or revert user changes.

Agents may delete files they generated during their own work. Do not delete files that were already tracked by git.
Expand Down Expand Up @@ -146,9 +147,23 @@ Useful build flags include:
- `-Dgc_debug=true`, `-Dgc_debug_light=true`, and `-Dgc_debug_access=true` for GC debugging.
- `-Djit_debug=true` for JIT debugging.
- `-Djit=false` to disable JIT while isolating runtime issues.
- `-Djit_asynchronous=<bool>` controls whether JIT jobs run on the worker thread. Keep it enabled by default unless isolating an async publication issue.
- `-Djit_call_threshold=<int>` is the function call count before a function is considered for JIT compilation.
- `-Djit_score_threshold=<int>` is the function score gate. Function score is call count multiplied by chunk complexity.
- `-Djit_hotspot_threshold=<int>` is the loop/hotspot execution count before a hotspot is considered for JIT compilation.
- `-Djit_hotspot_score_threshold=<int>` is the hotspot score gate. Hotspot score is execution count multiplied by AST hotspot complexity.
- `-Dcycle_limit=<int>` to limit bytecode execution, noting that it disables JIT compilation.
- `-Dmemory_limit=<int>` to reproduce or bound memory behavior.

Current default JIT thresholds are intentionally conservative: call threshold `1024`, function score threshold `65535`, hotspot threshold `256`, hotspot score threshold `65535`, async enabled. When tuning, compare against the full `tests/bench` matrix instead of optimizing a single benchmark:

```sh
scripts/jit_bench_matrix.sh quick
scripts/jit_bench_matrix.sh final nojit current sync-current hotspot-only
```

The matrix writes timings and output-hash comparisons under `zig-cache/jit-bench/`.

## Debugging Guidance

- For parser/typechecker/codegen issues, prefer the smallest `.buzz` regression test that reproduces the behavior.
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Unreleased

This release builds with zig 0.16.0. We will only use tagged version of zig from now on.
> [!NOTE]
> This release builds with zig 0.16.0. We will only use tagged version of zig from now on.

## Added

Expand All @@ -22,7 +23,10 @@ This release builds with zig 0.16.0. We will only use tagged version of zig from

## Internal

- JIT compiler works in a separate thread
- Better JIT thresholds based of functions/hotspots complexity scores
- The standard libraries are now statically loaded which gives a small speed boost
- `-Dshow_perf` now show detailed rundown of the time spent in each component of buzz

# 0.5.0 (01-24-2025)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ A small/lightweight statically typed scripting language written in Zig
<a href="https://buzz-lang.dev">Homepage</a> — <a href="https://discord.gg/VnMdNSdpNV">Discord</a>
</p>

_buzz is in alpha and is **not** ready any professional or production use_
> [!WARNING]
> buzz is in alpha and is **not** ready any professional or production use

## Features

Expand Down
45 changes: 33 additions & 12 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ const BuildOptions = struct {
"jit_hotspot_always_on",
"JIT compiler will compile any hotspot encountered",
) orelse false,
.hotspot_on = !is_wasm and b.option(
.hotspot = !is_wasm and b.option(
bool,
"jit_hotspot_on",
"jit_hotspot",
"JIT compiler will compile hotspot when threshold reached",
) orelse true,
.on = !is_wasm and b.option(
Expand All @@ -918,12 +918,27 @@ const BuildOptions = struct {
bool,
"jit_asynchronous",
"JIT will work in a dedicated thread",
) orelse false,
.prof_threshold = b.option(
f32,
"jit_prof_threshold",
"Threshold to determine if a function is hot. If the numbers of calls to it makes this percentage of all calls, it's considered hot and will be JIT compiled.",
) orelse 0.05,
) orelse true,
.call_threshold = b.option(
u16,
"jit_call_threshold",
"Call count threshold above which the function is being considered for JIT compilation.",
) orelse 1024,
.score_threshold = b.option(
u16,
"jit_score_threshold",
"Complexity score threshold above which the function will be JIT compiled.",
) orelse 65535,
.hotspot_threshold = b.option(
u16,
"jit_hotspot_threshold",
"Loop count threshold above which a loop is being considered for JIT compilation.",
) orelse 256,
.hotspot_score_threshold = b.option(
u16,
"jit_hotspot_score_threshold",
"Complexity score threshold above which a loop node will be JIT compiled.",
) orelse 65535,
},
};
}
Expand Down Expand Up @@ -971,19 +986,25 @@ const BuildOptions = struct {
on: bool,
always_on: bool,
hotspot_always_on: bool,
hotspot_on: bool,
hotspot: bool,
debug: bool,
prof_threshold: f32 = 0.05,
call_threshold: u16 = 1024,
score_threshold: u16 = 65535,
hotspot_threshold: u16 = 256,
hotspot_score_threshold: u16 = 65535,
asynchronous: bool,

pub fn step(self: JITOptions, options: *Build.Step.Options) void {
options.addOption(@TypeOf(self.debug), "jit_debug", self.debug);
options.addOption(@TypeOf(self.always_on), "jit_always_on", self.always_on);
options.addOption(@TypeOf(self.hotspot_always_on), "jit_hotspot_always_on", self.hotspot_always_on);
options.addOption(@TypeOf(self.on), "jit", self.on);
options.addOption(@TypeOf(self.prof_threshold), "jit_prof_threshold", self.prof_threshold);
options.addOption(@TypeOf(self.hotspot_on), "jit_hotspot_on", self.hotspot_on);
options.addOption(@TypeOf(self.call_threshold), "jit_call_threshold", self.call_threshold);
options.addOption(@TypeOf(self.score_threshold), "jit_score_threshold", self.score_threshold);
options.addOption(@TypeOf(self.hotspot), "jit_hotspot", self.hotspot);
options.addOption(@TypeOf(self.asynchronous), "jit_asynchronous", self.asynchronous);
options.addOption(@TypeOf(self.hotspot_threshold), "jit_hotspot_threshold", self.hotspot_threshold);
options.addOption(@TypeOf(self.hotspot_score_threshold), "jit_hotspot_score_threshold", self.hotspot_score_threshold);
}
};

Expand Down
Loading
Loading