--priority=99
Apply priority 99 with care to your own code. A tight endless loop with priority 99 will override pretty well everything else, so about the only way to escape will be to turn your computer off. Been there, done that :-)
Notice that without setting the priority, default policy is other, which is the standard one most processes get unless they request else.
By setting priority (while not specifying policy), the policy becomes fifo, the highest, which is meant to give the cpu immediately and not preempt until process releases it.
This implicit change in policy is why you see such brutal effect from setting priority.
If you're developing anything on x86 that needs realtime - how do you disable SMM drivers causing unexpected latency?
And while it won't (completely) remove SMM, https://github.com/corna/me_cleaner might get rid of some stuff. I think that's more about getting rid of spyware and ring -1 security bugs than improving real-time behavior though.