-
Notifications
You must be signed in to change notification settings - Fork 17
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
How to reduce "app:patch DexDebug" task execution time #36
Comments
hi, i don't know what dexpatcher you are using, start by telling me that. yes, i know you are using dxp-gradle 2.1.0 (which you should not because it is prerelease, but anyway). the version of dxp-tool is specified in your gradle build files. things you can do:
we can start debugging with that info. thanks! |
project build.gradle
app build.gradle
build log
And the original apk has 11 dex. |
thanks remove the '--verbose' item, it is handled by verbosity = ... im worried by your use of '--no-reanon-errors' and '--no-decode-errors', why are they necessary? i see you got how to using the advanced features in the latest beta from reading the very sparse docs, congrats. i haven't used the new transform features (no time) on any real hacks, that's why it is all still in beta, i haven't tested. there could be issues of course. but i aim for correctness first, then deal with optimization if needed, so i haven't got to study performance issues other than at the design phase. 0.34 secs are used to patch the code. 17 s are wasted on the 'transform output' step. you can recover most of that by setting --pre-transform dry (so output code will be pretransformed only of not written -ie, if a dxp error happens). otherwise transform and write back will happen simultaneously. caveats: transform logs will be intermixed with write logs. dxp will produce an (invalid) output if errors happen during output transforms! (given that write starts before transforms are executed) this causes no issues with dxp-gradle though. 280 s are used to write back the dex, there is not much that can be done here. this is an issue with dexlib2 (smali): it is not written for performance. but there is a way to multi-thread the write back phase: if you have a quad core machine you can have a significant speed gains in this phase. take a look here: https://github.com/DexPatcher/dexpatcher-tool/releases/tag/v1.2.0-beta2 note that multi-dex multi-threading is on by default when using dxp-gradle under certain conditions on debug builds! how to check if you are using MT mdex? set verbosity = VERBOSE and re run build with logStats = true. then only paste here the end of the build log like this:
but this time you should see info for each dex file of the output multidex. try it please, thanks. |
oh, and please tell me what is the CPU model you use. thanks. |
AMD Ryzen 5 1600 |
ok. after you check what i asked, for that CPU id recommend you use multiDexJobs = n, with n ranging from 6 to 12. currently dxp-tool limits itself to 4 jobs due to java programs not being able to distinguish between CPU cores and hyperthreads. this of course requieres MT mdex being used. |
Thanks for the help, I'll give it a try |
Does it work? |
hey im sorry! its been a year for me since i touched any of this i think you need more logging. is there a verbosity = DEBUG? try that instead. sorry :( |
I think you might want to check out my project. |
|
from your latest times:
you can try this:
probably you'll find that smali/dexlib2 is just slow with your big app. |
Right now I cannot swallow such a mass of knowledge :D. I think I need to do more research. Thank you very much, your DexPatcher project is very good. |
i just tried an apktool roundtrip on your apk (without resource decoding). it took 1m 24s, so there is ample space to increase performance. i suppose transforms are to blame here. i'll check options later when i can. |
I've done many projects with DexPatcher and this is the first one where I had such a problem. Thanks for the support. |
i never find out, due to the nature of most work done with this toolset. i hate that! :) i committed a change to your repo. it adds build options:
in your PC, when all options are set, i gather your rebuild time should fall from 5 minutes to around 45 seconds. |
this is the first 'stress test' i've seen the 1.8.0 beta being put though, as i never had time to finish the tool let alone play with or benchmark it. FYI: the question whether a pre-deanonymized dex can be built and then mapped to a pre-transformed dex (or live during patching) depends on the order of transforms i picked while implementing dxp-tool, which was the result of a very lengthy planning stage of all features before any coding. and if such ordering can or should be altered remains to be seen, but should happen while in beta. but in case of frequent mapping changes, pre-transforming is clearly not the way out. one possibility remains: dxp-tool could build a complete intermediate mapped source dex representation in memory. this would consume EFFING LOTS of heap memory for big projects, but would probably speed things significantly. it could be away out for those graced with an obscene amount of RAM. it's not hard to implement. EDIT:
(note that each mapping transform can apply the composition of two sets of maps.) this means deanonymize and encode cannot be pre-applied to source so that mapping changes are built faster. the idea was to give the user first deeds on the code, so that the mapping file would not depend on, say, the chosen identifier encoding settings. this is more than just convenience: it ensures compatibility with mappings of other tools. this was a very important factor in the decision. i do not think this decision should be reverted in favor of build performance. but should it be done, this would affect the transform orders of all endpoints: not just source, but patches and output too. a better alternative could be the in-memory cache of the transformed code as described earlier. |
Hi, it worked. Thank you very much. Do you have plans to further develop Dxp in the future? |
i'll keep this open so others are more likely to find it. the problem is, i got little time, and no one seems to use the toolset anyway. i would like to at least finish a proper release of -tool and -gradle with the new features. |
accepted solution: // Build Performance Options
// When set they increase build speed but decrease the quality of the build log.
def lazyTransforms = true // check transforms while output dex is being written
def fastAnon = true // apply patch in the anonymized namespace
def fastMap = true // apply patch in the unmapped namespace
dexpatcherConfig {
dexpatcher {
verbosity = VERBOSE
logStats = true
// i need to update dxp-tool with better defaults for newer PCs
// with more cores so that the following line is no longer needed:
multiDexJobs = (0.75 * Runtime.getRuntime().availableProcessors() + 0.5) as int
extraArgs.addAll([
'--map', 'mapping.txt',
'--main-plan', 'Anon[_Level]',
'--alt-plan', '[_]_',
'--deanon-patches-alt',
'--decode-patches',
])
if (fastMap) extraArgs.addAll(['--unmap-patches'])
else extraArgs.addAll(['--map-source', '--unmap-output'])
if (fastAnon) extraArgs.addAll(['--reanon-patches'])
else extraArgs.addAll(['--deanon-source', '--reanon-output'])
if (lazyTransforms) extraArgs.addAll(['--pre-transform', 'dry'])
}
} |
The project I'm working on takes a lot of time with each build.
Each time Dexpatcher will rewrite the dex in the directory '..\app\build\intermediates\dexpatcher\patched-dex\debug' and it took me almost 5 minutes for each such build.
Do you have any solution?
I am using:
The text was updated successfully, but these errors were encountered: