Skip to content

perf: optimize directory cache and animation initialization - #22

Open
VanCZ1 wants to merge 1 commit into
ersh1:mainfrom
VanCZ1:optimize-loading-time
Open

perf: optimize directory cache and animation initialization#22
VanCZ1 wants to merge 1 commit into
ersh1:mainfrom
VanCZ1:optimize-loading-time

Conversation

@VanCZ1

@VanCZ1 VanCZ1 commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Optimized the logic of directory cache and animation initialization, significantly reducing loading time.

Core Changes

  • Directory cache

  • Remove the unused CachedModDirectory::entries.

  • Add PrecacheAnimationHash() to replace PrecacheAnimationHashes(), avoiding repeated traversal.

  • Add regularAnimationFiles in CacheAnimationFilesInDirectory(), avoiding repeated traversal.

  • Directory parsing

  • Capture cached CachedModDirectory and CachedLegacySubMod nodes by pointer, avoiding deep copying. Keep the shared lock on g_directoryCache.cacheLock held until the workerPool has finished.

  • Animation initialization

  • Add _animationPathToIndexMap to replace repeated linear scans in ReplacerProjectData::TryAddAnimationToAnimationBundleNames().

  • Call SubMod::AddReplacerProject() and SubMod::SortReplacementAnimationsByPath() in subModsToUpdate rather than after every insertion.

  • Call SubMod::InitializeReplacementAnimation() for every insertion, avoiding repeated traversal in subModsToUpdate, and use Utils::ComparePaths() to keep the path-matching behavior of SubMod::LoadReplacementAnimationDatas().

Testing

  • Built on Windows and tested in-game.
  • Performed cold-start testing and recorded the timing data.

@VanCZ1

VanCZ1 commented Aug 9, 2026

Copy link
Copy Markdown
Author

OpenAnimationReplacer_3.2.0.log
OpenAnimationReplacer_fork.log
Total time for each of the 4 stages:
28644ms->18732ms
3336ms->115ms
3978ms->109ms
135ms->9ms

@VanCZ1

VanCZ1 commented Aug 9, 2026

Copy link
Copy Markdown
Author

This check is failed because github now blocks checking out fork pr code in pull_request_target workflows

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