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

[Class] Sort our array of Class -> token references so that we can do binary instead of linear searches in it. #5009

Merged
merged 1 commit into from
Oct 19, 2018

Commits on Oct 18, 2018

  1. [Class] Sort our array of Class -> token references so that we can do…

    … binary instead of linear searches in it.
    
    Our type map has two sections: first come all the wrapper types, then all the
    custom types. This means we need to sort these two sections separately, since
    code elsewhere depends on this split in order to determine if a type is a
    custom type or not.
    
    We also need a minor modification in the array of skipped types, since it
    contained indexes into the type map, which won't be valid after is has been
    sorted. Instead store a type reference for the actual type in the array, and
    use that to search the type map for the corresponding Class. This is a little
    bit slower, but the results are cached in a dictionary, so it'll only happen
    once for each type.
    
    The performance is slightly slower when the type map has very few entries, but
    that is repaid many times over when the number of entries go up.
    
    Numbers
    =======
    
    Test case: rolfbjarne/TestApp@004283d
    
    iPad Air 2
    ----------
    
    | Configuration       | Before | After  | Improvement   |
    | ------------------- | ------ | ------ | ------------: |
    | Release (link all)  | 477 ms | 481 ms | -4 ms (-0,8%) |
    | Release (dont link) | 738 ms | 656 ms |   82 ms (11%) |
    
    iPhone X
    --------
    
    | Configuration       | Before | After  | Improvement |
    | ------------------- | ------ | ------ | ----------: |
    | Release (link all)  |  98 ms |  99 ms | -1 ms (-1%) |
    | Release (dont link) | 197 ms | 153 ms | 44 ms (22%) |
    
    When linking all assemblies, the type map has 24 entries, and when not linking
    at all it has 2993 entries.
    
    This is part 1 of multiple fixes for xamarin#4936.
    rolfbjarne committed Oct 18, 2018
    Configuration menu
    Copy the full SHA
    f12b2e7 View commit details
    Browse the repository at this point in the history