Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an automated conhost benchmark tool #16453

Merged
merged 5 commits into from
Feb 22, 2024
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Dec 11, 2023

ConsoleBench is capable of launching conhost instances and measuring
their performance characteristics. It writes these out as an HTML file
with violin graphs (using plotly.js) for easy comparison.
Currently, only a small number of tests have been added, but the code
is structured in such a way that more tests can be added easily.

@lhecker
Copy link
Member Author

lhecker commented Dec 11, 2023

I'll leave this PR in draft until next year when we're under less time-to-ship-urgency. Since it's just a tool it's not important to review and/or merge it in anyways after all.

@tusharsnx
Copy link
Contributor

tusharsnx commented Dec 12, 2023

I know it's not ready yet, but I wanna point out a weird condition I'm seeing when running two conhost binaries together.

The second one to run always has a worse performance trace for some reason.

traces

image image

@lhecker
Copy link
Member Author

lhecker commented Dec 12, 2023

The latest commit should fix that issue. The old code did effectively y * height + x in a 2D matrix, but it should've done y * width + x of course. So the results got mixed up.

The new code is a bit simpler (hopefully), but it also includes a better way to track time limits, etc. It should be a bit more robust now. It can still randomly hang though, until we merge #16457 (just press Ctrl+C if that happens and repeat it). There can also be quite some variation for the WriteConsoleA/W 4Ki measurements between older and newer versions, because #16333 recently significantly improved scrolling performance in plain conhost.

DHowett pushed a commit that referenced this pull request Jan 29, 2024
conhost has 2 bugs related to clipboard handling:
* Missing retry on `OpenClipboard`: When copying to the clipboard
  explorer.exe is very eager to open the clipboard and peek into it.
  I'm not sure why it happens, but I can see `CFSDropTarget` in the
  call stack. It uses COM RPC and so this takes ~20ms every time.
  That breaks conhost's clipboard randomly during `ConsoleBench`.
  During non-benchmarks I expect this to break during RDP.
* Missing null-terminator check during paste: `CF_UNICODETEXT` is
  documented to be a null-terminated string, which conhost v2
  failed to handle as it relied entirely on `GlobalSize`.

Additionally, this changeset simplifies the `HGLOBAL` code slightly
by adding `_copyToClipboard` to abstract it away.

## Validation Steps Performed
* `ConsoleBench` (#16453) doesn't fail randomly anymore ✅
lhecker added a commit that referenced this pull request Jan 30, 2024
conhost has 2 bugs related to clipboard handling:
* Missing retry on `OpenClipboard`: When copying to the clipboard
  explorer.exe is very eager to open the clipboard and peek into it.
  I'm not sure why it happens, but I can see `CFSDropTarget` in the
  call stack. It uses COM RPC and so this takes ~20ms every time.
  That breaks conhost's clipboard randomly during `ConsoleBench`.
  During non-benchmarks I expect this to break during RDP.
* Missing null-terminator check during paste: `CF_UNICODETEXT` is
  documented to be a null-terminated string, which conhost v2
  failed to handle as it relied entirely on `GlobalSize`.

Additionally, this changeset simplifies the `HGLOBAL` code slightly
by adding `_copyToClipboard` to abstract it away.

* `ConsoleBench` (#16453) doesn't fail randomly anymore ✅

(cherry picked from commit 86c30bd)
DHowett pushed a commit that referenced this pull request Jan 30, 2024
conhost has 2 bugs related to clipboard handling:
* Missing retry on `OpenClipboard`: When copying to the clipboard
  explorer.exe is very eager to open the clipboard and peek into it.
  I'm not sure why it happens, but I can see `CFSDropTarget` in the
  call stack. It uses COM RPC and so this takes ~20ms every time.
  That breaks conhost's clipboard randomly during `ConsoleBench`.
  During non-benchmarks I expect this to break during RDP.
* Missing null-terminator check during paste: `CF_UNICODETEXT` is
  documented to be a null-terminated string, which conhost v2
  failed to handle as it relied entirely on `GlobalSize`.

Additionally, this changeset simplifies the `HGLOBAL` code slightly
by adding `_copyToClipboard` to abstract it away.

* `ConsoleBench` (#16453) doesn't fail randomly anymore ✅

(cherry picked from commit 86c30bd)
@lhecker lhecker marked this pull request as ready for review February 21, 2024 21:11
OpenConsole.sln Outdated
@@ -2806,6 +2808,30 @@ Global
{328729E9-6723-416E-9C98-951F1473BBE1}.Release|ARM64.ActiveCfg = Release|ARM64
{328729E9-6723-416E-9C98-951F1473BBE1}.Release|x64.ActiveCfg = Release|x64
{328729E9-6723-416E-9C98-951F1473BBE1}.Release|x86.ActiveCfg = Release|Win32
{BE92101C-04F8-48DA-99F0-E1F4F1D2DC48}.AuditMode|Any CPU.ActiveCfg = Debug|Win32
{BE92101C-04F8-48DA-99F0-E1F4F1D2DC48}.AuditMode|ARM.ActiveCfg = Debug|Win32
Copy link
Member

Choose a reason for hiding this comment

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

now you gotta drop all the ARM lines from this file!

I use vim:

:g/\<ARM\>/d
:wq

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

this is so cool

@DHowett DHowett enabled auto-merge (squash) February 22, 2024 00:04
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

oh man we so should run this and publish these as a CI artifact. that'd be neat

@DHowett DHowett merged commit ec434e3 into main Feb 22, 2024
20 checks passed
@DHowett DHowett deleted the dev/lhecker/ConsoleBench branch February 22, 2024 12:31
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.

4 participants