microsoft / microsoft/terminal
Extremely slow performance when processing virtual terminal sequences
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
### Windows Terminal version (or Windows build number)
1.8.1521.0
### Other Software
_No response_
### Steps to reproduce
Using any command line utility that produces virtual terminal sequences for setting the colors of individual characters, the performance of the terminal drops by a factor of around 40.
To measure this effect precisely, you can use the F2 key in termbench and observe the performance difference between color-per-character output and single-color output:
https://github.com/cmuratori/termbench/releases/tag/V1
### Expected Behavior
Despite the increased parsing load, modern CPUs should not have a problem parsing per-character color escape codes quickly. I would expect the performance of the terminal to be able to sustain roughly the same frame rate with per-character color codes as without, and if there was a performance drop, I wouldn't expect it to be anything close to 40x.
### Actual Behavior
The speed of per-character color output is 40x slower than the speed of single-color output.
Contributor guide
Research direction
Start by reproducing the comparison in termbench using the F2 measurement, contrasting per-character color output with single-color output. Profile the terminal while processing these virtual terminal sequences and identify the source of the roughly 40x slowdown; the work is done when per-character output has substantially improved performance without changing expected rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100