Commit a547cb7
committed
[linker] move StripEmbeddedLibraries into the linker
Fixes: #1092
The `StripEmbeddedLibraries` MSBuild task can take 1-2 seconds, and it
mainly removes `__AndroidLibraryProjects__.zip` from assemblies.
If we moved this to happen during linking, it has various benefits:
- The linker already has every assembly opened and loaded.
- We know if the linker is going to `Skip`/`Delete` an assembly, so we
can likewise skip it.
- The linker writes all the assemblies out at the end, so we don't
have a second "write" step.
Changes to make this happen:
- Removed the `StripEmbeddedLibraries` MSBuild task and related
targets
- Removed `$(_AndroidStripFlag)` from our targets, since it is no
longer used
- Created a new `StripEmbeddedLibraries` linker step that runs late
during linking
- Removed a `RemoveLibraryResourceZip` linker step, as it seemed to be
duplicative.
I timed before and after with the Xamarin.Forms test project:
.\bin\Debug\bin\xabuild .\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj /p:Configuration=Release /t:Clean
.\bin\Debug\bin\xabuild .\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj /p:Configuration=Release /t:Build /bl
Before:
1233 ms StripEmbeddedLibraries 1 calls
14925 ms LinkAssemblies 1 calls
After:
15437 ms LinkAssemblies 1 calls
As expected, `LinkAssemblies` will be slightly slower. But since
`StripEmbeddedLibraries` is not called at all, we have a net gain of
around 700ms.
Once this has been merged and working for `Release` builds, I plan to
do some further research to find out if running the new
`StripEmbeddedLibraries` linker step will help for `Debug` builds. It
could be a net performance improvement, if the time taken to remove
these files improves deployment and app startup times.
Greatly expanded upon an existing test:
- Made it a Xamarin.Forms project
- Moved the `AndroidEnvironment` item to a referenced library project
- Added an `$(AndroidLinkSkip)` option for a support library assembly
- Made sure the `$(AndroidLinkSkip)` assembly is saved and stripped
- Check and make sure `EmbeddedResource` items are stripped at the end
Other changes:
- Removed some assertions in tests looking for
`_StripEmbeddedLibraries`, since it is removed now.1 parent 743e69a commit a547cb7
File tree
9 files changed
+119
-169
lines changed- src/Xamarin.Android.Build.Tasks
- Linker/MonoDroid.Tuner
- Tasks
- Tests/Xamarin.Android.Build.Tests
9 files changed
+119
-169
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
114 | 113 | | |
115 | 114 | | |
116 | 115 | | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 72 | | |
91 | 73 | | |
92 | 74 | | |
| |||
Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 49 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
839 | 840 | | |
840 | 841 | | |
841 | 842 | | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | 843 | | |
846 | 844 | | |
847 | 845 | | |
| |||
875 | 873 | | |
876 | 874 | | |
877 | 875 | | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | 876 | | |
882 | 877 | | |
883 | 878 | | |
| |||
1571 | 1566 | | |
1572 | 1567 | | |
1573 | 1568 | | |
1574 | | - | |
| 1569 | + | |
| 1570 | + | |
1575 | 1571 | | |
1576 | 1572 | | |
1577 | 1573 | | |
1578 | 1574 | | |
1579 | 1575 | | |
1580 | 1576 | | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
1587 | 1611 | | |
1588 | 1612 | | |
1589 | 1613 | | |
| |||
1595 | 1619 | | |
1596 | 1620 | | |
1597 | 1621 | | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
1598 | 1634 | | |
1599 | 1635 | | |
1600 | 1636 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
197 | | - | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | 208 | | |
210 | 209 | | |
211 | 210 | | |
| |||
0 commit comments