Files
romm/backend/handler
Ryan McClelland 28be8b7ad8 perf(gamelist): parse gamelist.xml incrementally
_parse_gamelist_xml read the whole file, ran two regex rewrites over it
and built a tree for the entire document before touching a single game.
On a platform with thousands of entries that tree dominates the scan's
memory, and it is discarded as soon as the per-game dict is built.

Stream top-level game/folder elements with iterparse instead, clearing
each once consumed. Measured on a synthetic 4.8 MB gamelist with 10,703
games, peak allocation drops from 33.3 MB to 3.4 MB.

ES-DE writes an <alternativeEmulator> sibling to <gameList>, which is
invalid multi-root XML that the incremental parser rejects, so those
files fall back to the previous strip-then-parse path. Entries are keyed
by filename, so re-reading elements already consumed before the failure
cannot corrupt the result.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLTDjv3niosCXZWtjKELK2
2026-08-14 09:11:11 -07:00
..
2025-12-07 12:19:13 -05:00