fix: high cpu and ram usage when using walkdir#9
Open
dronesimyt wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
msfsBasePathutility uses a recursive disk walk (walkdir) as a fallback to find the simulator'sUserCfg.optfile. This mostly becomes an issue when users don't have both simulators installed.%LOCALAPPDATA%, forcing the app to scan tens of thousands of unrelated files (Chrome, Discord, etc.) synchronously on the UI thread.%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.%LOCALAPPDATA%up to 8 times.)Solution
walkdirfallback. The installer now checks only the well-known standard paths for Steam and Microsoft Store editions.basePathCacheandcommunityDirCache. 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.Impact
Discord username (if different from GitHub): dronesim