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

[Xamarin.Android.Build.Tasks] avoid FileNotFoundException in LinkAssemblies #2487

Merged

Conversation

jonathanpeppers
Copy link
Member

Context: https://github.com/Microsoft/perfview

When reviewing the .NET exception report in PerfView, I noticed a
FileNotFoundException thrown for every assembly such as:

Throw(System.IO.FileNotFoundException) Could not find file 'samples\HelloWorld\bin\Debug\HelloWorld.dll.mdb'.

All coming from the LinkAssemblies MSBuild task.

Reviewing the code, it appears we were affectively causing a throw new FileNotFoundException + catch for every instance where an mdb
file was missing!

I reworked the mdb code in LinkAssemblies to match what we are doing
for pdb files. It is an order of magnitude faster to check
File.Exists over throw + catch, especially when the file will
most likely not exist.

The results seem to be a ~29ms improvement:

Before:
445 ms  LinkAssemblies                             1 calls
After:
416 ms  LinkAssemblies                             1 calls

Other changes:

  • The pdb copying code here had a Path.Combine (copydst, filename)
    where we could use the assemblyDestination variable instead. This
    will give a slight perf benefit as well: not concatenating a string.

…mblies

Context: https://github.com/Microsoft/perfview

When reviewing the .NET exception report in PerfView, I noticed a
`FileNotFoundException` thrown for every assembly such as:

    Throw(System.IO.FileNotFoundException) Could not find file 'samples\HelloWorld\bin\Debug\HelloWorld.dll.mdb'.

All coming from the `LinkAssemblies` MSBuild task.

Reviewing the code, it appears we were affectively causing a `throw
new FileNotFoundException` + `catch` for every instance where an mdb
file was missing!

I reworked the mdb code in `LinkAssemblies` to match what we are doing
for pdb files. It is an order of magnitude faster to check
`File.Exists` over `throw` + `catch`, especially when the file will
most likely not exist.

The results seem to be a ~29ms improvement:

    Before:
    445 ms  LinkAssemblies                             1 calls
    After:
    416 ms  LinkAssemblies                             1 calls

Other changes:

- The pdb copying code here had a `Path.Combine (copydst, filename)`
  where we could use the `assemblyDestination` variable instead. This
  will give a slight perf benefit as well: not concatenating a string.
@jonathanpeppers
Copy link
Member Author

Binlogs: logs.zip

The project used here was the Xamarin.Forms integration project, in this repo.

@jonpryor jonpryor merged commit 8d540fe into dotnet:master Dec 5, 2018
@jonathanpeppers jonathanpeppers deleted the linkassemblies-filenotfoundexception branch May 20, 2019 16:54
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants