Skip to content

Add bounded artifact cache hot paths for large-airport open#53

Open
EnJiang wants to merge 4 commits into
X-Plane:wed_270_releasefrom
EnJiang:pr/artifact-cache-speedups
Open

Add bounded artifact cache hot paths for large-airport open#53
EnJiang wants to merge 4 commits into
X-Plane:wed_270_releasefrom
EnJiang:pr/artifact-cache-speedups

Conversation

@EnJiang
Copy link
Copy Markdown
Contributor

@EnJiang EnJiang commented Mar 29, 2026

Why

Opening very large airports can spend a long time in first-screen setup because WED repeatedly re-parses OBJ/AGP resources, re-decodes textures, and reparses Navaid reference data even when those inputs have not changed.

In our local testing on a representative large airport package (ZGSZ), the source-backed path was a 20+ wating process everytime. The goal of this PR is to keep the existing synchronous loading model, but avoid doing the same expensive work again on warm reopens.

How

This PR adds a bounded on-disk artifact cache for WED resource hot paths.

What is cached:

  • OBJ geometry hot-path artifacts, so warm hits do not need to reparse .obj text.
  • Prepared texture artifacts, so warm hits do not need to re-decode source images.
  • Compressed texture artifacts, so warm hits can use glCompressedTexImage2D instead of paying driver-side on-the-fly compression again.
  • Navaid index artifacts, so warm hits do not need to reparse earth_nav.dat / atc.dat / apt.dat when the Navaid overlay is visible.

Storage model:

  • SQLite index
  • segment-based pack storage
  • bounded cache size with simple whole-segment eviction
  • current implementation uses a 16 GiB cap and 1 GiB segments

Important behavior notes:

  • This keeps the original synchronous load model. There is no async resource loading in this PR.
  • Cache miss behavior is unchanged: on miss, WED still falls back to the existing source-backed load path.
  • Cache entries are keyed from source inputs and internal schema/layout versions, so changed inputs naturally miss and rebuild.

User Interface

This PR adds a new top-level Performance menu with:

  • Cache Artifact (persistent toggle, default on)
  • Clear Artifact Cache

So users who do not want the cache can disable it, and users can explicitly clear the on-disk artifacts.

Measurements

Representative local measurements on ZGSZ:

  • sync prepared-texture hot path before compressed texture artifact: first draw about 6.3 s
  • fully warm compressed-artifact hot path after this PR: first draw about 1.7-1.8 s
  • when the Navaid overlay is visible, Navaid first-use parse dropped from about 0.49 s to about 0.009 s on warm hit

In short: this PR is aimed at large-airport reopen performance, and in our local measurements it moved the hot first-screen path from 20+ seconds down to about two seconds without changing WED's synchronous loading semantics.

Validation

Local validation performed on Windows:

  • Release build succeeds
  • cache clear and rebuild succeeds
  • warm reopen uses cache artifacts correctly
  • cache cap / menu controls work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant