View Issue Details

IDProjectCategoryView StatusLast Update
0009510New Feature Requests[All Projects] Generalpublic2018-09-30 14:28
ReporterarranTunaAssigned To 
Status closedResolutionopen 
Summary0009510: [Request] Break down of client CPU usage

I have a CPU that meets the recommended requirements for GTA V yet can't get stable 60 FPS in MTA, I went to a busy location (50 players streamed in) and the CPU core is almost at full usage. According to performancebrowser for the client bone_attach is using 10% and the rest wouldn't add up to another 10%. So there must be something that is using a lot of the CPU and there's no way of knowing what, for example, in the past we had an object mod, all it was were some sandbags yet the collision model of the object was so complex a few of these objects could cause a significant FPS drop.

So if this is possible I request something like '/showmemstat' but for CPU usage with a list of main things that are done each frame and how much time was spent doing each of those things, so that server owners can diagnose poor performance:

  • Misc. MTA (Miscellaneous MTA stuff like player join)
  • Misc. GTA (Miscellaneous GTA stuff that isn't in this list)
  • Lua Scripts (All time spent on Lua stuff)
  • Shaders (Does this use some CPU as well as GPU?)
  • DX (Time spent rendering DX stuff)
  • ColShapes (Time spent processing colshape stuff)
  • Objects (Time spent processing object collisions)
  • Vehicles (Time spent processing vehicle collisions)
  • Peds (Time spent processing ped collisions)
  • GTA Audio (Time spent on GTA audio if possible)
  • MTA Audio (Time spent on MTA created sounds)
  • CEF (Time spent on CEF stuff)
  • Clothes (Time spent processing clothes if possible)
  • GTA FX (Time spent on effects such as smoke)
  • Files (Time spent opening files etc)
  • GUI (Time spent processing CEGUI stuff)
  • Lights (Maybe time spent on the GTA lights)
  • Markers (Maybe time spent on markers)
  • Pickups (Maybe time spent on pickups)

The above list is just an example, the more things that can have their own usage recorded the better, but I have no idea if most of this is even possible as I don't know how much info MTA can get from GTA. I think the main CPU problem is that GTA SA seems to process collisions inefficiently because:

crun for i=1, 200 do createPed(1, getElementPosition(localPlayer)) end -- Gives me 15 FPS.

crun for i=1, 200 do setElementCollisionsEnabled(createPed(1, getElementPosition(localPlayer)), false) end -- FPS stays at 60.

TagsNo tags attached.

Users sponsoring this issue
Sponsors List Total Sponsorship = EUR 30

2016-12-25 12:32: arranTuna (EUR 30)
Users sponsoring this issue (Total Sponsorship = EUR 30)



2016-12-25 12:48

viewer   ~~0025550

Are you using default nametags? If yes, what happens when you disable them and leave no nametags visible at all?


2016-12-25 13:07

manager   ~~0025552

Yes and disabling them made no noticeable difference.


2016-12-25 14:38

reporter   ~~0025553

setElementData is pretty much one of the slowest functions that can cause CPU issues, use Performance browser with -d option for clients to see which function in a script causes the drain. I hope its not a function with 2000 lines because then it will be hard to find out which line causes it, if its not caused by the MTA sync itself.


2016-12-25 16:11

manager   ~~0025554

If it's a script, it's not showing in performancebrowser, which is why I'm requesting a break down of other things, in case it's something like an inefficient mod.


2016-12-26 13:14

viewer   ~~0025556

I support! I have problems finding inside the script what causes me lag!


2017-04-28 19:19

reporter   ~~0025857

Little note: Not only Ped collisions cause a significant FPS drop.
20 vehicles on the same place are just as good. If you disable collisions of these 20 vehicles, your frame rate will go back to normal.

GTA seems to have a terrifying bad way to calculate collisions and i hope it can be fixed somehow because many players complain about terrible performance in locations where many vehicles are stored (like an aircraft carrier) and even with my i7 6700HQ i drop from 50fps to 32 fps just because there are 9 planes, 2 helicopters, 8 boats and 6 tanks.
Now imagine what happens when there are 30 players around. A drop under 20 fps can happen.


2017-04-29 07:25

developer   ~~0025863

I might be working on a solution for this issue, because it's very related to my personal issue. I am trying to create a resource to analyze the time spent in addEventHandler callback functions, especially in render events. My current code shows this on your screen:

This is not possible in the current MTA code base, but I work on it:


2017-04-30 02:40

reporter   ~~0025869

Isnt this the exact same information that performance browser gives you? It shows which onClientRender consumes the most performance.

Which wont help fixing the biggest performance hog, aka collisions (Or 200x dxDraw...) because a Lua scripter cannot fix collisions or make dxDraw functions faster.


2017-04-30 20:04

manager   ~~0025873

Last edited: 2017-04-30 20:06

View 2 revisions

Scripts that call DX functions a lot can usually be optimized by using screen source so for example a HUD can be drawn (then you draw the screen source which is only 1 function call) once every 500ms instead of every frame.

It's the collision processing that is unavoidable though. I wonder if MTA could make collision processing take place less often like instead of every frame it could be done every second frame assuming that wouldn't break everything.


2017-05-01 16:04

reporter   ~~0025889

It would most likely cause fast objects to clip through surfaces.

About the DX performance, do you talk about render targets?
For example instead of drawing 5 circles with 200x dxDrawLine using a RenderTarget and draw the RT then improves performance?


2017-05-20 01:37

reporter   ~~0025970

Last edited: 2017-05-20 01:38

View 2 revisions

I found a dirty fix for the high Vehicle collision CPU usage, but its hilarious.

My server creates vehicles and immediately freezes them (So they dont fall through ground or so) and they get unfreezed as soon as a player enters them.
Before, a base with 30+ vehicles stored in it caused my fps to drop from 45 to 35.
Now this is the trick:

function onStreamIn
if isElementFrozen(source) and getElementType(source) == "vehicle" then
local veh = source
setElementCollisionsEnabled(veh, false)
if isElement(veh) then
setElementCollisionsEnabled(veh, true)
end, 1000, 1)
addEventHandler("onClientElementStreamIn", root, onStreamIn)

This code disables the collisions of all frozen vehicles sitting anywhere as soon as they stream in and re-enables them after 1 second (or at LEAST 500ms). This solves the CPU usage issue completely. This fix has to be re-applied everytime a vehicle streams in.

I have no idea why this works lol, but now i have constant 45 fps (locked).


2017-05-20 23:11

manager   ~~0025972

It's because they're frozen, I just created a load of frozen cars and FPS was unaffected until I touched them, FPS drops terribly on contact.

Issue History

Date Modified Username Field Change