Repository navigation
Skip cache digest scans that can't find anything - #2775
Merged
Merged
Conversation
`Resolver#explicit_dependencies` scanned every Ruby source and template for `# Template Dependency:` with a regular expression, although almost none declare one; check for the literal first. `DependencyTracking` translated declared class names in synthetic templates, whose declarations the resolver already wrote as paths; return their dependencies before that pass.
Contributor
Author
|
PS: Thanks for the quick merges of previous performance PRs. I think this is the last one from me for now. |
Member
|
@erikaxel thanks for the fixes! I'm hoping we are close to the point where the caching feature does not have too much of a performance penalty, especially since we've done other things to speed up compilation. If this continues to be an issue, we could look at adding the ability to turn it off, but I'd rather avoid that route if possible. |
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.
What are you trying to accomplish?
A follow-up to #2769, #2771 and #2772. On 4.22.0, about 14% of a cold cache digest in our app (1,500 components, about 16 shared Ruby files each) goes to two scans that find nothing:
Resolver#explicit_dependenciesrunsEXPLICIT_DEPENDENCYover every Ruby source and template a component depends on. Almost none declare a# Template Dependency:, but the pattern starts with#\s*, so it's slow on Ruby sources, where#is common. This was 10.8% of a wall-clock profile of cold digests.DependencyTracking#find_dependenciesrunsexplicit_component_dependenciesover every synthetic template before returning its dependencies. The resolver already translated class names to paths when it wrote those declarations, so there is never anything to swap. This was 2.9%.Run alternately three times each against
main(4.22.0) on the same machine:precompute!over every component at bootDetailsKey.clearbefore eachAll 1,500 digests computed at boot are identical to 4.22.0, and so are the 152 cold digests.
What approach did you choose and why?
Resolver#explicit_dependenciescheckssource.include?("Template Dependency:")before scanning. The pattern can only match where that literal appears, so the result is unchanged.DependencyTracking#find_dependenciesnow returns a synthetic template's dependencies before the class-name translation rather than after it. Every declaration in a synthetic source comes fromResolver#dependencies, which has already translated the class names it could resolve. A name it couldn't resolve wouldn't resolve in a second pass either.Anything you want to highlight for special attention from reviewers?
Prism.parseandeach_nodeover each distinct source once and GC.