-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Dedicated "paint" interface for VtRenderer #10596
Comments
RenderData::GetPatternId
#10564
Ideally I would really want this to be a smooth transition just as my previous I'm expecting 50x-100x increment in throughput out of this task, which should be easily measurable after the first step is finished. |
In your trace... can you expand I don't necessarily want to start from the conclusion that we need to throw the whole architecture out when it could just be that we need to decouple the blocking write action from the rest of the processing that generates text. |
An interim fix would indeed be to add a buffer like the In the long term it might be worthwhile though to see if VT handling without the renderer lends itself to a simpler implementation, as we wouldn't be constrained to any drawing-oriented logic anymore. Basically what I'm saying is: If we add a buffer and decouple the renderer and |
The Vt Rendering engine rather concerns itself with turning a console buffer--which can be written by applications using any of the Win32 console APIs--into a stream of VT that represents that buffer. Yes, we can probably add a path to each API implementation that does something different if conhost is in pty mode, but I don't expect that it's going to provide the correctness (or peri-correctness) that snapping the buffer and presenting it as though it is a screen does. conhost has to soak up a lot of weird stuff like writing an attribute (only!) over a range of characters (for which there's no equivalent VT sequence), copying a region from position A to position B, etc. |
I just always thought the long term VT handling without the renderer framework was VT pass through mode... not rearchitecting the VT renderer. This is a discussion though so I'm not ruling anything out. |
To Dustin: I like the idea of VtEngine is subclass of IRenderEngine because I think it’s cool and also reasonable. The thing is, there’s also cons in this approach, which is what I listed above. I’m OK with still considering IVtEngine a similar interface as IRenderEngine, because this is the way to minimize the changeset and preserve correctness. I would love to see special handling for IVtEngine in renderer.cpp though, because it provides us with chances for all those optimization.
To Michael: yes WriteFile is one of the things that take long time. But the thing l hate the most (and takes double the time than WritrFile) is in PaintBufferLineHelper. For the example in the issue, if you print 1000000 new line, with 120 chars in a line, you having to call a bunch of code for 120000000 times in PaintBufferLineHelper, some of them are about fetching patternId, which provides no functionality in VtEngine. This is why I feel “there’s something wrong arch in the architecture”. I also consider ConPTY passthrough as the eventual plan. This proposal here is more of a low-hanging fruit comparing to ConPTY passthrough, which requires zero modification in the client side(for example Alacritty).
To Leonard: I was asking Michael about the spsc just yesterday. Michael has his own idea about that so I can’t speak for him.
To everyone: no I am not losing sleep because of the controversy. I am only having trouble with a mosquito or two that I really have to kill now.
获取 Outlook for iOS<https://aka.ms/o0ukef>
|
There are other deficiencies in the architecture which we may be able to capture in a revision with something like flags or stages that each individual engine can opt into or out of to reduce the amount of work that is done in the parent while still maintaining the advantages of a unified interface. For instance, the DirectX pipeline is having performance troubles as well because PaintBufferLineHelper divides up any time the colors change when it could happily accept a run with multiple color specifications instead of hopping in and out and in and out for every color change. I just think we might be able to pull those requirements together with the ones for VT and made an adaptation that has the best of all worlds. I do agree with you that the base was written 100% with GDI in mind as the only target. And it was just convenient to us that the BGFX and WDDM and then the VT and DX ones worked on the same interface, even if suboptimally. It could be time to refine it taking all of their unique considerations in mind. |
Well there's It's certainly my long term plan to try and completely replace the current conpty layer with a pure pass-through implementation, where the legacy console APIs are translated directly to VT sequences without an intermediate buffer (there may still need to be a buffer for the buffer reading APIs, but the conpty layer would ideally not be rendering from that buffer). Whether I can ever actually achieve that plan is another question, and of course you may not want to accept a PR of that sort, but that's the direction I'm heading (very very slowly I'll admit). So from my point of view, the |
I managed to drop the time needed 1000000 “yes” from 8.6s down to 4.5s, with the method I described (delay the Flush and add optimized path for VtEngine circling). With a bit more fine-tuning and aggressive optimization, I can see a final 3.3s result.
I am honestly disappointed by this because I have to find the 47x boost somewhere else.
获取 Outlook for iOS<https://aka.ms/o0ukef>
|
Structurally I think #10610 should be considered the prior task. After #10610 is done, I can add the optimization described in this PR without messing around the For the record, what I did in my experimental branch is adding another method in IRenderEngine for For example in VtEngine: [[nodiscard]] RenderEngineKind Kind() noexcept
{
return RenderEngineKind::VirturlTerminal;
} Then in renderer we can do this: if (pEngine->Kind() == RenderEngineKind::VirturlTerminal) {
// ...
} |
Description
As shown in #10563, ConPTY suffers from significant performance drop with too much scrolling request. A typical repro is:
This is a typical trace of
OpenConsole.exe
under the above workload:Discussion
The main issue that caused this, I think, is that VtRenderer suffers from using the same interface as other graphic renderer. To break it down:
EndPaint
as shown above), because the actual text added to the buffer is only a single line (120 chars in a typical display)._PaintBufferOutputHelper
method insiderrenderer
is obviously graphic-oriented. After all these years of development, I don't think it suits the need for VtRenderer anymore. An example is Reduce string operation cost in VtEngine::PaintBufferLine #10567, in which I try to reduce the cost of reassemble the line buffer. The reason why we need to reassemble the clusters, is because they are produced by splitting up the original buffer in_PaintBufferOutputHelper
, which is heavily required by graphic renderers. If we have a dedicated interface, unnecessary operations like these can be eliminated.VtEngine
&XtermEngine
, the actual number of methods that're both overridden and practically useful is rather small, comparing to the large amount of base methods inIRenderEngine
. This indicates that the fundamental goal ofVtEngine
isn't really the same as the graphic renderers.Proposed solution
I'm proposing a three-phase refactoring process for VtEngine to move away from
IRenderEngine
:VtEngine
that are heavily burdened by the current design, such as_PaintBufferOutputHelper
. We add them as base methods toIRenderEngine
.VtEngine
is still a child class ofIRenderEngine
, but we add dedicated IO methods in it and test the performance gain.VtEngine
same way as above.VtEngine
, probably name itIVtEngine
. Then we can createIVtEngine
fromIRenderEngine
, and letIRenderEngine
be what's left in it.CC @DHowett @miniksa @zadjii-msft @lhecker @j4james for discussion.
(How can I just At everyone who's collaborator of this project. That would be helpful.)
The text was updated successfully, but these errors were encountered: