-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a UserType flag for registered types, and use it to improve the p…
…erformance for is_user_type. (#5017) * Refactor type map to have a separate flag field for each type instead of magic location in the array. Refactor the type map to have a separate flag field for each type instead of a magic location in the array. This simplifies some code, but also allows us to introduce more flags in the future (which becomes increasingly complex if the location in the array is to determine yet another value). This has neglible performance impacts. * Add a UserType flag for registered types, and use it to improve the performance for is_user_type. Reflection in the Objective-C runtime is apparently quite slow, so try to avoid it by computing the information we need for determining whether a particular Objective-C type represents a user type or not in the static registrar. We store this information in a flag for the type in question in the type map, and use a binary search to search the type map when needed. This provides a significant improvement, in particular in the dontlink scenario (probably because there are many more Objective-C types in the app, which made Objective-C reflection slow). In fact, it somehow made the dontlink scenario so fast that it's faster than the linkall scenario (which also improved, but not nearly as much). While quite inexplicable, it's a consistent result I've seen over multiple test runs. Numbers ======= Test case: rolfbjarne/TestApp@004283d Fix 1 refers to PR #5009. Fix 2 refers to PR #5013. Fix 3 refers to PR #5016. Fix 4 is this fix. iPad Air 2 ---------- | Configuration | Before | After fix 1 | After fix 2 | After fix 3 | After fix 4 | Improvement from fix 3 to fix 4 | Cumulative improvement | | ------------------- | ------ | ----------: | -----------: | -----------: | -----------: | ------------------------------: | ---------------------: | | Release (link all) | 477 ms | 481 ms | 224 ms | 172 ms | 148 ms | 24 ms (14%) | 329 ms (69%) | | Release (dont link) | 738 ms | 656 ms | 377 ms | 201 ms | 146 ms | 55 ms (27%) | 592 ms (80%) | iPhone X -------- | Configuration | Before | After fix 1 | After fix 2 | After fix 3 | After fix 4 | Improvement from fix 3 to fix 4 | Cumulative improvement | | ------------------- | ------ | ----------: | -----------: | -----------: | -----------: | ------------------------------: | ---------------------: | | Release (link all) | 98 ms | 99 ms | 42 ms | 31 ms | 29 ms | 2 ms ( 6%) | 69 ms (70%) | | Release (dont link) | 197 ms | 153 ms | 91 ms | 43 ms | 28 ms | 15 ms (35%) | 169 ms (86%) | When linking all assemblies, the type map has 24 entries, and when not linking at all it has 2993 entries. This is part 4 (the last) of multiple fixes for #4936. The total speed-up is 69-86% (3-7x faster).
- Loading branch information
1 parent
097e3fc
commit c378d6b
Showing
5 changed files
with
77 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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