Open
Conversation
#typeInfoForFqn() splits FQN strings and performs Map lookups on every method invocation and property access. Since assemblies are immutable after load, cache the result for O(1) subsequent lookups. Cache is cleared on assembly load to prevent stale entries. Callers must not mutate returned spec.Type objects. Estimated 20-30% reduction in kernel dispatch overhead.
a483efd to
6d11103
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.
Summary
#typeCacheMap for O(1) FQN-to-Type lookups (replacing repeated string splits + Map lookups)#methodMapCacheand#propertyMapCachefor cached method/property resolutionMotivation
#typeInfoForFqn()is called on every method invocation, property access, and object creation. It splits the FQN string and does multiple Map lookups each time. Since assemblies are immutable after load, this result can be safely cached.Changes
packages/@jsii/kernel/src/kernel.ts: Add type cache with lazy population and blanket invalidation on assembly loadpackages/@jsii/kernel/src/kernel.test.ts: Add tests for cache hits, multi-assembly resolution, and cache invalidationImpact
#fieldsspec.Typeobjects (documented in comments)Test plan