CPU Usage DrawString runaway effect
Prerequisites
- [x] I have verified this issue is present in the
developbranch - [x] I have searched open and closed issues to ensure it has not already been reported.
MonoGame Version
3.8.4
Which MonoGame platform are you using?
MonoGame Cross-Platform Desktop Application (mgdesktopgl)
Operating System
Windows
Description
Drawing text with SpriteFont leads my CPU usage to spike up to full single core utilization. This happens seemingly randomly, suddenly the usage starts climbing until it caps out.
It seems to happen faster and more often with dynamic text, but it can be reproduced on my machine with the simplest imaginable example of just drawing a string.
Attached you can find a sample which on my machine more consistenently and faster reproduces the issue. I would say about half the times I run this sample in Debug or in Release build, it will start climbing in CPU usage from the get go.
I've also run this sample against MG 3.8.1, with no perceived changes in behaviour.
CPU profiling points to all CPU resources being consumed at FlushVertexArray
Steps to Reproduce
Draw string with SpriteFont, wait till CPU usage runaway effects occurs.
Minimal Example Repo
No response
Expected Behavior
No runaway cpu usage
Resulting Behavior
CPU core usage is maxed out
Files
I tested this a few times on my mac (left it running for a hour once). No change, it remains pretty stable. Might be a windows thing?
@dellis1972 i had never encountered this before myself, but now it seems I can't get rid of it, it's entirely possible that it's an issue with my machine and that it can't be replicated elsewhere. It's perplexing either way.
@nkast kindly provided me with the same sample in KNI, same result.
Confirmed this runaway issue does not happen MG WindowsDX, but it must be noted that the performance is still poor bouncing between 0.2% and somtimes spikes up to nearly 4% utilization (half a core of my 5800x3d for not much more than 100 chars rendered).
I've made one more change to the sample for more reliable testing;
this.InactiveSleepTime = TimeSpan.FromSeconds(0f);
The rest is all the same. but this time its WindowsDX 3.8.4, so conslusion, no runaway full core utilization, but still high CPU and GPU usage, high power draw from my machine, to draw a small string.