Skip to content

Textures: keep the compressed cache across unrelated dependency updates - #3360

Merged
isaacsa2 merged 1 commit into
openOMSI-org:mainfrom
isaacsa2:perf/texture-cache-key
Oct 27, 2026
Merged

isaacsa2 merged 1 commit into
openOMSI-org:mainfrom
isaacsa2:perf/texture-cache-key

Conversation

@isaacsa2

@isaacsa2 isaacsa2 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes for the player?

Updating an unrelated dependency no longer makes openOMSI recompress every cached texture on the next start. Texture-code and decoder changes still invalidate the cache. This targets unnecessary loading work after updates, not the frame rate while driving.

How to test

Load a map to warm the compressed-texture cache, then compare builds that differ only in an unrelated dependency. Existing cached textures should be reused. A decoder or production texture-source change should rebuild them.

Screenshots

No visible change.

What changes, and why?

The source key in omsi-texture/build.rs used every published package in Cargo.lock. It now traverses only the published dependencies of omsi-texture (72 entries with the current lock), and excludes *_tests.rs from the source hash. Target, manifest, cache format, source-file metadata and content checks remain part of the key. Only this build script changes.

The release comparison in fork PR #322 found 8 invalidations in 12 releases with the old key and 4 with this key. That is a cache-key comparison, not a measured loading-time or FPS improvement.

Validation

  • Fork PR Self-steering or actively steered rear axles on articulated busses like Van Hool ag and agg300 and ikarus 280. #322: Release, workspace/platform tests, PR checks, CodeQL and secret scan passed on 1e43dda. Its texture suite reported 87 passing tests.
  • The branch merges cleanly with current upstream main.
  • Independent review: the Rust dependency selector matches a separate TOML traversal on the current lock (72 packages).
  • Four direct checks of the actual build script pass: an unrelated rustls-webpki update preserves the key; an image update changes it; a test-only source addition preserves it; a production-source addition changes it.
  • Fresh cargo test -p omsi-texture --locked against the branch merged with current upstream main: 87 passed, 0 failed. Size budget, crate layers and whitespace checks passed too.

Limits

The Windows cache hit across a real game update has not been checked here. A missed dependency could reuse stale compressed data, which is why relevant-source and decoder invalidation were checked explicitly.

Performance

No feature added. No new gameplay benchmark or FPS claim.

Source: isaacsa2#322

…e textures alone

The cache key held every published package of the workspace's lock, so any new crate
anywhere invalidated every compressed texture, and the first start after an update
compressed them all again (Brigadeiro V2 on an R7 260: 20 s for the first three tiles).
Of the last twelve releases, eight threw the cache away; four of them for crates such as
zip/zstd, rustls-webpki, unsafe-libopus or ctutils.

The key now holds only the packages omsi-texture is built from (image and its decoders,
texture2ddecoder, and what they use: 72 of the lock's entries), and leaves out the crate's
test-only files. Over the same twelve releases it changes four times, each a change of the
texture code itself.
@github-actions

Copy link
Copy Markdown
Contributor

Test builds for 1e43dda

Platform Download
Android (arm64) android.zip
Linux x64 (game and dedicated server) linux-x64.zip
macOS (Apple silicon) macos-arm64.zip
Windows x64 (game and dedicated server) windows-x64.zip
  • Unpack the download into a new folder, not over your openOMSI. The launcher shows the version as ...-pr3360, and a test build is never updated. It shares your settings and OMSI 2 folder; mods you installed into your openOMSI folder are only seen when you unpack it into a copy of that folder.
  • Android: the download holds an APK that installs as a separate app, openOMSI PR Textures: keep the compressed cache across unrelated dependency updates #3360, beside the release, and shares its openOMSI folder.
  • What to try is under How to test in the description. Please comment with what you found and the version the launcher shows.
  • The links work for 14 days after the build.

@thibautgnt thibautgnt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @isaacsa2, nice targeted fix: the key now follows only what can change a compressed texture, and I checked that it still does. A cache entry is a function of the file's bytes (xxh64 in Key::new), the extension, the GPU options, omsi-texture's own sources and the decoders, and omsi-cfg only reads the files (whose bytes are in the key), resolves paths and reads sidecar flags that never reach the stored texture. Running the same traversal on the current lock gives the 72 packages, with image, its decoders (zune-jpeg, png, tiff, exr, image-webp, gif, qoi, zlib-rs...), texture2ddecoder and rayon all in, and format_tests.rs / transparency_tests.rs are both #[cfg(test)] only, so leaving them out is safe.

Non-blocking:

  1. crates/omsi-texture/build.rs:52: Cargo writes a dependency as "name version (source)" when two packages share a name and version from different sources. split_once(' ') then compares "1.2.3 (registry+...)" with the entry's version, the dependency is skipped silently, and an update of it would no longer invalidate the cache. Nothing in today's lock has that form, but taking only the second whitespace token (dep.split_whitespace().nth(1)) closes it for free.
  2. image's feature list lives in the root Cargo.toml ([workspace.dependencies]), which is not in the key (it was not before either). A feature that adds or removes a decoder crate shows up in the lock, so it is covered; one that only toggles code inside image is not. Feeding just that image = ... line would cover it without bringing back the invalidations on unrelated workspace changes. Fine as a follow-up.

@isaacsa2
isaacsa2 merged commit 1dcd9ae into openOMSI-org:main Oct 27, 2026
13 checks passed
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.

2 participants