Files
tty7/src/core/threads.rs
T
l0ng-ai 22e1ab1694 tty7: a GPU-rendered, daemon-backed terminal in pure Rust
tty7 is split into two Rust processes: a persistent daemon that owns the
shells and a GPU-rendered client that talks to it over a local socket.
Because the shells live in the daemon, quitting and reopening the app
leaves the session intact — detach and reattach, no tmux required.

- Persistent sessions — the daemon holds the PTYs and child processes, so
  closing a window or swapping in a new build never takes a shell down.
- Performance — an 11 MB `cat` completes in 95 ms and DOOM-fire renders at
  888 fps; the daemon drains the PTY at device speed off the render path.
- Shell-aware — new tabs and splits open in the current working directory;
  zsh, bash, fish, and PowerShell are set up automatically.
- Enhanced prompt — inline completion, syntax highlighting, history, and
  in-terminal search, with rich flag/subcommand signatures for common tools.
- Tabs, resizable splits, a command palette, click-to-open links, desktop
  notifications, eight themes, and CJK/IME input.

Native builds for macOS, Windows, and Linux.
Built on Zed's gpui and Alacritty's VT core.
2026-07-06 21:54:27 +08:00

28 lines
1.3 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Thread-scheduling helpers shared by the daemon and the GUI client.
/// Ask the OS to schedule the calling thread at user-interactive QoS.
///
/// macOS assigns unclassified threads a default QoS the scheduler is free to
/// park on efficiency cores under load. Measured on an M1 Pro mid-benchmark:
/// whole seconds where the PTY drain drops from ~96 MB/s to 5070 MB/s — an
/// E-core's pace — then recovers. The threads on the interactive output path
/// (daemon PTY reader, connection writer/reader, client socket reader) carry
/// keystroke echo and the visible output stream, which is exactly the workload
/// `QOS_CLASS_USER_INTERACTIVE` names. Best effort; a refused hint just keeps
/// the default class. No-op elsewhere: Linux/Windows schedulers don't demote
/// by QoS class.
pub fn promote_to_user_interactive() {
// Escape hatch for benchmarking the promotion itself (and for users whose
// workload fares better under default scheduling): any non-empty value
// other than "0" disables it.
if std::env::var("TTY7_NO_QOS").is_ok_and(|v| !v.is_empty() && v != "0") {
return;
}
#[cfg(target_os = "macos")]
// SAFETY: a plain scheduling hint for the current thread; no pointers, no
// preconditions.
unsafe {
libc::pthread_set_qos_class_self_np(libc::qos_class_t::QOS_CLASS_USER_INTERACTIVE, 0);
}
}