EndPaint outside of lock for DxEngine #9045

Closed
opened 2026-01-31 01:44:35 +00:00 by claunia · 5 comments
Owner

Originally created by @miniksa on GitHub (Jun 15, 2020).

The EndPaint command will naturally send all the queued drawing commands onto the underlying rendering target/bitmap/surface. Since all the data has already been captured and queued, there's no real sense in holding the lock on the I/O thread while the draw commands are performed. So this should probably move into the Present phase. But it will have to be reconciled with the invalid rectangle/scroll things that are usually done at EndPaint time.

Originally created by @miniksa on GitHub (Jun 15, 2020). The EndPaint command will naturally send all the queued drawing commands onto the underlying rendering target/bitmap/surface. Since all the data has already been captured and queued, there's no real sense in holding the lock on the I/O thread while the draw commands are performed. So this should probably move into the `Present` phase. But it will have to be reconciled with the invalid rectangle/scroll things that are usually done at `EndPaint` time.
Author
Owner

@zadjii-msft commented on GitHub (Aug 16, 2022):

🤔

Why did we never do this? This might have just sorted out like, a bunch of the miscellaneous deadlocks we're tracking (ala #12607)

@zadjii-msft commented on GitHub (Aug 16, 2022): 🤔 Why did we never do this? This might have just sorted out like, a bunch of the miscellaneous deadlocks we're tracking (ala #12607)
Author
Owner

@zadjii-msft commented on GitHub (Aug 16, 2022):

@lhecker tell me why this wouldn't work:
https://github.com/microsoft/terminal/compare/dev/migrie/b/6523-endpaint-outside-lock?w=1

@zadjii-msft commented on GitHub (Aug 16, 2022): @lhecker tell me why this wouldn't work: https://github.com/microsoft/terminal/compare/dev/migrie/b/6523-endpaint-outside-lock?w=1
Author
Owner

@lhecker commented on GitHub (Aug 16, 2022):

D2D has an internal batch size limit for draw commands, so given enough text on the screen, it'll try to call D3D functions potentially many times before EndDraw is even called.
That said, it can't hurt to merge this. Reduces the chance for our issue even further...

@lhecker commented on GitHub (Aug 16, 2022): D2D has an internal batch size limit for draw commands, so given enough text on the screen, it'll try to call D3D functions potentially many times before `EndDraw` is even called. That said, it can't hurt to merge this. Reduces the chance for our issue even further...
Author
Owner

@zadjii-msft commented on GitHub (Aug 22, 2022):

Note to future self: this seemingly did not noticeably improve Terminal perf. Maybe it helps conhost perf, but I didn't have the cycles to further sanity check if this wouldn't just explode (esp. over RDP).

I'm closing this tab out now, see y'all in two more years when I reopen this 😜

@zadjii-msft commented on GitHub (Aug 22, 2022): Note to future self: this seemingly did not noticeably improve Terminal perf. Maybe it helps conhost perf, but I didn't have the cycles to further sanity check if this wouldn't just explode (esp. over RDP). I'm closing this tab out now, see y'all in two more years when I reopen this 😜
Author
Owner

@lhecker commented on GitHub (Oct 10, 2024):

Oh, we do this now in AtlasEngine!

@lhecker commented on GitHub (Oct 10, 2024): Oh, we do this now in AtlasEngine!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9045