PiTyUs.Hire me

Engineering

Using the FiveM profiler to find slow code

How to use FiveM’s built-in profiler on the client and server: profiler record, status, view and saveJSON, opening profiles in Chrome DevTools, reading frame time and resource threads, and turning a spike into a fix.

Updated 10 min readBy PiTyUs · FiveM developer

Overview

resmon tells you which resource is slow; the profiler tells you why. It records every frame for a few seconds, then shows exactly which resource, which thread and which line took the time — on the client or on the server. It is the tool that ends arguments about which script causes “server lag”.

01Recording a profile

  1. Wait until the lag is happening (or reproduce it).
  2. Server: type profiler record 500 in the server console. Client: open F8 and type the same.
  3. Check profiler status until the capture completes.
  4. Run profiler view to open it in Chrome — on the server, copy the link it prints into Chrome.
  5. Or save it with profiler saveJSON lag-2026-09-11.json to study later or share with a developer.

Reading the result

The profile opens in Chrome DevTools’ Performance view. Frame time is shown per frame; tall frames are hitches. Zoom into one, then hover the coloured blocks beneath it: each shows the resource and the file and line it was running, with its duration in milliseconds.

  • One block that is always wide → a heavy function that runs every frame.
  • Occasional huge blocks → a database callback, a big loop or a large event payload.
  • Many small blocks from one resource → too many threads or per-frame loops.

Server hitches

When the server console prints “server thread hitch warning”, the main server thread took too long for a tick. Profiling the server during those moments shows which resource blocked it — usually synchronous work in an event handler, a huge loop over players or a slow query waited on in the wrong place. The minimap studio’s server performance guide covers the server side in more depth.

Turning a finding into a fix

Profile showsTypical fix
A per-frame loop doing distance checksAdaptive sleep — threads and Wait
Repeated native calls in one functionCache results in locals — Lua performance
A database wait in a hot pathCache or batch queries — oxmysql
A huge event payloadSend less, or use latent events — events

Frequently asked questions

How do I use the FiveM profiler?

Run profiler record 500 in the server console or F8, wait for profiler status to finish, then profiler view to open it in Chrome.

Where does profiler saveJSON save the file?

In the folder containing your server’s run script.

How do I open a saved profile?

In Chrome DevTools, open the Performance tab, right-click and load the profile JSON.

Should I use resmon or the profiler?

resmon to find which resource is slow; the profiler to see which function inside it and why.

Need this built, not just explained?

Ten years of FiveM work, from Lua to NUI

Custom resources, React NUI, ESX / QBCore / Qbox integration, OneSync performance audits and security reviews — plus the websites and SEO around your server brand.

Related guides