Skip to content

Conversation

rigor789
Copy link
Member

@rigor789 rigor789 commented Jul 1, 2022

Checking if a swizzled method exists constructs the selector for every call by concatenating the swizzle prefix to the actual selector string. This is pretty slow when doing many calls.

This PR keeps a map (using robin_hood::unordered_map for performance) of SEL (selector) pairs, so that the swizzled selector is only constructed once, and any subsequent calls will use the fast-path by returning the value from the cache.

From a few performance tests, we've seen a ~30% improvement, though it may vary from case to case.

@cla-bot cla-bot bot added the cla: yes label Jul 1, 2022
@NathanWalker NathanWalker marked this pull request as ready for review July 16, 2022 15:23
@NathanWalker NathanWalker merged commit b4f1391 into alpha Jul 16, 2022
@NathanWalker NathanWalker deleted the perf/swizzle-selectors branch July 16, 2022 15:25
caitp pushed a commit to caitp/ns-v8ios-runtime that referenced this pull request Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants