LL perf (Textures/assets): LLFileSystem reopens the file for every operation #301

Closed
opened 2026-10-04 14:09:14 +00:00 by sky_line · 0 comments
Owner

From the LL-origin inefficiency audit (finding T5). File/line references are from commit 0229f8872c; re-locate them before working.

LLFileSystem reopens the file for every operation

  • Where: llfilesystem/llfilesystem.cpp.
    • The constructor does fileExists plus a last_write_time stat, and possibly utime (:57-71, 300-359).
    • getSize() opens an ifstream and seeks to the end (:122-135); seek() and eof() both call getSize() (:176-179, 247).
    • read/write open and close a stream each time (:137-236).
    • getExists() opens an ifstream and seeks to test for non-zero size (:74-87).
  • Where it hurts:
    • A mesh LOD cache hit costs ~4 opens plus 2 stats (llmeshrepository.cpp:2046-2080).
    • Vorbis decode calls read per chunk plus getSize per SEEK_END (llaudiodecodemgr.cpp:100-160).
    • 39k mesh fetches at login.
  • Fix: open once and hold the fd; fstat once; pread; one utimensat only when stale.
  • Confirmed. S-M.

Verify the cost (profile or timer) before and after changing it.

From the LL-origin inefficiency audit (finding T5). File/line references are from commit 0229f8872c; re-locate them before working. **`LLFileSystem` reopens the file for every operation** - **Where:** `llfilesystem/llfilesystem.cpp`. - The constructor does `fileExists` plus a `last_write_time` stat, and possibly `utime` (`:57-71, 300-359`). - `getSize()` opens an ifstream and seeks to the end (`:122-135`); `seek()` and `eof()` both call `getSize()` (`:176-179, 247`). - `read`/`write` open and close a stream each time (`:137-236`). - `getExists()` opens an ifstream and seeks to test for non-zero size (`:74-87`). - **Where it hurts:** - A mesh LOD cache hit costs ~4 opens plus 2 stats (`llmeshrepository.cpp:2046-2080`). - Vorbis decode calls `read` per chunk plus `getSize` per SEEK_END (`llaudiodecodemgr.cpp:100-160`). - 39k mesh fetches at login. - **Fix:** open once and hold the fd; `fstat` once; `pread`; one `utimensat` only when stale. - Confirmed. S-M. Verify the cost (profile or timer) before and after changing it.
sky_line added this to the Slipstream project 2026-10-06 15:04:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#301
No description provided.