LL perf (Textures/assets): Texture cache I/O pattern and LRU #300

Closed
opened 2026-10-04 14:09:14 +00:00 by sky_line · 1 comment
Owner

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

Texture cache I/O pattern and LRU

  • Lookup: openAndReadEntry re-reads a 28-byte entry from texture.entries with open/seek/read/close under mHeaderMutex (:1179, 1232-1238). The entries were loaded at startup and discarded.
  • Reads: doRead opens 3 times (:413, 449, 490).
  • Writes: reopen texture.entries every time (:1196-1228).
  • LRU (top-10 #4):
    • The timestamp update is gated at 75% full (:1248-1265), so mTime is the first-write time.
    • mLRU is a std::set<LLUUID>, consumed in UUID order rather than age order (:1140-1155, 1538).
  • Fix:
    • Keep a RAM entry vector (~6 MB at 223k entries).
    • Keep fds open; use pread/pwrite; take the body size from the entry.
    • Always update the timestamp in RAM and flush dirty entries in batches.
    • Sort the LRU by time.
  • Confirmed. S (LRU) / M (I/O).

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

From the LL-origin inefficiency audit (finding T3). File/line references are from commit 0229f8872c; re-locate them before working. **Texture cache I/O pattern and LRU** - **Lookup:** `openAndReadEntry` re-reads a 28-byte entry from `texture.entries` with open/seek/read/close under `mHeaderMutex` (`:1179, 1232-1238`). The entries were loaded at startup and discarded. - **Reads:** `doRead` opens 3 times (`:413, 449, 490`). - **Writes:** reopen `texture.entries` every time (`:1196-1228`). - **LRU (top-10 #4):** - The timestamp update is gated at 75% full (`:1248-1265`), so `mTime` is the first-write time. - `mLRU` is a `std::set<LLUUID>`, consumed in UUID order rather than age order (`:1140-1155, 1538`). - **Fix:** - Keep a RAM entry vector (~6 MB at 223k entries). - Keep fds open; use `pread`/`pwrite`; take the body size from the entry. - Always update the timestamp in RAM and flush dirty entries in batches. - Sort the LRU by time. - Confirmed. S (LRU) / M (I/O). Verify the cost (profile or timer) before and after changing it.
Author
Owner

Part of #405 (RAM/VRAM management epic).

Part of #405 (RAM/VRAM management epic).
sky_line added this to the Slipstream project 2026-10-06 15:04:14 +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.

Reference
sky_line/Slipstream#300
No description provided.