the-abe-train / globle

Use your geography knowledge to figure out the mystery country in as few guesses as possbile!
https://globle-game.com
Other
185 stars 78 forks source link

pegs CPU #108

Open filbo opened 2 years ago

filbo commented 2 years ago

When I am on the Globle tab in my browser, it pegs my CPU. Now granted my CPU is a wuss, but this still shouldn't be happening.

HW: Intel Core i3-4170 (2 cores + hypothreading @3.7GHz); 16GiB RAM; no GPU, just Intel's 'HD 4400' POS. OS: LinuxMint 17.3 (oooold), 4.4.0-148-lowlatency kernel Browser: Opera (dev branch) 88.0.4401.0, based on Chromium 102.0.4972.0

When Globle is on screen, it fluctuates between consuming 70 and 85% of CPU. Fan gets noisy. As soon as I switch away, it goes quiet. Acts as if it is either constantly redrawing the globe, or ... nevermind, I brought up the browser 'task manager' and it says 300% of one CPU is being used by 'GPU process'. So yes, constant redrawing.

I noticed that before I guessed anything, the globe was slowly rotating. So I guessed, which pinned the world in place. No difference, still 300% busy.

It's probably doing this on real machines too, it just isn't noticeable if you have a GPU with half a lung...

the-abe-train commented 2 years ago

The 3D globe is, like all games with a 3D component, inherently going to take up more CPU than a regular site. I'm not sure there's a solution to this other than using a 2D map instead of a globe, but I could be wrong. I'll leave this issue up so that if anyone has any ideas about how to reduce load on the CPU they can share here.

filbo commented 2 years ago

I haven't looked at how it's implemented. My question is basically, is it busy-looping drawing the globe repeatedly as fast as it can; or is it timer / event driven, drawing it only as-needed?

When it's rotating, conceptually it 'needs' to draw once per rotational increment. On a timer event, it would skip drawing any time the next increment wasn't due. So then the drawing equipment [CPU in my case, GPU in a 'real' system's case] would be idle except when a rotation was due.

When it's not rotating nor actively being zoomed, it never needs to redraw. This is not a live-action 3D FPS game! Yet it still sits there hammering the CPU (via 'GPU' process). So clearly there is some gain to be had. Recognize when this iteration's drawing parameters (rotation, zoom) are the same as last one's, and don't. The image on-screen isn't going anywhere, just let it be...

epixian commented 2 years ago

You could do a quick sample for how long requestAnimationFrame takes on the user's browser and not auto-rotate if above a certain value.

filbo commented 2 years ago

It is not the auto-rotation. The CPU is pegged when the earth is sitting completely still.