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

Rename Variables slow obfuscation time #95

Closed
MichaelXF opened this issue Jun 8, 2023 · 8 comments
Closed

Rename Variables slow obfuscation time #95

MichaelXF opened this issue Jun 8, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@MichaelXF
Copy link
Owner

The Rename Variables is very slow! Taking over 30 seconds for 3mb file.

{
    "fileName": "static/js/bundle.js",
    "obfuscatedTime": "55.2 Seconds",
    "transformationTimes": {
        "Preparation": "0.7 Seconds",
        "ObjectExtraction": "1 Seconds",
        "Dispatcher": "0.6 Seconds",
        "DeadCode": "0.1 Seconds",
        "Calculator": "0.1 Seconds",
        "ControlFlowFlattening": "1.2 Seconds",
        "OpaquePredicates": "0.4 Seconds",
        "StringConcealing": "0.5 Seconds",
        "DuplicateLiteralsRemoval": "0.8 Seconds",
        "MovedDeclarations": "6.1 Seconds",
        "RenameLabels": "0.9 Seconds",
        "Minify": "2.5 Seconds",
        "RenameVariables": "36.4 Seconds",
        "AntiTooling": "0.5 Seconds",
        "Finalizer": "0.7 Seconds"
    },
    "originalFileSize": "3mb",
    "obfuscatedFileSize": "10mb"
}

This is obfuscating an entire React build on Low preset. (With compact=false for fair file size comparison)

@MichaelXF MichaelXF added the enhancement New feature or request label Jun 8, 2023
@fuzzbuck
Copy link

Hi, how to perform such test?
I am obfuscating quite a large file (1MB+) and it takes upwards of 5+ minutes to obfuscate, would like to figure out the cause.

@MichaelXF
Copy link
Owner Author

Hi this is from a webpack plugin I’m making, it will be available soon. Also I found a solution to the slow obfuscation times so expect this fixed in the next update.

@fuzzbuck
Copy link

Cool, I made a new PR with a progess bar which helped me figure out what is taking so long, apparently it's the NameRecycling transformation which takes upwards of 4 minutes!

@fuzzbuck
Copy link

fuzzbuck commented Jun 13, 2023

Here is a simple benchmark I did for some other transformations:

Stack: 28 seconds
ControlFlow: 12 seconds
NameRecycling: 287 seconds !
MovedDeclarations: 182 seconds !
RenameLabels: 96 seconds

It is important to note that after first execution, after V8 JIT takes place, these times dwindle a lot (< 10 seconds),
perhaps we will just have to cope with the limitations of javascript

@MichaelXF
Copy link
Owner Author

Im planning on removing the Name Recycling option (it's a weak obfuscation, and Rename Variables already practically does this) and have rewritten Moved declarations to be more efficient.

@fuzzbuck
Copy link

Awesome, looking forwards to the update.

@fuzzbuck
Copy link

Hi this is from a webpack plugin I’m making, it will be available soon. Also I found a solution to the slow obfuscation times so expect this fixed in the next update.

Hey, has there been any updates to this? Looking to find out on my own what's taking so long, have there been any discoveries?

@MichaelXF
Copy link
Owner Author

Yes here's what I've achieved so far:

 {
    "fileName": "static/js/bundle.js",
    "obfuscatedTime": "18.6 Seconds",
    "transformationTimes": {
        "Preparation": "0.8 Seconds",
        "ObjectExtraction": "1.1 Seconds",
        "Dispatcher": "0.5 Seconds",
        "DeadCode": "0.1 Seconds",
        "Calculator": "0.1 Seconds",
        "ControlFlowFlattening": "0.7 Seconds",
        "OpaquePredicates": "0.2 Seconds",
        "StringConcealing": "0.4 Seconds",
        "DuplicateLiteralsRemoval": "0.5 Seconds",
        "MovedDeclarations": "0.4 Seconds", // from 6.1 Seconds
        "RenameLabels": "0.5 Seconds",
        "Minify": "1.1 Seconds",
        "RenameVariables": "9.3 Seconds", // from 36.4 Seconds
        "AntiTooling": "0.3 Seconds",
        "Finalizer": "0.5 Seconds"
    },
    "originalFileSize": "3mb",
    "obfuscatedFileSize": "5mb"
},

I will release this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants