It can be substantially faster in some cases. Notepad++ (with several plugins) start up goes down from around ~1.03 sec to ~0.61 sec on my machine (with wineprefix active).
9b7669592d6f8b40976b571b70f8543777d35167 is what introduced this performance regression. I don't know why exactly, but it made my Notepad++ noticeably slower when launched from a file manager (so it's not just at wineprefix startup overhead), which is very annoying.
-- v2: win32u: Cache is_virtual_desktop.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
It can be substantially faster in some cases. Notepad++ (with several plugins) start up goes down from around ~1.03 sec to ~0.61 sec on my machine (with wineprefix active).
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/win32u/ntuser_private.h | 1 + dlls/win32u/winstation.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 3b6cab5bdc9..0cffa8b2208 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -127,6 +127,7 @@ struct user_thread_info UINT spy_indent; /* Current spy indent */ BOOL clipping_cursor; /* thread is currently clipping */ DWORD clipping_reset; /* time when clipping was last reset */ + signed char cached_is_virtual_desktop; /* ternary value: zero = unknown, negative = FALSE, positive = TRUE */ };
C_ASSERT( sizeof(struct user_thread_info) <= sizeof(((TEB *)0)->Win32ClientInfo) ); diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c index 9df27517a43..70179d3c8f6 100644 --- a/dlls/win32u/winstation.c +++ b/dlls/win32u/winstation.c @@ -42,12 +42,21 @@ WINE_DECLARE_DEBUG_CHANNEL(win);
BOOL is_virtual_desktop(void) { - HANDLE desktop = NtUserGetThreadDesktop( GetCurrentThreadId() ); + struct user_thread_info *thread_info = get_user_thread_info(); USEROBJECTFLAGS flags = {0}; + HANDLE desktop; DWORD len; + BOOL ret; + + if (thread_info->cached_is_virtual_desktop) + return thread_info->cached_is_virtual_desktop > 0;
+ desktop = NtUserGetThreadDesktop( GetCurrentThreadId() ); if (!NtUserGetObjectInformation( desktop, UOI_FLAGS, &flags, sizeof(flags), &len )) return FALSE; - return !!(flags.dwFlags & DF_WINE_VIRTUAL_DESKTOP); + ret = !!(flags.dwFlags & DF_WINE_VIRTUAL_DESKTOP); + + thread_info->cached_is_virtual_desktop = ret ? 1 : -1; + return ret; }
/*********************************************************************** @@ -261,6 +270,7 @@ BOOL WINAPI NtUserSetThreadDesktop( HDESK handle ) { struct user_thread_info *thread_info = get_user_thread_info(); struct user_key_state_info *key_state_info = thread_info->key_state; + thread_info->cached_is_virtual_desktop = 0; thread_info->client_info.top_window = 0; thread_info->client_info.msg_window = 0; if (key_state_info) key_state_info->time = 0;
Well I rebased it, although I know it's unlikely to go in without further investigation.
Can you reproduce similar numbers/improvements with an active prefix at least?
Of course starting notepad in an active prefix is faster but I still don't reproduce any difference.
Do you see `X11DRV_UpdateDisplayDevices` being called (ie: the TRACE after `if (!force && !force_display_devices_refresh) return TRUE;`) when you run notepad in an active prefix?
On Sun Feb 18 20:42:12 2024 +0000, Rémi Bernon wrote:
Of course starting notepad in an active prefix is faster but I still don't reproduce any difference. Do you see `X11DRV_UpdateDisplayDevices` being called (ie: the TRACE after `if (!force && !force_display_devices_refresh) return TRUE;`) when you run notepad in an active prefix?
Nope. It's not called. But I'm talking about notepad++ (plus plus, not the built in notepad), with a bunch of plugins (not sure if that matters). Built in notepad launches fast enough that I can't see a difference.
FWIW, I don't see it called when launching notepad++ in an active prefix either, but it's still slow, so that can't be it.
Recent changes in virtual desktop mode have skipped a couple of unnecessary cache invalidation, is this still making a difference?
As an additional prefix startup optimization I think we could write the display device modes to the registry all at once, as done in https://gitlab.winehq.org/wine/wine/-/merge_requests/5579.
On Sat May 4 18:56:44 2024 +0000, Rémi Bernon wrote:
Recent changes in virtual desktop mode have skipped a couple of unnecessary cache invalidation, is this still making a difference? As an additional prefix startup optimization I think we could write the display device modes to the registry all at once, as done in https://gitlab.winehq.org/wine/wine/-/merge_requests/5579.
Just tested now on an active prefix (so, no prefix startup):
Upstream: ~630 ms With my patch on top: ~590 ms
Of note is that it's actually faster than before even with my patch (great!), but I think the difference now is too small to warrant this, so I'll close this MR. (well unless someone changes their mind to reopen it, but I don't think it's worth it anymore)
Thanks!
This merge request was closed by Gabriel Ivăncescu.