Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Feb 14, 2024

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.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 14, 2024 19:02
@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 14, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as draft February 14, 2024 19:03
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review February 15, 2024 18:48
System.Diagnostics.Debug.Assert(annotations.Length != 0, "we should return nonempty annotations or NoAnnotations");
return annotations;
}
}
Copy link
Member Author

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.

@CyrusNajmabadi
Copy link
Member Author

@RikkiGibson @sharwell @333fred this is ready for review.

@CyrusNajmabadi CyrusNajmabadi merged commit c123404 into dotnet:main Feb 15, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the hasAnnotations branch February 15, 2024 22:36
@ghost ghost added this to the Next milestone Feb 15, 2024
@jjonescz jjonescz modified the milestones: Next, 17.10 P2 Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants