revanced-patcher icon indicating copy to clipboard operation
revanced-patcher copied to clipboard

perf: Improve proxy performance

Open oSumAtrIX opened this issue 10 months ago • 4 comments

Feature description

Right now, the proxy function is implemented like this:

Image

Make proxyPool a map for constant lookup.

Motivation

Proxy has linear time complexity and if you need to proxy many classes, it's quadratic. Making lookup constant would reduce complexity to linear for performance.

Acknowledgements

  • [x] I have checked all open and closed feature requests and this is not a duplicate.
  • [x] I have chosen an appropriate title.
  • [x] All requested information has been provided properly.

oSumAtrIX avatar Mar 07 '25 19:03 oSumAtrIX

@LisoUseInAIKyrios Does that make sense?

oSumAtrIX avatar Mar 07 '25 19:03 oSumAtrIX

This is already implemented in

https://github.com/ReVanced/revanced-patcher/pull/329#issuecomment-2618629298

https://github.com/LisoUseInAIKyrios/revanced-patcher/blob/feat/instruction_filters/src/main/kotlin/app/revanced/patcher/util/PatchClasses.kt

LisoUseInAIKyrios avatar Mar 07 '25 19:03 LisoUseInAIKyrios

The change also fixes an existing bug, where if a patch modified a method, then a different patch fingerprint matches a different part of the same method, then the match indexes returned by the second fingerprint are incorrect (it returns the pattern indexes of the unmodified method).

https://github.com/ReVanced/revanced-patcher/pull/329#issuecomment-2615313028

The bug has existed for a long time, but that change fixes it.

LisoUseInAIKyrios avatar Mar 07 '25 20:03 LisoUseInAIKyrios

The bug has existed for a long time, but that change fixes it.

It was considered a non-bug. I was under the impression of fingerprints matching the real source, but it makes sense to make it respect past changes.

oSumAtrIX avatar Mar 07 '25 20:03 oSumAtrIX