--- name: roblox-performance description: "Use when profiling, fixing or reviewing Roblox performance: lag, low FPS, memory, crashes on phones, load time, streaming." when_to_use: "Also when the game stutters or hitches, phones overheat or crash, crash rate is high, a mesh budget is full, Studio feels laggy, load is slow, server heartbeat drops, or numbers from Studio don't match the live game." last_reviewed: 2026-11-28 sources: - original - https://create.roblox.com/docs/en-us/performance-optimization/microprofiler - https://create.roblox.com/docs/en-us/performance-optimization/improve - https://create.roblox.com/docs/en-us/reference/engine/libraries/debug - https://create.roblox.com/docs/reference/engine/classes/Actor - https://create.roblox.com/docs/reference/engine/datatypes/SharedTable - https://create.roblox.com/docs/scripting/multithreading - https://create.roblox.com/docs/workspace/streaming/frustum - https://create.roblox.com/docs/workspace/streaming/slim - https://create.roblox.com/docs/scripting/transparent-batching - https://luau.org/performance --- # Roblox Performance ## When to Load Frame time, memory, crashes, load time or streaming. With the Studio MCP, also load `rbx-perf-profiling` / `rbx-scene-analysis`. Physics contacts: `roblox-physics`. Cleanup and `task` traps: `roblox-luau`. "Field-measured" = measured in one of the owner's projects; verify yours. ## Traps (symptom -> cause -> fix) - Studio hitches but a live game feels smooth -> Studio solo runs server and client in **one process**, so client frames include server work. Profile a local server + 1 client, then confirm on a **published client on a phone** (rendering, memory) (§1). - Unattended or agent-driven playtest reads ~15 FPS -> Studio throttles an unfocused client (idle p50 ~66.7 ms). Void captures whose idle p50 isn't ~16.7 ms; compare per-action CPU instead (§1). - "Mesh budget is full", later builds (even map chunks) fail -> runtime-built mesh memory (`EditableMesh`, `CreateMeshPartAsync`) counts against a per-device budget (lower on mobile) **for as long as the objects exist**. Spreading builds over time does not help; the total does. Build lazily on use, keep a small LRU, free the rest; upload fixed models as mesh assets to avoid the runtime cost (§2). - Client physics 8 -> 15-46 ms after a blast of small debris -> contacts inside piles. Turn off collision (`CanCollide = false` or a no-collide group) on debris that is fading or being cleared; verify by toggling it in a profiled session (`roblox-physics` §5). - Meshed the visuals, Studio and load still heavy -> invisible collider Parts still cost (~3.3 KB per Part whatever its collision flags). Replace voxel colliders with a few coarse boxes/slabs or `Box`/`Hull` fidelity; small decor non-colliding. **StreamingEnabled doesn't replace cutting instances and collision.** - Converted Parts to MeshParts and draw calls rose -> draw calls follow **unique** meshes/materials; identical ones instance. ~20.8k Parts drew in ~31 calls; the same build as ~331 unique meshes took ~295. Measure (Shift+F2) before and after. - Tiers from `UserGameSettings.SavedQualityLevel` -> the docs now advise against driving effects from it, and on Automatic scripts can't read the active level. If you tier anyway, map only manual levels 1-10 and use a device fallback (touch -> low); better, key debris/effect/physics budgets (which engine scaling never reduces) to measured frame time. - Per-frame work capped by item count still spikes -> each item gets dearer as the world grows. Cap by elapsed `os.clock()` (~3-4 ms) (§3). - Long-lived server memory grows per join -> Player and Character objects aren't destroyed by default. Set `Workspace.PlayerCharacterDestroyBehavior = Enabled` in Studio (`Default` follows an engine default that can change) and still disconnect your own connections. - Stats don't add up -> `Stats.RenderCPUFrameTime`/`RenderGPUFrameTime` read in **seconds** (0.0085 = 8.5 ms), `PhysicsStepTimeMs` in ms and smoothed (ramped 2 -> 43 over ~2.5 s); `RenderGPUFrameTime` ~0 in Studio; `GetTotalMemoryUsageMb()` in Studio includes the editor (2+ GB) (field-measured). - `FindFirstChild` on a distant object returns nil, remote args arrive nil -> streamed-out instances are parented to nil. Send stable ids and resolve on arrival, or `Player:RequestStreamAroundAsync()` before firing (§4). - Delayed 1-17 s stalls after destroying runtime meshes on a big map -> engine background work (~12.5k `CreateMeshPartAsync` meshes, destroying 30). Retire them by unparenting and holding a reference (Studio solo, field-measured). ## Limits (field-measured, Studio PC unless noted) | Case | Measured | |---|---| | Studio playtest server tick | ~20 Hz: a "frame" holds ~3x a live 60 Hz frame's work | | Large data module require | 234-518 ms in Studio (compile), ~40 ms on phones (bytecode) | | 1,657 Parts parented one by one vs into a detached Folder + one attach | 12.3 ms vs 0.6 ms | | Count-capped per-frame work -> time cap + grid | 523 ms -> 19 ms | | `FindFirstChildWhichIsA` per Part in a 13k-child folder | 198 ms (linear scan; memoise per parent) | | `part.Parent` read / `GetPartBoundsInBox` | ~0.10 us / 6-15 us (`--!native` won't speed engine calls) | | New Part vs pooled | ~37 us vs ~7 us | | Clone+parent quiet vs with thousands of moving parts | ~30 us vs ~500 us | | Lazy BVH: warm ray vs first shot building it | 0.13 ms vs 2-13 ms | | Destroy a 145k-part map in one call | 2.5 s frame (slice ~30 ms with `task.wait()`) | ## Review checklist | Symptom | Check | |---|---| | Lag numbers from Studio | Solo vs server+client, window focus, ~20 Hz server, editor memory; confirm on a phone | | Crashes | Dashboard crash type/platform, memory over a long phone session, never-destroyed meshes/debris | | Memory grows | Player/Character destroy behavior, connections, runtime meshes held, caches never cleared | | A fix "should" help but doesn't | Benchmarked in the reporter's state? Worst frame from another system? Harness work inside the window? | | GC spikes | Allocation source elsewhere (the allocating frame isn't the stalling frame) | ## 1. Measuring right - Detect the Studio focus cap from inside the game: ~4 simulation steps per drawn frame when capped, ~1 when focused. - Time physics yourself from `RunService.PreSimulation` to `PostSimulation`. On the server it reads ~0 when costly bodies are client-simulated, so log the client. - Unexplained stall: timestamp each frame stage (`PreRender`, `PreAnimation`, `PreSimulation`, `PostSimulation`, `Heartbeat`) and log `gcinfo()` and memory beside frame time. A gap with flat memory rules out Luau allocation; a one-frame jump of tens of MB points at script work. Keep logging past the trigger: the worst frame can come seconds later. - Custom labels: `debug.profilebegin`/`debug.profileend` (balanced, same thread), `debug.setmemorycategory` per long-lived thread; gate them behind a flag. The MicroProfiler Detailed view has search (Ctrl+F); Studio's Assistant or an MCP agent can read a paused capture, but treat its report as a lead (2026-11). - Split a big label before trusting a saving: ten verified fixes moved p99 only 91 -> 76 ms. A "last slow frame" label explains that frame, not a low average. - Keep harness work (screenshots, big scans: one ~450k-part scan made 250-320 ms server frames) out of the window. - Benchmark in the reporter's state: a fix that won on a fresh map did nothing at hundreds of settled debris pieces (3x the bench). One switch per variant; per-item cost rose under load (0.1 -> 0.3-0.4 ms). - Time what the player sees, not when work ends (this exposed a newest-first queue). Studio has no real round trip: run network features under a Studio network profile. - "Clean up performance": total each system's ms/frame in idle, action and heavy scenarios on server and client separately; the biggest waste was idle polling. Price a cache by switching it off (one warm-up spent 150-520 ms to save 15-100 ms). Sum per-system budgets against the frame. ## 2. Memory and crashes - `DataModel.ServerLowMemoryWarning` is best effort, may fire repeatedly, guarantees nothing: make the handler idempotent and cheap (clear rebuildable caches). ## 3. Hot paths - Build Parts under an unparented Folder in time-budgeted slices, attach once, remove with one `Folder:Destroy()`. Drive loading bars from real progress (a replicated attribute). - Engine calls dominate loops: cache facts an anchored part never changes in a weak-keyed table (~40% cut once). Keep a separate actionable set instead of walking every item (~1.5 ms/frame on ~2,700 idle items). - Do lazy loads during an action's wind-up on a per-frame budget (worst frame 87-96 -> 34-47 ms); build indexes at load, not on first use; filter before forcing lazy modules (1,601 requires: 1,415 ms, 68 MB). - Many props: no script per prop. State as replicated data, one server system at a fixed rate, one client system moving only active props with one `workspace:BulkMoveTo`. - Luau: global chains like `math.floor` are resolved at load ("imports"), so `local f = math.floor` and hoisting `#list` buy nothing. `getfenv`/`setfenv`/`loadstring` make the environment impure and disable imports and `--!optimize 2` inlining. - Parallel Luau: only for profiled, isolatable CPU work. `require()` can't run in a desynchronized phase. `Actor:SendMessage` copies arguments (no functions); `BindToMessageParallel` runs the callback in parallel. SharedTable can't hold Instances or functions; `SharedTable.update` may call `f` more than once (keep it pure); a deep clone isn't atomic (`cloneAndFreeze` for stable worker views). - Web-backed calls (`GetProductInfoAsync`, `UserOwnsGamePassAsync`, `GetItemDetailsAsync`, `GetBundleDetailsAsync`) batch automatically when started close together: start them concurrently with `task.spawn` + `pcall`. ## 4. Streaming - Only Workspace descendants stream. `ModelStreamingBehavior = Improved` streams a Model's non-BasePart descendants with it; a Model with no BaseParts replicates at join. Streaming radii, `StreamingIntegrityMode` and `Workspace.PredictiveStreamingMode` carry `PluginOrOpenCloud`: Studio/plugins/Open Cloud only, not game scripts. - Client copies: a local clone of a server instance gets no updates; a client `Destroy()` of a server object streams back. Client physics runs only in streamed areas; add a replication focus near anything that must keep simulating. - `Player.FrustumStreaming` (2026-10) is **server-only** (validate a client remote, then set it), additive (more memory, never less work), uses the camera FOV directly (benchmark at the widest FOV), has no occlusion, needs draw distance beyond the target radius, and may be off on low-end devices. Pre-stream fast camera moves with `RequestStreamAroundAsync`. - SLIM (`Model.LevelOfDetail = SLIM`): needs StreamingEnabled, a place saved to Roblox and Team Create; static models only (no runtime changes, animation or `Humanoid`). Unions can render wrong (own model), coplanar faces z-fight (0.01 studs apart), UVs are regenerated. - DevForum reports (2026, recheck status): parts moved millions of studs away and back stopped rendering on Windows (park pooled parts nearby or unparent); world textures unload in long Studio sessions (compare a fresh Studio and a live client before re-uploading); periodic micro-stutters in an empty baseplate (reproduce empty before blaming game code).