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
perf: resolve fingerprints using method maps #185
perf: resolve fingerprints using method maps #185
Conversation
…ignature that specifies empty parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All in all an interesting idea that can indeed help with speed. I am currently missing better abstractions and object-oriented approaches. To avoid this abstraction, it seems like a single map was used as a lookup table for all sorts of keys, partially arbitrary ones such as the "String:" prefix.
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
…ut might as well.
…s together (performance patching YouTube is the same, as no patches specify more than 5 parameters)
I finally tried patching on a phone (a 5 year old Snapdragon 845), and this PR combined with the patch fingerprint tweaks the time to patch YouTube was reduced by 89 seconds. |
…e_map # Conflicts: # src/main/kotlin/app/revanced/patcher/Patcher.kt # src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Maybe merge this before Manager and CLI get updated with the other required patcher changes? This is not a breaking change so only a minor version bump is needed. |
I'll have to review this regarding code quality and style before merging, so that we don't have to look back to it to refactor if necessary |
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patcher/fingerprint/method/impl/MethodFingerprint.kt
Outdated
Show resolved
Hide resolved
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…fingerprint_signature_map
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…ethodFingerprint.kt Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
…e_map # Conflicts: # src/main/kotlin/app/revanced/patcher/Patcher.kt
## [11.0.2-dev.3](v11.0.2-dev.2...v11.0.2-dev.3) (2023-06-27) ### Performance Improvements * resolve fingerprints using method maps ([#185](#185)) ([d718134](d718134))
## [11.0.2](v11.0.1...v11.0.2) (2023-06-27) ### Bug Fixes * catch exceptions from closing patches ([d5d6f85](d5d6f85)) * do not load annotations as patches ([519359a](519359a)) * only close succeeded patches ([b8151eb](b8151eb)) * use `versionCode` if `versionName` is unavailable ([6e1b647](6e1b647)) ### Performance Improvements * resolve fingerprints using method maps ([#185](#185)) ([d718134](d718134))
Instead of looking thru every single method for each method signature, instead selectively check only the class methods that match the signatures:
Time to patch YouTube:
before: 54 seconds
after (this PR): 46 seconds
This is approaching the speed of the one off branch I made that serializes the resolved class names to json (which gives patch time of 38 seconds). But getting that performance requires patching multiple times locally, or bundling an additional resolver json file with the patches (which isn't ideal).
The changes of this PR work without any extra data, and simply cull the number of methods required to check.
Further performance improvements could be made in the patches by adding the access and return type to more method signatures. I fixed the slowest resolving fingerprints in this branch, and using those changes with this patcher modifications the time to patch is reduced to 40 seconds.
Not a big deal if this is never merged, as I'll keep using the one off branch which gives even faster performance. But this PR might be useful for anyone else.