Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
330fb6b
tune: design notes for progress events and a single renderer
borisbat Jul 27, 2026
228e6ef
tune: route the flag rail through daslib/clargs in the design notes
borisbat Jul 27, 2026
427be46
tune: make gen_tune_probe honour --tune-fast a decided item in the notes
borisbat Jul 27, 2026
c30f3cb
tune: record the supervised dasllama-server scenario as the goal
borisbat Jul 27, 2026
693cec6
tune: no duration estimates; add pass name and live-candidate count
borisbat Jul 27, 2026
c8be86d
tune: stream the scope tuner's output instead of buffering it to a file
borisbat Jul 27, 2026
33bf17d
daslib/tty: terminal capability probes, with the fio_core binding beh…
borisbat Jul 27, 2026
320128d
tune: progress events, a single renderer, and the up-front promise
borisbat Jul 27, 2026
70dabaa
tune: mark the built sections in the design notes
borisbat Jul 27, 2026
33798ec
tune: clargs flag rail, --tune-fast for the generator half, and real …
borisbat Jul 27, 2026
bc98431
tune: keep event values space-free, and test the truncation
borisbat Jul 27, 2026
f2e0a98
watchdog: consume tune progress events instead of inferring them from…
borisbat Jul 27, 2026
1754c99
tune: render from the emitter too, and clear llvm_tune's lint debt
borisbat Jul 27, 2026
12f3a9d
tune: mute the tuner's own chatter under a live display
borisbat Jul 27, 2026
bfa3035
tune: the per-kernel stamp report is verbose-only
borisbat Jul 27, 2026
984ed13
tune: per-ISA [tuned] fallbacks, and make cpu_supports answer on arm64
borisbat Jul 27, 2026
8534e05
tune_kernels: derive the summary from report() instead of parallel ar…
borisbat Jul 27, 2026
7985263
tune_kernels: derive the shipped fallback from the annotation, not li…
borisbat Jul 28, 2026
ef6795a
docs: wire daslib/tty and the new fio terminal builtins into das2rst
borisbat Jul 28, 2026
80f8399
fix: hoist the arm64 feature includes out of namespace das
borisbat Jul 28, 2026
e4c1ff2
docs: archive the tune progress-UX design notes
borisbat Jul 28, 2026
2f4e290
fix: include windows.h for the arm64 Windows cpu_supports branch
borisbat Jul 28, 2026
e838730
watchdog: clear published tune state when a child starts
borisbat Jul 28, 2026
b93e064
tune_kernels: close a kernel whose bench returned early
borisbat Jul 28, 2026
6a2d90c
tune: a new plan clears the previous scope's kernel state
borisbat Jul 28, 2026
fe69b2d
watchdog: clear the per-round fields when a kernel ends
borisbat Jul 28, 2026
d858c70
watchdog: a hostile @tune line must not kill the streaming thread
borisbat Jul 28, 2026
ddfc302
tune: a must-see line no longer collides with the live display
borisbat Jul 28, 2026
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
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ A generic that should accept `array<T>`, `array<array<T>>`, … (any nesting)
- **`where` and `shared` are reserved words too** — `where` is the comprehension filter keyword and
`shared` the module modifier; both are a syntax error as a variable name (`let where = ...`,
`let shared = ...`). Rename (`sink_pos`, `shared_node`); hit while writing PERF026-028
- **`label`, `expect`, and `pass` are reserved words** (lexer keywords `DAS_LABEL`/`DAS_EXPECT`/`DAS_PASS` — `pass` is the no-op statement) — using any as a parameter/variable name is a syntax error; rename (`tag`, `want`, `cpass`)
- **`label`, `expect`, `pass`, and `explicit` are reserved words** (lexer keywords `DAS_LABEL`/`DAS_EXPECT`/`DAS_PASS`/`DAS_EXPLICIT` — `pass` is the no-op statement, `explicit` the generic-parameter modifier you see in `array<T> explicit` signatures) — using any as a parameter/variable name is a syntax error; rename (`tag`, `want`, `cpass`, `declared`)
- **`range`/`urange`/`range64`/`urange64` are lexer TYPE tokens** (`DAS_TRANGE` etc., like `int`) — unusable as struct-field, parameter, or annotation-argument names (`@range = ...` is a syntax error); the grammar whitelists them back to a plain name only in call position, which is why `range(10)` works. Rename (`rng`, `span`); grammar-verified 2026-07-23
- **Literal `{`/`}` in string literals must be escaped `\{`/`\}`** — unescaped `{...}` is interpolation. Bites when embedding shader/C source as inline strings. String literals may span multiple lines (raw newlines are legal); probe-verified 2026-07-11
- String builder requires `unsafe` or `options persistent_heap` if returned
Expand Down
51 changes: 51 additions & 0 deletions daslib/tty.das
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
options gen2
options indenting = 4
options strict_smart_pointers = true

module tty shared public

//! Terminal capability probes — is a stream a real terminal, and how wide is it.
//!
//! This is the gate for anything that redraws itself with ``\r``: a progress bar written to a
//! pipe, a redirect, or a supervising process is garbage in the resulting log. Sniffing ``TERM``
//! is not enough — it stays set when stdout is redirected. ``daslib/ansi_colors`` handles
//! styling; this module answers the capability question underneath it.

require fio_core

//! Standard stream numbers, for ``is_stream_terminal``.
let TTY_STDIN = 0
let TTY_STDOUT = 1
let TTY_STDERR = 2

//! Width assumed by ``terminal_columns`` when nothing reports one.
let TTY_DEFAULT_WIDTH = 80

def is_stream_terminal(fd : int) : bool {
//! True when the standard stream `fd` (`TTY_STDIN` / `TTY_STDOUT` / `TTY_STDERR`) is
//! attached to a terminal. Any other descriptor is false.
return is_terminal(fd)
}

def is_stdin_terminal() : bool {
//! True when standard input is attached to a terminal.
return is_terminal(TTY_STDIN)
}

def is_stdout_terminal() : bool {
//! True when standard output is attached to a terminal. This is the gate for a redrawn
//! progress display — false under a pipe, a redirect, or a supervising process.
return is_terminal(TTY_STDOUT)
}

def is_stderr_terminal() : bool {
//! True when standard error is attached to a terminal.
return is_terminal(TTY_STDERR)
}

def terminal_columns(fallback = TTY_DEFAULT_WIDTH) : int {
//! Terminal width in columns, substituting `fallback` when neither the terminal nor
//! ``COLUMNS`` reports one. Pass `fallback = 0` for the raw probe.
let w = terminal_width()
return w > 0 ? w : fallback
}
12 changes: 12 additions & 0 deletions doc/reflections/das2rst.das
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require daslib/regex_boost
require daslib/apply
require daslib/algorithm
require daslib/ansi_colors
require daslib/tty
require daslib/jobque_boost
require daslib/jobque_profile
require daslib/apply_in_context
Expand Down Expand Up @@ -220,6 +221,7 @@ def document_module_fio(_root : string) {
group_by_regex("Directory manipulation", mod, %regex~(dir|dir_rec|mkdir|mkdir_rec|mkdir_result|rmdir|rmdir_rec|rmdir_rec_result|rmdir_result|chdir|getcwd)$%%),
group_by_regex("Glob and pattern matching", mod, %regex~(match_glob|glob|glob_filtered|is_glob_pattern|expand_glob|parse_file_list)$%%),
group_by_regex("Filesystem queries", mod, %regex~(temp_directory|temp_directory_result|create_temp_file|create_temp_file_result|create_temp_directory|create_temp_directory_result|disk_space)$%%),
group_by_regex("Terminal queries", mod, %regex~(is_terminal|terminal_width)$%%),
group_by_regex("OS specific routines", mod, %regex~(sleep|exit|system|popen|popen_binary|popen_timeout|spawn_argv|popen_argv|popen_argv_pipe|popen_timed_out|run_and_capture|get_env_variable|set_env_variable|sanitize_command_line|has_env_variable)$%%),
group_by_regex("Dynamic modules", mod, %regex~(register_dynamic_module|register_native_path)$%%)
)
Expand Down Expand Up @@ -648,6 +650,15 @@ def document_module_ansi_colors(_root : string) {
document("ANSI terminal color and style helpers", mod, "ansi_colors.rst", groups)
}

def document_module_tty(_root : string) {
var mod = find_module("tty")
var groups <- array<DocGroup>(
group_by_regex("Terminal detection", mod, %regex~.*(is_stream_terminal|is_stdin_terminal|is_stdout_terminal|is_stderr_terminal)$%%),
group_by_regex("Terminal geometry", mod, %regex~.*(terminal_columns)$%%)
)
document("Terminal capability probes", mod, "tty.rst", groups)
}

def document_module_algorithm(_root : string) {
var mod = find_module("algorithm")
var groups <- array<DocGroup>(
Expand Down Expand Up @@ -1839,6 +1850,7 @@ def main {
// document daslib modules
document_module_algorithm(root)
document_module_ansi_colors(root)
document_module_tty(root)
document_module_apply_in_context(root)
document_module_apply(root)
document_module_archive(root)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Returns true when the standard stream `fd` (0 for input, 1 for output, 2 for error) is attached to a terminal. Any other descriptor, and every stream that is a pipe or a file, returns false.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Returns the terminal width in columns, or 0 when nothing reports one — the stream is not a terminal, or the platform query failed. Falls back to the COLUMNS environment variable before giving up.
29 changes: 29 additions & 0 deletions doc/source/stdlib/handmade/module-tty.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
The TTY module answers whether a stream is attached to a real terminal, and how
wide that terminal is.

This is the gate for anything that redraws itself with a carriage return: a
progress bar written to a pipe, a redirect, or a supervising process is garbage
in the resulting log. Checking ``TERM`` is not a substitute — it stays set when
standard output is redirected. ``daslib/ansi_colors`` handles styling; this
module answers the capability question underneath it.

All functions and symbols are in "tty" module, use require to get access to it.

.. code-block:: das

require daslib/tty

Example:

.. code-block:: das

require daslib/tty

[export]
def main() {
if (is_stdout_terminal()) {
print("drawing a {terminal_columns()}-column progress bar\n")
} else {
print("output is captured — emitting plain lines instead\n")
}
}
1 change: 1 addition & 0 deletions doc/source/stdlib/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Developer tools
---------------

* :doc:`ansi_colors <generated/ansi_colors>` — ANSI terminal color escape sequences
* :doc:`tty <generated/tty>` — terminal capability probes (is it a terminal, how wide)
* :doc:`command_line <generated/command_line>` — command-line argument parsing helpers
* :doc:`das_source_formatter <generated/das_source_formatter>` — daslang source code formatter
* :doc:`das_source_formatter_fio <generated/das_source_formatter_fio>` — file-based source code formatting
Expand Down
1 change: 1 addition & 0 deletions doc/source/stdlib/sec_io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ File I/O, networking, URI parsing, terminal output, and binary serialization.
generated/uriparser.rst
generated/uriparser_boost.rst
generated/ansi_colors.rst
generated/tty.rst
generated/archive.rst
generated/command_line.rst
generated/logger.rst
1 change: 1 addition & 0 deletions history/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ listed in the log below — search it first when hunting for a doc.
- 2026-07-25 `modules/dasLLAMA/benchmarks/prefill_metal_chase.das` -> `history/dasLLAMA/benchmarks/prefill_metal_chase.das` - Metal prefill chase instrument (arc shipped)
- 2026-07-25 `modules/dasLLAMA/benchmarks/bench_metal_framing.das` -> `history/dasLLAMA/benchmarks/bench_metal_framing.das` - Metal framing-overhead bench (arc shipped)
- 2026-07-25 `modules/dasLLAMA/benchmarks/gguf_perf.das` -> `history/dasLLAMA/benchmarks/gguf_perf.das` - gguf load-time bench (the .dlim rail made it moot)
- 2026-07-27 `modules/dasLLVM/TUNE_PROGRESS_PLAN.md` -> `history/compiler/TUNE_PROGRESS_UX.md` - tune progress-display design (events + single renderer; arc shipped, operative content in skills/tune.md)
Loading
Loading