microsoft / microsoft/terminal

[Performance] Replace std::vector with more lightweight structure in `RenderData::GetPatternId`

Open
#10,564 8 comments 1 reaction 0 assignees View on GitHub
Area-Performance Area-Rendering Help Wanted Issue-Task Product-Meta
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

This is about the scrolling test in #10563. A simplified repro would be:

```bash
time bash -c 'yes | head -n1000000'
```

which takes 7-8s with windows terminal and 300ms with gnome terminal.

Test case provided by @lhecker.

These lines show up in the hot paths of the trace of `OpenConsole`:

https://github.com/microsoft/terminal/blob/main/src/renderer/base/renderer.cpp#L788

![image](https://user-images.githubusercontent.com/4710575/124551976-7fac6600-de65-11eb-892c-982f5e8ab85b.png)

It appears that simply constructing empty `std::vector` (empty because this is in conhost/OpenConsole) is quite expensive.

CC @PankajBhojwani

Contributor guide

Open the contributing guide

Research direction

Start with RenderData::GetPatternId and the referenced hot path at src/renderer/base/renderer.cpp#L788. Run the provided scrolling repro, `time bash -c 'yes | head -n1000000'`, and inspect the trace showing empty std::vector construction in conhost/OpenConsole. Done means replacing that costly structure appropriately and confirming the scrolling performance improves.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.