On my AMD Ryzen 7 8845HS mini PC, NVDA is a bit sluggish in some cases in Firefox; e.g. cursoring through messages in Gmail folders. For reasons I don't fully understand, setting the processor affinity to a single CPU core and setting the process priority to "above normal" helps significantly, even when the CPU is nearly idle. I don't currently have the time/energy to debug the root cause for this or write a proper add-on, but I wrote an NVDA global plugin to make the change for me automatically when NVDA starts. If it breaks something, you get to keep all the pieces.
```
import ctypes

import globalPluginHandler

class GlobalPlugin(globalPluginHandler.GlobalPlugin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
p = ctypes.c_void_p(ctypes.windll.kernel32.GetCurrentProcess())
ctypes.windll.kernel32.SetProcessAffinityMask(p, ctypes.c_void_p(1))
ctypes.windll.kernel32.SetPriorityClass(p, ctypes.wintypes.DWORD(0x00008000))
```
#nvdasr

This entry was edited (17 hours ago)

reshared this

in reply to x0

@x0 @kev I honestly don't even really understand priority. If the CPU is near idle, there shouldn't be much contention (and thus nothing should have to wait), especially with multiple cores, since there are more than enough cores for all the things. As for affinity, NVDA is largely single core, primarily because GUIs (and thus accessibility APIs) are pretty much main thread only. Most of the work of a virtual buffer actually happens in NVDA's injected code in the GUI thread of the remote process; e.g. inside Firefox. I haven't tested this, but I think this is more likely to be the many cross-process COM calls NVDA makes to query the focus, etc., not the buffer stuff. That involves a lot of context switching.
@Kevan @x0
in reply to Andre Louis

@FreakyFwoof What's really intriguing about my situation is that clearly, it's not really anything in particular that is slow, but rather, how NVDA gets scheduled by Windows. That's not a bottleneck I ever expected to be noteworthy. One of these days, I might try to profile it and figure out what's really going on, but definitely not today and probably not any time soon.
in reply to Jamie Teh

oh yeah I've been doing this for quite a while now on a HX370. I have very little experience with NVDA addons so entirely possible I messed something up somewhere, but it works for me. This let's you set CPU affinity and priority in NVDA settings.
Addon: iamtalon.me/cpuPriority-1.0.0.…
Code: code.iamtalon.me/Talon/cpu-aff…
in reply to Talon

@talon I think you're right, honestly. I won't see any performance gains until I upgrade this machine's well, everything.
It's running better than it ever has though, Jake hooked me up with a GPU instead of Intel onboard graphics, and I upped it from 16 to 32 GB RAM. Windows 10 but it's not end-of-life because of the I guess, EU mandate so I still get updates.
Never felt so good lol
in reply to Jamie Teh

Not entirely sure, and also not even sure how I'd debug that. I'd imagine since it's a mobile CPU it's related to the power profiles, and changing them does improve things a little, but it makes a huge difference especially if you're running in a more energy saving mode. It switches to them especially when running on batteries and I haven't found out how I can prevent it from doing that, but to be honest sometimes I don't even want it to do that because it means giving up quite a lot of battery time. But setting CPU affinity and priority seems to do a good enough job that I kinda forgot about it until recently when I tried to get it working as an addon and not as a weird set of external scripts.
in reply to Talon

@talon My 8845HS is in a mini PC, so still a mobile-ish CPU but theoretically less of the power saving silliness. Obviously an older generation than yours though and I was thinking that was the cause, but I guess not. I'm definitely curious about the underlying cause, but now that I have an interim solution, I'm not quite curious enough to be motivated to dig into it further. I might get nerd sniped enough one day, we'll see.