I’d prefer not to have my mouse stutter because the driver paused to run the garbage collector.

Mouse stutter has become more common in Windows. Every time I open a web page with Spotify embed mouse freezes for ~0.5 to 1 second and then continues moving, I haven't found any reason for it, it happens with Firefox, Google Chrome, and Edge.

It's been repeatable ever since I bought a Ryzen 7950X at the beginning of the year, that's why I tried using system profiler tools to find the reason but as I have no good experience in this it's difficult to find the root cause.

You can use UI4ETW[0] to capture an event trace when the mouse freezes. You may need to install the Windows SDK or Visual Studio to interpret the results, though.

[0] https://github.com/google/UIforETW