css: fix language model cache evicting at capacity instead of overflow#309175
Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Open
css: fix language model cache evicting at capacity instead of overflow#309175yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The `getLanguageModelCache` eviction check used `===` to compare the current entry count against `maxEntries`, which triggered eviction as soon as the cache reached its maximum size. As a result the cache only held `maxEntries - 1` entries at steady state instead of the intended `maxEntries`. Changing the condition to `>` ensures eviction only occurs when the count exceeds `maxEntries`, allowing the cache to retain the full number of intended entries.
5a5ad69 to
273305c
Compare
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.
The
getLanguageModelCachefunction in the CSS language server uses===to check whether the current entry count equalsmaxEntries. This causes the cache to evict the oldest entry as soon as it reaches its configured maximum size, so the cache holds onlymaxEntries - 1entries at steady state instead of the intendedmaxEntries.The same issue was also present in the HTML language server (see companion fix in separate PR).
Fix: Change the condition from
nModels === maxEntriestonModels > maxEntries. Eviction now only occurs after the cache has grown beyond its limit.Before:
After:
With
maxEntries = 10(the value used in the CSS language server), this means the cache can now properly retain up to 10 parsed stylesheet models instead of 9.