klonyyy / STMViewer

Real-time STM32 variable & trace viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CPU/GPU usage when idle

dzid26 opened this issue · comments

Windows 11.
There is constant small CPU/GPU usage even when acquisition is stopped and app is minimized.

Can we pause the rendering at least under those conditions?

Could you show me the circumstances under which these usages take place? This is my usage when STMViewer is minimized:
image

(Branch jlink_hss @ b6371ef)

All the time.

In general the usage is not big (usually 2%) but it jumps to 5% periodically.

Examples (after loading config and minimizing.)
(When recording is active, the effect on GPU is slightly lesser. )

Untitled.video.-.Made.with.Clipchamp.5.mp4
Untitled.video.-.Made.with.Clipchamp.8.mp4

I am expecting there could be 0% when stopped.
But if imgui is not efficient about mouse events, etc.., then at least maybe we can pause it when minimized.

Thanks

Please let me know if the latest commit solved the issue. Thanks for bringing it out!

Strangely, today, I couldn't reproduce 5% CPU spikes on any version.

Version 0.4 & 0.5:

  • When stopped CPU was mostly 0% and GPU mostly 4%.
  • When minimized CPU was mostly at 0% and GPU at 0.5% average

With GLFW_FOCUSED:

  • CPU and GPU are both 0% when not in focus. Great.

But the cursors don't refresh when hovering. Not sure if that is useful for anything.

Since the issue doesn't seem as bad as I thought, I guess we could check for "minimized" only?

This works:

if (glfwGetWindowAttrib(window, GLFW_ICONIFIED))

Yeah, I was thinking of the GLFW_ICONIFIED however this does not seem to limit the rendering whenever the windows is overlayed by another window (not minimized explicitly). Let's stick with it and see if someone complaints about the high CPU/GPU usage after this fix.

Actually, we also could add this in the while loop as another simple efficiency improvement:

		if (glfwGetWindowAttrib(window, GLFW_FOCUSED) || (tracePlotHandler->getViewerState() == PlotHandlerBase::state::RUN) || (plotHandler->getViewerState() == PlotHandlerBase::state::RUN))
			glfwSwapInterval(1);
		else
			glfwSwapInterval(4);

1% instead of 4% GPU usage with visible window.

Would you be willing to implement and test that in a PR to the devel branch?