AEGIS

Performance

Obfuscation has an unavoidable performance impact. These steps keep your protected code running smoothly.

Pick the right mode

Source mode — fastest

Strings, numbers and control flow are obfuscated but the code stays valid Lua. Use this for code that must run at near-native speed.

VM mode — slowest, strongest

The VM is emulating Lua: one instruction can turn into dozens. Only run hot paths through it when the security benefit outweighs the cost.

ServerShield — same runtime, keyless file

Adds only a one-time key fetch at startup. After that, execution speed matches the mode underneath.

Exclude what doesn't need protection

Not all code needs to be obfuscated. Large libraries that deal with unimportant code (UI libraries, physics calculations, 2D/3D rendering & drawing) should usually be left unobfuscated. Wrap them in AEG_NO_OBFUSCATE(...) — this still hides variable names and comments, but keeps the code running at full speed.

local UI = AEG_NO_OBFUSCATE(loadUI())
local function render()
  AEG_NO_VIRTUALIZE(function()
    -- per-frame drawing code
  end)()
end

Full macro list on the macros page.

Optimize your code

Code optimization is extremely important when dealing with obfuscation. Most of the time, poor performance is caused by unoptimized code. Due to the nature of the VM, poorly written code has a much greater impact than when it is unobfuscated. Analyzing your code for redundancies improves performance and lowers file size.

Before
a.b.c.d.e.f.g.x = 1
a.b.c.d.e.f.g.y = 2
a.b.c.d.e.f.g.z = 3
After
local myTable = a.b.c.d.e.f.g

myTable.x = 1
myTable.y = 2
myTable.z = 3

Optimizations that look like micro-optimizations have a much larger impact when obfuscated. Fewer instructions is always better.

Frequently run code

Code that runs frequently (per game tick, render frame, or otherwise multiple times per second) may cause freezes, drop FPS, reduce throughput, and increase latency even if optimized properly. Most of the time obfuscation is not necessary on these functions — mark them with AEG_NO_VIRTUALIZE / AEG_NO_OBFUSCATE so they run at full speed.

  • Any code that involves rendering/drawing per frame.
  • Functions that are called/invoked repeatedly per frame.
  • Loops that run repeatedly or multiple times per second.
  • Large amounts of code that run frequently or repeatedly.

FiveM

  • Large amounts of threads created by Citizen.CreateThread
  • Loops/threads that run repeatedly and use short Citizen.Wait intervals
  • Event handlers that are invoked frequently

Roblox

  • Connections to RunService events (RenderStepped, Heartbeat, etc.)
  • Connections to UserInputService events (InputChanged, etc.)
  • Hooks to Instance __index / __namecall / __newindex methods
  • Loops/threads that run repeatedly and use short wait intervals
  • Hooks to functions that are called frequently

ServerShield specifics

ServerShield fetches its key once at startup and then decrypts instructions on demand, one at a time. The steady-state overhead is identical to the underlying mode. To keep startup fast: place the protected file early in your resource/script load order, and avoid hot reloading it inside per-frame loops.