Repository navigation
[PluginMessageHandling] Cache decoded StaticBuildConfiguration - #3468
Merged
Merged
Conversation
PluginProviderMessageHandler decoded the static build configuration JSON for every expandFreestandingMacro and expandAttachedMacro message, even though a compiler sends the same configuration for the whole compile. Keep the decoded configurations in a small LRU cache keyed by their JSON representation. A single handler can serve multiple compiler instances with different configurations, e.g. through SourceKit's shared plugin registry or the process-wide in-process plugin server, so the cache keeps more than the most recent configuration. rdar://189539737
rintaro
requested review from
hamishknight,
hborla and
nkcsgexi
as code owners
October 8, 2026 19:49
Member
Author
|
@swift-ci Please test |
Member
Author
|
@swift-ci Please test macOS |
Member
Author
|
@swift-ci Please test Linux |
hamishknight
approved these changes
Oct 8, 2026
hamishknight
left a comment
Contributor
There was a problem hiding this comment.
Depending on how expensive this is, I wonder if it would be worth seeing if we could hash the configuration on the compiler side, and send that hash along with the configuration? That way the plugin is still a pure function but doesn't have to keep re-hashing the same (potentially quite large) string
Member
Author
|
@swift-ci Please test Linux |
Member
Author
|
swiftlang/swift#93092 |
Member
Author
|
swiftlang/swift#93092 |
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.
PluginProviderMessageHandlerdecoded the static build configuration JSON for everyexpandFreestandingMacro/expandAttachedMacromessage, even though a compiler sends the same configuration for the whole compile.This change keeps the decoded configurations in a small
LRUCachekeyed by their JSON representation, so a configuration is decoded once and reused for later messages that carry the same JSON. A single handler can serve multiple compiler instances with different configurations, so the cache keeps more than the most recent one:Configurations that fail to decode still produce
niland are not cached.Related: swiftlang/swift#93083, which builds the configuration and its JSON once per
ASTContext.rdar://189539737