Realize less of the syntax tree during AbstractSemanticModelReuseLanguageService.GetPreviousBodyNode #77032
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.
During the typing scenario in the scrolling speedometer test, about 13% of allocations in VS are under GetPreviousBodyNode, due to realizing a bunch of nodes in the syntax tree to attempt to map from a method node in one tree to the corresponding node in similarly structured tree. Instead, as we know the trees have similar structure, just walk up the ancestors in the current tree to generate a node index path, and apply that path to the previous tree to find the appropriate method node.
*** Without change ***
![image](https://private-user-images.githubusercontent.com/6785178/409723800-f196c583-f95e-4bac-bfa8-3679c9c710d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4ODc2MTAsIm5iZiI6MTczODg4NzMxMCwicGF0aCI6Ii82Nzg1MTc4LzQwOTcyMzgwMC1mMTk2YzU4My1mOTVlLTRiYWMtYmZhOC0zNjc5YzljNzEwZDgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMDAxNTEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWYwMmQ3N2Y1OWRkYzJiMTI5MWI4NzBmMzQ2M2Q4ZjQ3ZmM0NzVlNTk3ZmNkMjY2NzFjZDk5ODFmOTc5OTZmNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.VB2a1xr5yCO0Hx-FiqifgPO7TYMq-wpS4goRwy-VSyY)
13% of VS allocations during typing:
Types allocated under GetPreviousBodyNode:
![image](https://private-user-images.githubusercontent.com/6785178/409723852-fba2b4be-00c1-4e93-87c7-2f5576571a5d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4ODc2MTAsIm5iZiI6MTczODg4NzMxMCwicGF0aCI6Ii82Nzg1MTc4LzQwOTcyMzg1Mi1mYmEyYjRiZS0wMGMxLTRlOTMtODdjNy0yZjU1NzY1NzFhNWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMDAxNTEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmEzNTljNGYyMWRjNTJjMzNhNmMyMTY1Y2ExZTY1NzcyMDI0NGJiOWQzNGRmYWI1ZjlkNWM5MDUwYmU4NmI5NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ijae8jdw5gfUT9Th7fhbB_y-UOSBf_2AybI0x9E47x8)
*** With change ***
![image](https://private-user-images.githubusercontent.com/6785178/410008798-12a23d1b-ea07-475f-b1b3-cded5a6de921.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4ODc2MTAsIm5iZiI6MTczODg4NzMxMCwicGF0aCI6Ii82Nzg1MTc4LzQxMDAwODc5OC0xMmEyM2QxYi1lYTA3LTQ3NWYtYjFiMy1jZGVkNWE2ZGU5MjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMDAxNTEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODViMzRkODlhZmUwMDk0MWUyNjdlNGI5ODA1ZWQ5NTYxZTg2OGQzNGYwODUwZjFjMzJmZDIzMjA2ZWQ0NTE3ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.AVA-qI97158y3nbU08YDnD2_fquYp2JdjGQAWCaUUwA)
0.3% of VS allocations during typing:
Types allocated under GetPreviousBodyNode:
![image](https://private-user-images.githubusercontent.com/6785178/410007968-3b09ea9b-477b-4b04-9df5-a218ada437d3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4ODc2MTAsIm5iZiI6MTczODg4NzMxMCwicGF0aCI6Ii82Nzg1MTc4LzQxMDAwNzk2OC0zYjA5ZWE5Yi00NzdiLTRiMDQtOWRmNS1hMjE4YWRhNDM3ZDMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDdUMDAxNTEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZGY2NjljMjdjODMzNGI1ZWRmNGY3Y2IzODcwMGY5ZWZiZjNkNjAxNTI4ZjczZjUyZDMxM2JlNjk5OGRjMTkyNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.kIaY-o1DE9hwxKxWErWdjluWBEiyIxmgijDUQU93BNk)