Skip to content

fix: high cpu and ram usage when using walkdir#9

Open
dronesimyt wants to merge 1 commit into
headwindsim:v2.0from
dronesimyt:fix/remove-walkdir
Open

fix: high cpu and ram usage when using walkdir#9
dronesimyt wants to merge 1 commit into
headwindsim:v2.0from
dronesimyt:fix/remove-walkdir

Conversation

@dronesimyt

Copy link
Copy Markdown

Summary of Changes

This PR addresses the critical performance regression where the installer would hang or "freeze" upon launch.
This PR is analog to the same fix on the FBW installer flybywiresim/installer#536

Following text is credited to the original author of the fix at FBWs repo https://github.com/schembriaiden

The Problem (Root Cause)

The msfsBasePath utility uses a recursive disk walk (walkdir) as a fallback to find the simulator's UserCfg.opt file. This mostly becomes an issue when users don't have both simulators installed.

  • Performance Hit: The search started at the root of %LOCALAPPDATA%, forcing the app to scan tens of thousands of unrelated files (Chrome, Discord, etc.) synchronously on the UI thread.
  • Logic Error: Steam installations store this configuration in the Roaming folder (%APPDATA%), meaning the brute-force search in the Local folder was scanning the entire wrong directory for Steam users, ensuring a long wait followed by a failed detection.
  • Redundancy: These checks were triggered multiple times during the settings initialization, multiplying the lag. (4 times for every simulator meaning going through %LOCALAPPDATA% up to 8 times.)

Solution

  1. Eliminated Recursive Scan: Removed the walkdir fallback. The installer now checks only the well-known standard paths for Steam and Microsoft Store editions.
  2. Implemented Memory Caching: Added basePathCache and communityDirCache. Since these functions are called frequently by the settings schema and UI components, the cache ensures that disk I/O (checking file existence/reading configs) only happens once per session.
  3. Graceful Fallback: If a user has a non-standard installation, the installer will now immediately show the "Path Missing" dialog for manual selection, which is significantly faster and more reliable than an automated brute-force search.

Impact

  • Startup Speed: Startup is now near-instant like before.
  • UI Responsiveness: The app no longer freezes and can immediately begin downloading configuration data on launch.

Discord username (if different from GitHub): dronesim

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