[OPEN SOURCE] O(1) Engine: The Ultimate Anti-Lag Library (Handle 7,500+ moving parts ) (V2 update below)

Hey everyone! :waving_hand:

Are you tired of Script Activity spikes? Does your server freeze when dealing with hundreds of moving parts, complex math, or heavy loops?

I’ve spent the last few weeks building the O(1) Engine, a professional-grade optimization suite designed to bypass Roblox’s heavy C++ bridge and Garbage Collector. Today, I am releasing it completely for FREE and Open Source.

:bar_chart: The Benchmark (Tested on a low-end i5-10210U Laptop)

I created a stress test with 7,500 moving parts updating every frame.

  • :red_circle: Standard Loop (Individual updates): ~28 FPS**.
  • :green_circle: O(1) Engine (BulkMoveTo + Fast Math): 35 FPS**.

(See the videos below for the proof)


:gear: What’s inside the Engine?

It comes with 4 highly optimized modules that you can “lazy load” only when you need them:

1. Instances Module (Zero-Lag Rendering)

  • Manage massive armies or bullet hells without lag.
  • Built-in Object Pooling (Never use :Destroy() again, save your RAM!).
  • Advanced Spatial Hashing to find nearby entities instantly without magnitude checks on everything.

2. Math Module (Physics Bypass)

  • Calculates Gacha Systems (Weighted Randoms in O(1) time).
  • Custom Spherical Hitboxes and Dot Product Cones.
  • FastSin approximations (much faster than math.sin for heavy loops).

3. Memory Module (DataStore Saver)

  • Uses Raw C++ Buffers instead of Lua Tables to prevent Garbage Collection micro-stutters.
  • BitPacking: Compress up to 32 booleans (like quests or inventory slots) into a single number to save DataStore space and reduce UpdateAsync times.

4. Utility Module (Clean UI)

  • Pro-level formatting: Convert 1500000 to "1.5M" instantly.
  • Time formatting (00:05) and Hex Color tools.

:shield: 100% Safe & Open Source

I know the community is (rightfully) paranoid about backdoor plugins. The O(1) Engine has no obfuscated code, no hidden require(), and is heavily commented.
When you install the plugin, it generates a disabled README script in your ServerScriptService with full examples on how to use every function.

:link: Get the Plugin Here:

https://create.roblox.com/store/asset/76970688497999/O1-Engine-The-Ultimate-Optimization-Suite

Feel free to read the source code, modify it, or use it in your top games. Let me know what you guys think, and if you have any feature requests or feedback, drop a reply! :rocket:

3 Likes

ah yes 5fps increase seems needed, with better optimizations you can have the code move 7.5k parts much more smoother

18 Likes

Hey everyone! First of all, thank you for the feedback on the initial release. Some of you rightly pointed out that the previous benchmarks weren’t showing a massive difference. You were absolutely right: we were hitting a GPU bottleneck that hid the actual engine efficiency.

I took your feedback, went back to the drawing board, and I’m incredibly excited to announce the O(1) Engine V2: The Buffer Revolution.

We completely rewrote the core using a Data-Oriented Design. We moved away from heavy Lua tables and implemented raw memory Buffers. The difference is night and day.

:bar_chart: The New Benchmark (10,000 Moving Parts)

We ran a massive stress test updating 10,000 parts every frame (tested on a mid-range i5 / Ryzen 5600G).

  • :red_circle: Standard Roblox Loop: ~18 FPS (Heavy C++ bridge & GC overhead)
  • :green_circle: O(1) Engine V2: ~41 FPS
  • Result: A +100% performance boost.(in perfect conditions)

:movie_camera: Watch the live Benchmark Proof here:

:warning: Scientific Disclaimer: Please note that the +100% boost is achieved under extreme, experimental stress-test conditions designed specifically to highlight the C++ bridge bottleneck. In real-world game scenarios, your total FPS gain will vary depending on your GPU, existing memory leaks, and other game-specific logic. However, the architectural overhead and Garbage Collection spikes are drastically reduced across the board.

:hammer_and_wrench: What’s New in V2?

  • Raw Memory Buffers (SoA): The engine now stores positions (X,Y,Z) as 32-bit floats in raw memory buffers. This reduces RAM usage for large arrays by over 70% and completely eliminates Lua Garbage Collection lag spikes.
  • Automated Frustum Culling: The Instances module now features visual culling. If the engine detects that a part is outside the player’s screen, it pauses its CFrame calculations, giving massive breathing room to your CPU.
  • Parallel Luau Support: The Math module now natively supports Multi-Core CPU processing for heavy arrays (requires to be run inside an Actor).
  • Bulletproof Installer: The plugin now safely auto-generates a clean README_EXAMPLES script in your ServerScriptService with copy-pasteable snippets for the new Buffer API.

If you want to test the 18 vs 40 FPS difference yourself, here is the exact script I used for the video:

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local O1 = require(ReplicatedStorage:WaitForChild("O1"))

local COUNT = 10000
local RENDER_DISTANCE = 150
local TEST_DURATION = 8 -- seconds per test

--======================================================
-- 1. AUTOMATIC GUI SETUP (No manual work needed)
--======================================================
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
local screen = Instance.new("ScreenGui", playerGui)
screen.Name = "O1_VideoBenchmark"
screen.IgnoreGuiInset = true

local statusLabel = Instance.new("TextLabel", screen)
statusLabel.Size = UDim2.new(1, 0, 0.1, 0)
statusLabel.Position = UDim2.new(0, 0, 0.05, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.TextStrokeTransparency = 0
statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
statusLabel.TextScaled = true
statusLabel.Font = Enum.Font.FredokaOne
statusLabel.Text = "⚙️ LOADING " .. COUNT .. " PARTS..."

local fpsLabel = Instance.new("TextLabel", screen)
fpsLabel.Size = UDim2.new(1, 0, 0.15, 0)
fpsLabel.Position = UDim2.new(0, 0, 0.15, 0)
fpsLabel.BackgroundTransparency = 1
fpsLabel.TextStrokeTransparency = 0
fpsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
fpsLabel.TextScaled = true
fpsLabel.Font = Enum.Font.GothamBlack
fpsLabel.Text = "FPS: --"

--======================================================
-- 2. ENVIRONMENT SETUP
--======================================================
local standardFolder = Instance.new("Folder", workspace)
local standardParts = table.create(COUNT)

local v2Folder = Instance.new("Folder", workspace)
local v2Parts = table.create(COUNT)
local v2CFrames = table.create(COUNT)
local positionBuffer = O1.Memory.NewPositionBuffer(COUNT)

for i = 1, COUNT do
	-- Standard Setup
	local p1 = Instance.new("Part")
	p1.Size = Vector3.new(1, 1, 1)
	p1.Anchored = true
	p1.Color = Color3.fromRGB(255, 50, 50) -- Red
	p1.Parent = standardFolder
	standardParts[i] = {Part = p1, Phase = math.random() * 10}

	-- V2 Setup
	local p2 = Instance.new("Part")
	p2.Size = Vector3.new(1, 1, 1)
	p2.Anchored = true
	p2.Color = Color3.fromRGB(50, 255, 100) -- Green
	p2.Parent = v2Folder
	v2Parts[i] = p2
	v2CFrames[i] = CFrame.new(0,0,0)

	local initX = math.random(-200, 200)
	local initZ = math.random(-200, 200)
	positionBuffer:WritePosition(i, initX, 0, initZ)
end

v2Folder.Parent = nil
task.wait(2)

-- Helper function to track real-time FPS
local function TrackFPS(duration, renderLogic)
	local frames = 0
	local lastFpsUpdate = os.clock()
	local startTime = os.clock()
	local totalFrames = 0

	local connection = RunService.RenderStepped:Connect(function(dt)
		local t = os.clock()
		renderLogic(t)

		frames = frames + 1
		totalFrames = totalFrames + 1

		-- Update GUI every 0.5 seconds for readability
		if t - lastFpsUpdate >= 0.5 then
			local currentFps = math.floor(frames / (t - lastFpsUpdate))
			fpsLabel.Text = currentFps .. " FPS"
			frames = 0
			lastFpsUpdate = t
		end
	end)

	task.wait(duration)
	connection:Disconnect()
	return math.floor(totalFrames / duration)
end

--======================================================
-- 3. RUN TESTS
--======================================================

-- TEST 1: STANDARD
statusLabel.Text = "🔴 STANDARD LOOP (Unoptimized)"
statusLabel.TextColor3 = Color3.fromRGB(255, 100, 100)
fpsLabel.TextColor3 = Color3.fromRGB(255, 50, 50)

local avgStandard = TrackFPS(TEST_DURATION, function(t)
	for i = 1, COUNT do
		local data = standardParts[i]
		local y = math.sin(t + data.Phase) * 5
		data.Part.Position = Vector3.new(data.Part.Position.X, y, data.Part.Position.Z)
	end
end)

-- TRANSITION
standardFolder.Parent = nil
statusLabel.Text = "🔄 SWITCHING TO O(1) ENGINE..."
statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
fpsLabel.Text = "-- FPS"
fpsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
task.wait(3)

-- TEST 2: O(1) ENGINE
v2Folder.Parent = workspace
statusLabel.Text = "🟢 O(1) ENGINE (Buffers + Culling)"
statusLabel.TextColor3 = Color3.fromRGB(100, 255, 100)
fpsLabel.TextColor3 = Color3.fromRGB(50, 255, 100)

local avgO1 = TrackFPS(TEST_DURATION, function(t)
	for i = 1, COUNT do
		local px, py, pz = positionBuffer:ReadPosition(i)
		local newY = O1.Math.FastSin((t + (i*0.01)) * 57) * 5
		local currentPos = Vector3.new(px, newY, pz)

		if O1.Instances.IsVisible(currentPos, RENDER_DISTANCE) then
			v2CFrames[i] = CFrame.new(currentPos)
		else
			v2CFrames[i] = CFrame.new(0, 100000, 0)
		end
	end
	O1.Instances.BulkMove(v2Parts, v2CFrames)
end)

-- CONCLUSION SCREEN
v2Folder.Parent = nil
statusLabel.Text = "🏆 BENCHMARK COMPLETE"
statusLabel.TextColor3 = Color3.fromRGB(255, 215, 0) -- Gold
fpsLabel.Text = "Standard: " .. avgStandard .. " FPS | O(1): " .. avgO1 .. " FPS"
fpsLabel.TextColor3 = Color3.fromRGB(255, 255, 255)

If you already have the plugin installed, just head to your Manage Plugins tab in Studio and click Update! Let me know what you guys think of the new Buffer architecture! :rocket:

2 Likes

I don’t think this is a fair comperasion

  1. O1 V2 Engine has culling ability and to be in favor of it you randomoizr parts positions so not all would be loaded as standard method just puts all parts in 1 position
  2. you can use vector.new btw
  3. you can decrease memory as 32-bit floats are uneccessery

overlla it still made a upgrade from V1 version

1 Like

Hey @lol_GG1HACKE, thank you so much for taking the time to look into the code. I genuinely appreciate the honest and constructive feedback!

1. The Benchmark Fairness (0,0,0 stacking) You were absolutely right. The standard parts defaulting to 0,0,0 was a genuine oversight on my end. Stacking 10,000 anchored parts in the exact same spot created artificial rendering and physics lag for the standard loop, which unfairly bloated the difference. Thank you for calling this out!

I just completely rewrote the benchmark script to be 100% fair: both methods now spawn parts in the exact same randomized spread, and I gave the standard loop cached X/Z variables so it runs as fast as traditionally possible. I re-ran the tests: Standard now sits at around 24 FPS, while the O(1) Engine holds around 45 FPS. Even on a completely leveled playing field, the Buffer + BulkMove architecture nearly doubles the performance (an almost +90% boost)! I’ve updated the main post with the new fair script and video.

2. vector.new (Native Luau Vectors) This is a brilliant suggestion. Luau’s native vector types (vector.create) are insanely fast. I am currently back in Studio implementing this for internal math to squeeze out even more performance. You can expect a V2.1 update for this tomorrow!

3. 32-Bit Floats Memory Regarding the memory optimization, I’m curious to hear your thoughts on this! I chose 32-bit floats (buffer.writef32) to maintain world-space precision and avoid the jittering/snapping issues that usually happen with lower precision. If you have a specific implementation in mind that reduces memory without sacrificing decimal accuracy for Positions (X, Y, Z), I’d love to see how you’d handle that in the code. What kind of data type or compression logic would you suggest for this specific use case?
Thanks again for helping me keep the benchmark honest and for the great optimization ideas. This is exactly what helps the engine grow and get better for everyone! :rocket:


here is the new testing script ( a localscript in StarterPlayerScript):

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local O1 = require(ReplicatedStorage:WaitForChild("O1"))

local COUNT = 10000
local RENDER_DISTANCE = 150
local TEST_DURATION = 8 -- seconds per test

--======================================================
-- 1. AUTOMATIC GUI SETUP
--======================================================
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
local screen = Instance.new("ScreenGui", playerGui)
screen.Name = "O1_VideoBenchmark"
screen.IgnoreGuiInset = true

local statusLabel = Instance.new("TextLabel", screen)
statusLabel.Size = UDim2.new(1, 0, 0.1, 0)
statusLabel.Position = UDim2.new(0, 0, 0.05, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.TextStrokeTransparency = 0
statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
statusLabel.TextScaled = true
statusLabel.Font = Enum.Font.FredokaOne
statusLabel.Text = "⚙️ LOADING " .. COUNT .. " PARTS..."

local fpsLabel = Instance.new("TextLabel", screen)
fpsLabel.Size = UDim2.new(1, 0, 0.15, 0)
fpsLabel.Position = UDim2.new(0, 0, 0.15, 0)
fpsLabel.BackgroundTransparency = 1
fpsLabel.TextStrokeTransparency = 0
fpsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
fpsLabel.TextScaled = true
fpsLabel.Font = Enum.Font.GothamBlack
fpsLabel.Text = "FPS: --"

--======================================================
-- 2. ENVIRONMENT SETUP (100% FAIR CONDITIONS)
--======================================================
local standardFolder = Instance.new("Folder", workspace)
local standardParts = table.create(COUNT)

local v2Folder = Instance.new("Folder", workspace)
local v2Parts = table.create(COUNT)
local v2CFrames = table.create(COUNT)
local positionBuffer = O1.Memory.NewPositionBuffer(COUNT)

-- We use a neutral color for both to ensure rendering cost is identical
local SHARED_COLOR = Color3.fromRGB(200, 200, 200) 

for i = 1, COUNT do
	-- 📍 FAIR SPREAD: Both setups use the exact same generated coordinates
	local initX = math.random(-200, 200)
	local initZ = math.random(-200, 200)
	local startPos = Vector3.new(initX, 0, initZ)

	-- Standard Setup
	local p1 = Instance.new("Part")
	p1.Size = Vector3.new(1, 1, 1)
	p1.Anchored = true
	p1.Position = startPos -- Placed correctly from the start
	p1.Color = SHARED_COLOR
	p1.Parent = standardFolder

	-- Caching BaseX and BaseZ to give the standard loop the best possible chance
	standardParts[i] = {Part = p1, Phase = math.random() * 10, BaseX = initX, BaseZ = initZ}

	-- V2 Setup
	local p2 = Instance.new("Part")
	p2.Size = Vector3.new(1, 1, 1)
	p2.Anchored = true
	p2.Color = SHARED_COLOR
	p2.Parent = v2Folder

	v2Parts[i] = p2
	v2CFrames[i] = CFrame.new(startPos)

	-- Writing to V2 Buffer
	positionBuffer:WritePosition(i, initX, 0, initZ)
end

v2Folder.Parent = nil
task.wait(2)

-- Helper function to track real-time FPS
local function TrackFPS(duration, renderLogic)
	local frames = 0
	local lastFpsUpdate = os.clock()
	local startTime = os.clock()
	local totalFrames = 0

	local connection = RunService.RenderStepped:Connect(function(dt)
		local t = os.clock()
		renderLogic(t)

		frames = frames + 1
		totalFrames = totalFrames + 1

		-- Update GUI every 0.5 seconds for readability
		if t - lastFpsUpdate >= 0.5 then
			local currentFps = math.floor(frames / (t - lastFpsUpdate))
			fpsLabel.Text = currentFps .. " FPS"
			frames = 0
			lastFpsUpdate = t
		end
	end)

	task.wait(duration)
	connection:Disconnect()
	return math.floor(totalFrames / duration)
end

--======================================================
-- 3. RUN TESTS
--======================================================

-- TEST 1: STANDARD
statusLabel.Text = "🔴 STANDARD LOOP (Unoptimized)"
statusLabel.TextColor3 = Color3.fromRGB(255, 100, 100)
fpsLabel.TextColor3 = Color3.fromRGB(255, 50, 50)

local avgStandard = TrackFPS(TEST_DURATION, function(t)
	for i = 1, COUNT do
		local data = standardParts[i]
		local y = math.sin(t + data.Phase) * 5
		-- Fair update: using cached X and Z so it doesn't read the property (which is slow)
		data.Part.Position = Vector3.new(data.BaseX, y, data.BaseZ)
	end
end)

-- TRANSITION
standardFolder.Parent = nil
statusLabel.Text = "🔄 SWITCHING TO O(1) ENGINE..."
statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
fpsLabel.Text = "-- FPS"
fpsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
task.wait(3)

-- TEST 2: O(1) ENGINE
v2Folder.Parent = workspace
statusLabel.Text = "🟢 O(1) ENGINE (Buffers + Culling)"
statusLabel.TextColor3 = Color3.fromRGB(100, 255, 100)
fpsLabel.TextColor3 = Color3.fromRGB(50, 255, 100)

local avgO1 = TrackFPS(TEST_DURATION, function(t)
	for i = 1, COUNT do
		local px, py, pz = positionBuffer:ReadPosition(i)
		local newY = O1.Math.FastSin((t + (i*0.01)) * 57) * 5
		local currentPos = Vector3.new(px, newY, pz)

		if O1.Instances.IsVisible(currentPos, RENDER_DISTANCE) then
			v2CFrames[i] = CFrame.new(currentPos)
		else
			v2CFrames[i] = CFrame.new(0, 100000, 0) -- Frustum Culling teleport
		end
	end
	-- Single C++ Bridge Call
	O1.Instances.BulkMove(v2Parts, v2CFrames)
end)

-- CONCLUSION SCREEN
v2Folder.Parent = nil
statusLabel.Text = "🏆 BENCHMARK COMPLETE"
statusLabel.TextColor3 = Color3.fromRGB(255, 215, 0) -- Gold
fpsLabel.Text = "Standard: " .. avgStandard .. " FPS | O(1): " .. avgO1 .. " FPS"
fpsLabel.TextColor3 = Color3.fromRGB(255, 255, 255)

?? :sob:

what am i looking at bro

6 Likes

can u give us a game link to test play?

is this an ai generated resource

10 Likes

I think it is, one single reply pointing out the 5 fps increase and OP responds with an entire essay on multiple sources of feedback, I’m pretty sure OP is just putting something into ai and replying with whatever it says.

Not to mention apparently it took only 1 day to make a SECOND version of this entire system, that takes multiple days and maybe up to a week for something of THIS magnitude…

3 Likes

Yes bro , this is IA plugin image generated and i used IA to reply.

dead internet theory is real…

Ahh:

function Memory.NewPositionBuffer(capacity)
	local self = setmetatable({}, FastBuffer) 
    --                         ^       
    --                         allocation
	self._b = buffer.create(capacity * 12) -- <- allocation
	self.Capacity = capacity
	return self
end

3 Likes

just a note for you, complete AI work is looked down upon and it is not a good idea to vibe-code public resources.

vibe coding destroys optimization, this engine may be intended for optimization but in no way is it reaching it’s potential simply because the fact it’s entirely made by AI

not to mention, vibe-coded work is impossible to read, impossible to debug, and most of the time just bloat.

AI is a tool, not a replacement, and in this entire thing you’re using it as a replacement.

you’re right i used gemini , i was bored of my unoptimized spagettis codes so i just gave to gemini it.

there isn’t shame in using AI to help you optimize your code or format it better or recommend changes that would prove fruitful, but having it write everything from start to finish is something you’d want to avoid

2 Likes

people don’t realize this is ai slop invading the good ol’ devforum

6 Likes

useless as u vibecoded this (very obvious)

1 Like

I’m not gonna like this looks just like it

To be honest we should have like a category for completely AI and partially AI generated sources

Stay stuck in the 2015’s while we move on.
AI is the future, no matter what, deal with it.

Who cares if it is written by AI? Clearly it gives a performance boost, so i would be glad to use it (thought i won’t because i don’t need it)

its a small difference and most ai code is slop and full of bugs AI is the future sure but ai isnt there yet and needs a lot of human assistance to not produce slop like this