prometheus-lua / Prometheus

Lua Obfuscator written in pure Lua
https://levno-710.gitbook.io/prometheus/
GNU Affero General Public License v3.0
220 stars 65 forks source link

ProxifyLocals Combined with Vmify creates peformance issues #29

Closed wrefgtzweve closed 2 years ago

wrefgtzweve commented 2 years ago

Describe the bug I've noticed that performance drops significantly when im using the Strong preset, after trying out a lot of stuff i've noticed that VM and Proxify run fine on their own but get very bad when combined. I'm using Garry's mod lua enviroment for this.

The code im using to test:

local SysTime = SysTime
local Distance = FindMetaTable("Vector").Distance

local vec1 = Vector(1, 2, 3)
local vec2 = Vector(13, 26, -10)

local count = 10000

local StartTime = SysTime()

for i = 1, count do
    -- Repeat an action 10,000 times to check how long it takes on average
    -- Example action:
    Distance(vec1 , vec2)
end

local EndTime = SysTime()
local TotalTime = EndTime - StartTime
local AverageTime = TotalTime / count

print("Custom Total: " .. TotalTime .. " seconds. Average: " .. AverageTime .. " seconds.")

image As you can see here, strong significantly increases the time it takes for the benchmark to run. image In this screenshot i compare it to my custom preset which is basically Strong without using proxify locals image

And for reference, this is Strong without VM and with proxify: image image

Expected behavior Some way of using both of these methods at the same time without having peformance issues.

To Reproduce As described before, any configuration that uses both VM and Proxify together will create a massive peformance sink.

Screenshots See main explanation.

Additional context Gmod lua wiki: https://wiki.facepunch.com/gmod/ Garry's mod uses Lua 5.1

Brohammer5 commented 2 years ago

As stated by the developer, "the VM is currently extremely slow and I am in the moment working on a better vm to increase speed. Another problem that the new vm in the next release will fix, is that it is relatively easy to dump constants used by the old vm." Link to Comment: https://github.com/levno-710/Prometheus/discussions/28#discussioncomment-2211572

wrefgtzweve commented 2 years ago

As can be seen in this example: image

VM by itself isn't currently slowing stuff down significantly, when used together with proxylocals it starts to cause peformance issues.

levno-710 commented 2 years ago

Proxify locals is relatively slow, because it uses metatablea a lot. However, it becomes slower, the more local variables your program has. The VM adds a lot of local variables, so that the slowdowns combined are very big

brandonsturgeon commented 2 years ago

Proxify locals is relatively slow, because it uses metatablea a lot. However, it becomes slower, the more local variables your program has. The VM adds a lot of local variables, so that the slowdowns combined are very big

Is that something that could potentially be remedied?