Improve WriteCharsLegacy performance by increasing local buffer size (#10921)

Improve WriteCharsLegacy performance by increasing LocalBuffer size, allowing
longer runs of characters to be submitted to the remaining parts of conhost.

References #10563 -- vtebench tracking issue

## Validation Steps Performed

* Ran `cat big.txt`, vtebench and termbench and
  noted ~5% performance improvements
This commit is contained in:
Leonard Hecker 2021-08-12 19:54:59 +02:00 committed by GitHub
parent f1dc649135
commit d3f9859051
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,8 +28,6 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
// Used by WriteCharsLegacy.
#define IS_GLYPH_CHAR(wch) (((wch) >= L' ') && ((wch) != 0x007F))
constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
// Routine Description:
// - This routine updates the cursor position. Its input is the non-special
// cased new location of the cursor. For example, if the cursor were being
@ -339,7 +337,6 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
COORD CursorPosition = cursor.GetPosition();
NTSTATUS Status = STATUS_SUCCESS;
SHORT XPosition;
WCHAR LocalBuffer[LOCAL_BUFFER_SIZE];
size_t TempNumSpaces = 0;
const bool fUnprocessed = WI_IsFlagClear(screenInfo.OutputMode, ENABLE_PROCESSED_OUTPUT);
const bool fWrapAtEOL = WI_IsFlagSet(screenInfo.OutputMode, ENABLE_WRAP_AT_EOL_OUTPUT);
@ -360,6 +357,9 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
coordScreenBufferSize.X = textBuffer.GetLineWidth(CursorPosition.Y);
}
static constexpr unsigned int LOCAL_BUFFER_SIZE = 1024;
WCHAR LocalBuffer[LOCAL_BUFFER_SIZE];
while (*pcb < BufferSize)
{
// correct for delayed EOL