-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dedicated bit for indicating if a node itself has annotations (versus its children). #72104
Conversation
…rsus its children).
System.Diagnostics.Debug.Assert(annotations.Length != 0, "we should return nonempty annotations or NoAnnotations"); | ||
return annotations; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the meat of the change. In the past, we'd end up lookign at nodes that didn't actually have annotations on htem, because they had a child somewhere deep under them with annotations. This was very expensive as CWT lookups are not cheap. For tree rewrites, when rewriting nodes , we look at the old node to copy annotations over. And this meant almost always doing this work just if a deep child token had an annotation. now we only need to do the work on nodes that actually have annotations on them themselves.
@RikkiGibson @sharwell @333fred this is ready for review. |
Followup to #72070. Draft while that is in review.
This helps avoid expensive conditionalweaktable lookups. This is especially useful when examining trees for things like elastic trivia. We end up seeing that some child has annotations deep in a node. But we need to examine all the nodes down to the child to see if they have annotations on them (since we can't distinguish 'has' vs 'contains'). For large trees, where all the tokens have elastic trivia, this is incredibly expensive.