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

Poor performance when overrunning a large obfuscation dictionary #413

Open
quat1024 opened this issue Jun 18, 2024 · 2 comments
Open

Poor performance when overrunning a large obfuscation dictionary #413

quat1024 opened this issue Jun 18, 2024 · 2 comments

Comments

@quat1024
Copy link

quat1024 commented Jun 18, 2024

In one project, we use an obfuscation dictionary with 10,000 entries. We found that most CPU time was spent in proguard.obfuscate.DictionaryNameFactory.nextName.

It turns out we had more than 10,000 symbols to obfuscate in the project and ran out the dictionary. DictionaryNameFactory falls back to generating fresh names and checking them against the dictionary so it doesn't generate a duplicate, but this duplicate-checking uses a linear scan (List#contains, line 255), so our large dictionary was causing this code path to be very slow.

// Return the next different name from the other name factory.
do
{
name = nameFactory.nextName();
}
while (names.contains(name));

@phase
Copy link

phase commented Jul 3, 2024

here's a profiler snapshot from VisualVM:
image

by expanding our dictionary from 10k to 50k, the problem went away and the time taken by proguard cut in half.

after this was solved, another profile shows another hot loop is taking up a significant portion of time

https:/Guardsquare/proguard-core/blob/9ae93fd664f8b92830e9ea402a65c0ffd6f73dce/base/src/main/java/proguard/classfile/util/MethodLinker.java#L150-L158

image

@mrjameshamilton
Copy link
Collaborator

The dictionary performance should be improved in 7.6 with the following commit: 03d7eff

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

No branches or pull requests

3 participants