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

perf: resolve fingerprints using method maps #185

Merged
merged 49 commits into from Jun 27, 2023

Conversation

LisoUseInAIKyrios
Copy link
Contributor

@LisoUseInAIKyrios LisoUseInAIKyrios commented May 31, 2023

Instead of looking thru every single method for each method signature, instead selectively check only the class methods that match the signatures:

  • access type
  • return type
  • parameter types
  • or contain a declared strings

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.

Copy link
Member

@oSumAtrIX oSumAtrIX left a 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.

@LisoUseInAIKyrios LisoUseInAIKyrios marked this pull request as ready for review June 4, 2023 11:54
@LisoUseInAIKyrios
Copy link
Contributor Author

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
@LisoUseInAIKyrios
Copy link
Contributor Author

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.

@oSumAtrIX
Copy link
Member

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

LisoUseInAIKyrios and others added 3 commits June 11, 2023 11:47
…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>
LisoUseInAIKyrios and others added 24 commits June 11, 2023 20:45
…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
@oSumAtrIX oSumAtrIX changed the title feat: faster fingerprint resolving by selectively comparing perf: resolve fingerprints using method maps Jun 27, 2023
@oSumAtrIX oSumAtrIX merged commit d718134 into ReVanced:dev Jun 27, 2023
2 checks passed
revanced-bot pushed a commit that referenced this pull request Jun 27, 2023
## [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))
revanced-bot pushed a commit that referenced this pull request Jun 27, 2023
## [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))
@LisoUseInAIKyrios LisoUseInAIKyrios deleted the fingerprint_signature_map branch June 27, 2023 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants