Hi,
we got this problem before. We investigated and excluded it was a NoMachine issue, but it was rather an issue related to the RANDR X server extension. No Trouble Report exists for this problem and that was a mistake. This issue is annoying and a TR would have been useful as a reference for anyone reproducing it. When the lag occurs, do you experience the same lag on the local, physical machine?
From the investigations we found that applying a resize of the screen of the desktop, using the RANDR X extension, resolved the problem. I don’t remember if applying a resize with the same size the desktop already had made the trick, but you can try it yourself. To try this, open a terminal and use the xrandr command to list the available resolutions (‘xrandr -q’), then set one of them (‘xrandr -s WxH’). This should clear the lag. Another thing we could do is sending a fake input event at intervals to prevent the screen from going to sleep, but this can be obviously annoying, for the user, that would never get its screen into sleep.
BTW, are you using an NVidia graphic card? Are you using the NVidia proprietary graphic driver? Because also these two X driver’s bugs can apply:
https://askubuntu.com/questions/1053973/mouse-cursor-lags-behind-after-screen-lock-user-switching
https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-390/+bug/1757202