SteamGridDB / steam-rom-manager

An app for managing ROMs in Steam
GNU General Public License v3.0
1.79k stars 119 forks source link

Huge memory+CPU spike on batch 1 only when saving large single parsers #589

Closed fpiesche closed 8 months ago

fpiesche commented 10 months ago

First off: I suspect this overlaps with #563 and #564. I reported this on discord a little while ago but only now got around to writing this up as a GitHub issue.

Platform: Steam Deck SRM version: 2.4.17 AppImage

I've observed that when using "Save to Steam" on single parsers with more than a couple hundred games or so (the point seems to be somewhere around 250-300 games as far as I can tell?), there's an enormous spike in RAM and CPU usage before batch 1 gets saved, regardless of how many batches there actually are.

Running multiple parsers at once totalling up to >500 games with each individual parser at under 200 games does not exhibit this behaviour; it appears to only happen when a single parser exceeds a certain number of games.

The behaviour I've observed, with multiple different parsers, is this:

Is there anything particular SRM is doing before actually handling batch 1 that it doesn't do with the other batches that could cause this behaviour?

Screenshots of this occurring on my Steam Deck, both test cases with a batch size of 20:

image 268 games, 58 batches. Memory usage shown spiking from ~3GB to 7.6GB once "Doing batch 1" is output to terminal.

image 413 games, 103 batches (?!). Once "Doing batch 1" is output to terminal log, memory usage spikes from ~3GB to 12GB (!), and then very slowly decreased by about 1GB/5 minutes with the usage pattern shown here.

In both cases, once memory usage dropped back down to the idle ~3GB, adding games proceeded quickly and finished within a few minutes.

Crucially, if this spike actually exhausts the memory available on the system, it will just stall the machine indefinitely. If I've got Discord and Firefox running in the background (for an idle memory use of about 6GB instead of 3GB), the 413-game parser will max out the system memory and stall the system for 10+ hours while CPU usage is maxed and the fan spins at maximum speed.

I'd be happy to test out a build with more debug output or some such if it'd help pinpoint the problem - hit me up on Discord (ektoutie).

fpiesche commented 8 months ago

Another couple of observations of things I've just noticed running into this again:

fpiesche commented 8 months ago

Managed to resolve this by wiping my shortcuts.vdf and addeditems.json.

krazykriskomar commented 6 months ago

This is not fixed. happens to me every time.