Skip to content

perf: only check for raw mode when logging to a terminal - #1471

Merged
dsherret merged 1 commit into
mainfrom
perf-logger-raw-mode
Nov 28, 2026
Merged

dsherret merged 1 commit into
mainfrom
perf-logger-raw-mode

Conversation

@dsherret

Copy link
Copy Markdown
Member

The logger checked whether the terminal was in raw mode before checking whether the stream was a terminal at all, for every line it logged. On Windows, crossterm's `is_raw_mode_enabled()` opens `CONIN$`, reads its mode and closes it, which takes about 75µs. That happens while holding the logger's lock, so on commands that log a line per file (ex. `dprint check --list-different`) the formatting threads end up waiting on each other to log.

This checks whether the stream is a terminal first and stores that when the logger is made, so raw mode is only checked when logging to a terminal.

`dprint check --list-different --incremental=false` with `@dprint/tidy` on 32 threads (Windows), on files that all need formatting:

Files Before After
21,073 mixed 998 ms 547 ms
6,816 TS 382 ms 180 ms

It's cheap to check on other platforms, so this mostly helps Windows.

@dsherret
dsherret merged commit 88c8c3f into main Nov 28, 2026
6 checks passed
@dsherret
dsherret deleted the perf-logger-raw-mode branch November 28, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant