Skip to content

avoid committing rows just to figure out rendition, blink and cursor#19984

Merged
DHowett merged 1 commit intomainfrom
dev/duhowett/do-not-commit-buffer-for-blinking-purposes
Mar 18, 2026
Merged

avoid committing rows just to figure out rendition, blink and cursor#19984
DHowett merged 1 commit intomainfrom
dev/duhowett/do-not-commit-buffer-for-blinking-purposes

Conversation

@DHowett
Copy link
Member

@DHowett DHowett commented Mar 17, 2026

We have been looking at a set of conhost crashes due to low-memory conditions. I've observed that they all happen during the first pass of rendering, before there's even an engine set up, when we try to estimate whether there are any blink attributes. I also found that we'll commit the buffer to check the cursor's double-width status and whether it's on a double-width-rendition line.

Uncommitted rows never contain a blinker, are never double-width and never contain DBCS.

We can't necessarily avoid committing an empty buffer forever, but this at least moves the first commit until after the renderer truly starts.

This prevents us from committing an empty buffer for headless console apps (!)

@DHowett
Copy link
Member Author

DHowett commented Mar 17, 2026

I would like to prevent commit completely if all we do is render an empty console window, which should save roughly 40kb for every console application ever spawned until it prints its first text. But given our architecture that may not currently be feasible.

@github-actions

This comment has been minimized.

@DHowett DHowett force-pushed the dev/duhowett/do-not-commit-buffer-for-blinking-purposes branch from c685c30 to 72680af Compare March 17, 2026 21:15
@github-actions

This comment has been minimized.

We have been looking at a set of conhost crashes due to low-memory
conditions. I've observed that they all happen during the first pass of
rendering, before there's even an engine set up, when we try to estimate
whether there are any blink attributes. I also found that we'll commit
the buffer to check the cursor's double-width status and whether it's on
a double-width-rendition line.

We can't necessarily avoid committing an empty buffer _forever,_ but
this at least moves the first commit until after the renderer truly
starts.

Whether that's good or not remains to be seen.
@DHowett DHowett force-pushed the dev/duhowett/do-not-commit-buffer-for-blinking-purposes branch from 72680af to e1c43fe Compare March 17, 2026 21:21
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we did buffer snapshotting this may be relatively easy to implement by copying uncommitted rows as whitespace.

@DHowett DHowett merged commit f8b4e19 into main Mar 18, 2026
20 checks passed
@DHowett DHowett deleted the dev/duhowett/do-not-commit-buffer-for-blinking-purposes branch March 18, 2026 22:53
DHowett added a commit that referenced this pull request Mar 18, 2026
This saves us all of the cost of preparing the renderer when we're not
going to use it.

Related to #19984
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.

2 participants