Skip to content
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

Use forattributename jsgenerator #78136

Merged
merged 3 commits into from
Nov 17, 2022

Conversation

chsienki
Copy link
Member

Updates the JSImportGenerator and JSExportGenerator to use ForAttributeWithMetadataName (instead of directly creating a syntax provider) which improves performance.

@ghost
Copy link

ghost commented Nov 10, 2022

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Issue Details

Updates the JSImportGenerator and JSExportGenerator to use ForAttributeWithMetadataName (instead of directly creating a syntax provider) which improves performance.

Author: chsienki
Assignees: -
Labels:

area-System.Runtime.InteropServices

Milestone: -

@teo-tsirpanis teo-tsirpanis modified the milestones: 7.0.x, 8.0.0 Nov 10, 2022
@teo-tsirpanis
Copy link
Contributor

(if you want to backport it, the PR targeting release/7.0 should be in the 7.0.x milestone)

static modelData => modelData is not null);
.ForAttributeWithMetadataName(Constants.JSExportAttribute,
static (node, ct) => node is MethodDeclarationSyntax,
static (context, ct) => new { Syntax = (MethodDeclarationSyntax)context.TargetNode, Symbol = (IMethodSymbol)context.TargetSymbol });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are pushing symbols down in the pipeline, which affects incrementality.

Fixing it may require more extensive refactorings which I don't know if it can be backported, but I think for this PR that will go to 8, we should do it the right way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the symbols issue, but this was being done before. This PR doesn't change that, just makes the existing logic more efficient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generator (along with the rest of the interop generators) use symbols for a few steps until we are able to build a model that does not contain symbols at a named step "CalculateStubInformation". From that point onwards, the generators are incremental. We can't do incrementality earlier as we need to get the symbols as well as some additional information from the Compilation.

static modelData => modelData is not null);
.ForAttributeWithMetadataName(Constants.JSImportAttribute,
static (node, ct) => node is MethodDeclarationSyntax,
static (context, ct) => new { Syntax = (MethodDeclarationSyntax)context.TargetNode, Symbol = (IMethodSymbol)context.TargetSymbol });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@chsienki chsienki merged commit 4acfa64 into dotnet:main Nov 17, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2022
@RikkiGibson
Copy link
Contributor

We are seeing some heavy memory use from before this change show up in some VS perf traces. We might want to backport this change to 7 and 6. cc @CyrusNajmabadi.

image
image

@CyrusNajmabadi
Copy link
Member

Did this generator ship before net8? Or was it just added in net8? If so, we may just be behind wrt picking up this fix in Roslyn.

@jkoritzinsky
Copy link
Member

It shipped in .NET 7.

@CyrusNajmabadi
Copy link
Member

@jkoritzinsky thanks. Can we backport toys fix to 7.0? It's fairly brutal :-)

@jkoritzinsky
Copy link
Member

We should be able to. I'll try the backport bot on this and follow up on Monday to get it through servicing.

@github-actions github-actions bot unlocked this conversation Apr 15, 2023
@jkoritzinsky
Copy link
Member

/backport to release/7.0-staging

@github-actions
Copy link
Contributor

Started backporting to release/7.0-staging: https://github.com/dotnet/runtime/actions/runs/4706135407

@dotnet dotnet deleted a comment from github-actions bot Apr 15, 2023
@github-actions
Copy link
Contributor

@jkoritzinsky backporting to release/7.0-staging failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Use ForAttributeWithMetadataName instead of CreateSyntaxProvider
Applying: Remove unused code
error: sha1 information is lacking or useless (src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSImportGenerator.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 Remove unused code
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@jkoritzinsky an error occurred while backporting to release/7.0-staging, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@jkoritzinsky
Copy link
Member

I'll manually backport this on Monday.

@CyrusNajmabadi
Copy link
Member

Thanks!

@jkoritzinsky
Copy link
Member

Backport PR at #84936

jkoritzinsky pushed a commit to jkoritzinsky/runtime that referenced this pull request Apr 17, 2023
* Use ForAttributeWithMetadataName instead of CreateSyntaxProvider

* Remove unused code

* Update export generator too
jkoritzinsky added a commit that referenced this pull request Apr 21, 2023
Co-authored-by: Chris Sienkiewicz <chsienki@microsoft.com>
@ghost ghost locked as resolved and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants