[Repo Assist] perf: cache settings per workspace folder to skip redundant loadSettings() calls#115
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…ngs() calls On every format(), loadSettings(document.uri) was called unconditionally, triggering workspace.getConfiguration() + all downstream path-resolution work even when settings had not changed. With formatOnSave enabled this fires on every Ctrl+S. Add _lastSettingsKey (workspace folder URI string) so loadSettings() is a no-op when called again for the same workspace folder. The key is cleared by clearSettingsCache() which is now called from onDidChangeConfiguration so any settings change still triggers a fresh read. Multi-root workspaces are handled correctly: distinct workspace folders have distinct keys, so each folder's settings are loaded independently. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 29, 2026
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.
🤖 This is an automated draft PR from Repo Assist, an AI assistant.
Summary
Every call to
format()invokesloadSettings(document.uri)unconditionally. WithformatOnSaveenabled, this fires on everyCtrl+S, triggeringworkspace.getConfiguration()plus all downstream string-manipulation (path prefix resolution,~expansion,\$\{workspaceFolder}substitution) on every save — even when nothing has changed.Root cause
loadSettings()was designed to pick up the correct scoped configuration per document so multi-root workspaces work. But once settings are loaded for a given workspace folder they remain valid until the user explicitly changes aphpcbf.*setting. There was no caching, so the work was repeated on every save.Changes
extension.jsthis._lastSettingsKey = nullfield in the constructor — tracks the workspace-folder URI of the last successfulloadSettings()call.clearSettingsCache()one-liner method that resets_lastSettingsKey.loadSettings(): if the new call resolves to the same workspace folder as last time, skip the reload entirely.onDidChangeConfigurationhandler to callclearSettingsCache()beforeloadSettings()so any settings change still triggers a fresh read.Behaviour unchanged when:
onDidChangeConfiguration→clearSettingsCache()→ reload)'', guard is skipped — always reloads, conservative)Relationship to other open PRs
This PR is complementary to existing performance PRs:
findFiles()filesystem walksThis PR eliminates the
workspace.getConfiguration()call overhead on every save, which is the first thingformat()does before either of the above code paths even run.Test Status
node --check extension.jsnpm run test:unit(7 findFiles unit tests)(Integration tests require the VS Code GUI environment and cannot run in CI.)