Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCommon: optimize asset loading system #12916

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

iwubcode
Copy link
Contributor

@iwubcode iwubcode commented Jul 4, 2024

This PR updates the asset loading system to optimize it. A brief overview is given below.

The old system

  • Used a recursive_mutex, this seems to have had a chance to cause a crash on some MacOS machines
  • Stuck everything into a single queue, loading everything after the other, users would report up to 30 seconds of wait time for initial texture loads with prefetch turned on. I could never replicate that but even on my modern machine, I would see up to 14 seconds for the textures I was interested in when toggling the load textures from a scene
  • To handle realtime reloads of assets (for dynamic-input-textures [DIT] or manual asset edits), a separate thread existed that would peg the system every 500ms, looping over all assets to see if any were updated (this could have been a huge part of the performance bottleneck on bulk loading textures?)

The new system

  • Assets can now be loaded in parallel by multiple threads. I currently have 2 threads defined but a future PR will likely create a setting to make this customizable
  • There is a priority system. The system now tracks the last frame count for when an asset is used, assets with more recent frame counts are preferred over earlier ones
  • I now use a library watcher to get told by the filesystem that an asset has changed. This marks the asset for reload. Avoiding the overhead of polling every asset for changes
  • Assets can now be manually requested to be reloaded (used in my editor)

Testing

I have tested on Windows (11) both DIT and texture pack loads. The 'watcher' library has a couple of minor Windows bugs that I am working with the author to iron out but they shouldn't block this feature. (EDIT: Done) I need testing from other platforms (Android, Mac, Linux) to confirm all functionality operates and to get feedback from users with lower end system.

Windows DIT: Working
Windows Performance Experience: Positive, noticeably faster
MacOS DIT: Working
MacOS Performance Experience: --
Linux DIT: --
Linux Performance Experience: --
Android DIT: --
Android Performance Experience: --

@iwubcode iwubcode force-pushed the asset_system_optimization branch 3 times, most recently from d7764dc to 39cb24f Compare July 12, 2024 03:32
iwubcode added 4 commits July 13, 2024 22:53
… threads, leverage a priority system so that assets being used recently are preferred, and avoid recursive mutex locking
…d in without the DirectFilesystemAssetLibrary dependencies, the header will be expanded later
@Tilka
Copy link
Member

Tilka commented Aug 7, 2024

Not sure if relevant but we use QFileSystemWatcher for the game list. I guess it makes sense not to depend on Qt for this.

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

Successfully merging this pull request may close these issues.

2 participants