-
Notifications
You must be signed in to change notification settings - Fork 565
[WIP] [Xamarin.Android.Build.Tasks] use hashes as Inputs for _GenerateJavaStubs
#7694
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
Closed
jonathanpeppers
wants to merge
1
commit into
dotnet:main
from
jonathanpeppers:CalculateJavaStubHashStep
Closed
[WIP] [Xamarin.Android.Build.Tasks] use hashes as Inputs for _GenerateJavaStubs
#7694
jonathanpeppers
wants to merge
1
commit into
dotnet:main
from
jonathanpeppers:CalculateJavaStubHashStep
Conversation
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
Inputs for `_Gene…Inputs for _GenerateJavaStubs
Member
Author
|
Actually, looks like I have a small code change in java.interop. Looks like this won't build yet... |
jonathanpeppers
added a commit
to jonathanpeppers/java.interop
that referenced
this pull request
Jan 12, 2023
…anner Context: dotnet/android#7694 Add an overload of `JavaTypeScanner.GetJavaTypes()` that takes in a `Mono.Cecil.AssemblyDefinition` to be more easily consumed by linker steps.
8836f0f to
53eada2
Compare
jonpryor
pushed a commit
to dotnet/java-interop
that referenced
this pull request
Jan 18, 2023
#1076) Context: dotnet/android#7694 Add an overload of `JavaTypeScanner.GetJavaTypes()` that takes in a `Mono.Cecil.AssemblyDefinition`. This is more easily used by linker steps.
…rateJavaStubs`
One of the slower parts of an incremental Android build is:
_GenerateJavaStubs = 978 ms
Currently, this happens when any .NET assembly changes: C# change,
`.xaml` change, etc.
In theory, we could analyze .NET assemblies during the linker and
create a "hash" that represents types & members that would invalidate
`_GenerateJavaStubs`'s output. We can then save these hashes in a file
to be used as `Inputs` instead of the .NET assemblies themselves.
Example of the hash:
HashAlgorithm hasher = new Microsoft.Android.Build.Tasks.Crc64 ();
foreach (var type in scanner.GetJavaTypes (assembly)) {
Hash (hasher, type.FullName);
foreach (var method in type.Methods) {
Hash (hasher, method.Name);
}
}
The result is:
Target Name=_GenerateJavaStubs Project=bar.csproj
Skipping target "_GenerateJavaStubs" because all output files are up-to-date with respect to the input files.
Improving the incremental build time about about ~1 second in a
`dotnet new maui` project. `_LinkAssembliesNoShrink` will be slightly
slower, but because it builds partially it will only be creating this
hash on a single file most of the time. Currently, this seems to be
about ~20ms final numbers TBD.
Things left to do:
* Make sure we are hashing the right things that `_GenerateJavaStubs`
cares about.
* Fix `Release` builds, they likely aren't setup right.
* Add several tests around this scenario. We need to validate adding
new `Java.Lang.Object` subclasses work as expected.
53eada2 to
e4b6737
Compare
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
Due to the various errors trying to use I'm going to see if I can do this idea for |
Member
Author
|
Closing old PRs, will revisit later if needed. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
One of the slower parts of an incremental Android build is:
Currently, this happens when any .NET assembly changes: C# change,
.xamlchange, etc.In theory, we could analyze .NET assemblies during the linker and create a "hash" that represents types & members that would invalidate
_GenerateJavaStubs's output. We can then save these hashes in a file to be used asInputsinstead of the .NET assemblies themselves.Example of the hash:
The result is:
Improving the incremental build time about about ~1 second in a
dotnet new mauiproject._LinkAssembliesNoShrinkwill be slightly slower, but because it builds partially it will only be creating this hash on a single file most of the time. Currently, this seems to be about ~20ms final numbers TBD.Things left to do:
Make sure we are hashing the right things that
_GenerateJavaStubscares about.Fix
Releasebuilds, they likely aren't setup right.Add several tests around this scenario. We need to validate adding new
Java.Lang.Objectsubclasses work as expected.