Files
romm/backend
Ryan McClelland 4bf8f5a15c perf(tasks): walk resource directories with os.scandir
The orphaned resource cleanup listed the resource tree through
`anyio.Path`, which dispatches to a worker thread for every entry it
yields and again for every `is_dir()` call. On a library with ~30k ROM
resource directories that is ~60k thread round trips to read data the
directory listing already contains.

Measured on a 30,262-directory library (Raspberry Pi 4, ext4):

    anyio iterdir + is_dir()   50.3s
    os.scandir                  0.15s

`os.scandir` reports the entry type from the directory read itself, so
no per-entry stat is needed. The walk moves into a helper run once via
`asyncio.to_thread`, keeping the event loop free while doing the whole
traversal in a single thread hop rather than tens of thousands.

Cold and warm runs of the old code were within 1% of each other, so this
was thread-dispatch overhead rather than disk I/O.

A directory that cannot be listed now logs and yields an empty set
instead of aborting the walk, so one unreadable platform cannot strand
every other platform's orphans.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 15:48:30 -07:00
..
2026-06-21 17:42:25 -04:00
2026-07-01 08:58:00 -04:00
2026-07-26 15:16:56 -04:00
2024-02-10 12:43:39 -05:00
2025-07-05 19:17:40 -04:00
2026-07-26 15:16:56 -04:00
2026-05-17 17:39:47 -04:00
2026-05-22 22:35:30 -04:00