mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-18 10:50:44 +00:00
Only flush during Present()
This is interesting, but didn't meaningfully move the needle * one line flush change 32.443MB, 3.905s, 8.307MB/s 32.443MB, 3.938s, 8.238MB/s 32.443MB, 3.915s, 8.288MB/s * with lock the buffer and flush on present 32.443MB, 3.891s, 8.339MB/s 32.443MB, 3.872s, 8.379MB/s 32.443MB, 3.877s, 8.368MB/s
This commit is contained in:
@@ -112,7 +112,10 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe,
|
||||
// by prepending a cursor off.
|
||||
if (_lastCursorIsVisible != Tribool::False)
|
||||
{
|
||||
_buffer.insert(0, "\x1b[?25l");
|
||||
{
|
||||
auto buffer{ _buffer.lock() };
|
||||
buffer->insert(0, "\x1b[?25l");
|
||||
}
|
||||
_lastCursorIsVisible = Tribool::False;
|
||||
}
|
||||
// If the cursor was NOT previously visible, then that's fine! we don't
|
||||
|
||||
@@ -94,22 +94,6 @@ using namespace Microsoft::Console::Types;
|
||||
RETURN_IF_FAILED(_MoveCursor(_deferredCursorPos));
|
||||
}
|
||||
|
||||
// If this frame was triggered because we encountered a VT sequence which
|
||||
// required the buffered state to get printed, we don't want to flush this
|
||||
// frame to the pipe. That might result in us rendering half the output of a
|
||||
// particular frame (as emitted by the client).
|
||||
//
|
||||
// Instead, we'll leave this frame in _buffer, and just keep appending to
|
||||
// it as needed.
|
||||
if (_noFlushOnEnd) [[unlikely]]
|
||||
{
|
||||
_noFlushOnEnd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_IF_FAILED(_Flush());
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -122,8 +106,23 @@ using namespace Microsoft::Console::Types;
|
||||
// Return Value:
|
||||
// - S_FALSE since we do nothing.
|
||||
[[nodiscard]] HRESULT VtEngine::Present() noexcept
|
||||
{
|
||||
return S_FALSE;
|
||||
{ // If this frame was triggered because we encountered a VT sequence which
|
||||
// required the buffered state to get printed, we don't want to flush this
|
||||
// frame to the pipe. That might result in us rendering half the output of a
|
||||
// particular frame (as emitted by the client).
|
||||
//
|
||||
// Instead, we'll leave this frame in _buffer, and just keep appending to
|
||||
// it as needed.
|
||||
if (_noFlushOnEnd)
|
||||
[[unlikely]]
|
||||
{
|
||||
_noFlushOnEnd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_IF_FAILED(_Flush());
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT VtEngine::ResetLineTransform() noexcept
|
||||
@@ -552,10 +551,11 @@ using namespace Microsoft::Console::Types;
|
||||
// Write the actual text string. If we're using a soft font, the character
|
||||
// set should have already been selected, so we just need to map our internal
|
||||
// representation back to ASCII (handled by the _WriteTerminalDrcs method).
|
||||
if (_usingSoftFont) [[unlikely]]
|
||||
{
|
||||
RETURN_IF_FAILED(VtEngine::_WriteTerminalDrcs({ _bufferLine.data(), cchActual }));
|
||||
}
|
||||
if (_usingSoftFont)
|
||||
[[unlikely]]
|
||||
{
|
||||
RETURN_IF_FAILED(VtEngine::_WriteTerminalDrcs({ _bufferLine.data(), cchActual }));
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_IF_FAILED(VtEngine::_WriteTerminalUtf8({ _bufferLine.data(), cchActual }));
|
||||
|
||||
@@ -93,7 +93,10 @@ try
|
||||
#endif
|
||||
|
||||
// TODO GH10001: Replace me with REP
|
||||
_buffer.append(n, c);
|
||||
{
|
||||
auto buffer{ _buffer.lock() };
|
||||
buffer->append(n, c);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
@@ -129,7 +132,8 @@ CATCH_RETURN();
|
||||
|
||||
try
|
||||
{
|
||||
_buffer.append(str);
|
||||
auto buffer{ _buffer.lock() };
|
||||
buffer->append(str);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -140,8 +144,12 @@ CATCH_RETURN();
|
||||
{
|
||||
if (_hFile)
|
||||
{
|
||||
auto fSuccess = !!WriteFile(_hFile.get(), _buffer.data(), gsl::narrow_cast<DWORD>(_buffer.size()), nullptr, nullptr);
|
||||
_buffer.clear();
|
||||
bool fSuccess = false;
|
||||
{
|
||||
auto buffer{ _buffer.lock() };
|
||||
fSuccess = !!WriteFile(_hFile.get(), buffer->data(), gsl::narrow_cast<DWORD>(buffer->size()), nullptr, nullptr);
|
||||
buffer->clear();
|
||||
}
|
||||
if (!fSuccess)
|
||||
{
|
||||
_exitResult = HRESULT_FROM_WIN32(GetLastError());
|
||||
|
||||
@@ -20,6 +20,7 @@ Author(s):
|
||||
#include "tracing.hpp"
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <til/mutex.h>
|
||||
|
||||
// fwdecl unittest classes
|
||||
#ifdef UNIT_TESTING
|
||||
@@ -93,7 +94,7 @@ namespace Microsoft::Console::Render
|
||||
|
||||
protected:
|
||||
wil::unique_hfile _hFile;
|
||||
std::string _buffer;
|
||||
til::shared_mutex<std::string> _buffer;
|
||||
|
||||
std::string _formatBuffer;
|
||||
std::string _conversionBuffer;
|
||||
|
||||
Reference in New Issue
Block a user