Jump to content

Map to Lua converter


Mr_Moose

Recommended Posts

Any ideas why .lua maps would be more laggy than regular .map maps? I think that depends on which properties are included in the conversation. This tool tries to detect as many properties as possible unlike the other converters. Thanks to xeon17 I found some more properties that I don't have in my own maps which I initially tested with such as LOD objects, collisions, and radius. Anyway, if the conversation is 100% accurate and the same mechanism is used to render the maps no matter if the source is .lua or .map it shouldn't be any difference. 

If .lua maps does get more laggy than .map maps then I might as well create a map minimize tools which compress and removes default values. :)

  • Like 3
Link to comment
On 30/3/2017 at 21:11, CodyJ(L) said:

One issue with this general logic, although it may be smaller; it is actually a lot more laggy to using .lua mapping vs .map mapping.

Exactly, I used to be dev in a server that we used to use a map converter, I realized that with ~20 players online I had more lag than with ~600 players in CIT, this is something that everyone in MTA must know, creating alot of maps using Lua code brings enormous lag it's just a CPU killer.

Personally I think it's ok creating that kind of map converters but be aware of the consequences, alot of people is not, due lack of experience or they just don't have maps with +5000 objects.

And I'm not talking in vain or just with conjetures, I'm talking from my own personal experience.

  • Like 1
Link to comment
1 hour ago, CodyJ(L) said:

I've done a lot of testing on this, .lua maps murder CPU usage for clients and drop their FPS alot; not 100% sure why, though likely has to do with how the maps are processed. Also, even  with / without properties; this occurs.

The process is basically the same, only thing different is that .lua one can be customized to be even better than default mta loading system. If .lua map loading system was this terrible, hundreds of servers wouldn't be using it.

  • Like 1
Link to comment

Your posts did make me wonder, was this really the case, so I run a little test of my own to prove or disprove the theory.

I have no idea how it's done in MTA's source code, nor did I bother to look, but I took it upon myself to find out through real example.

Testing environment setup as follows:

  • Latest editor definitions from nightly.mtasa, no edits or tweaks whatsoever
  • Client&Server build: v1.5.3-release-11225
  • Running resource during the time of testing: none, apart the resource being tested
  • A map with random 12k objects
  • No world movement, no camera movement, MTA minimized
  • Lua map converted with OP's website, without blips attribute (I also highly suggest removing the said feature as it may cause significant changes in performance & loading times) & ran client side
  • Server FPS Limit: 60

 

Results:

  • .map: bee516efd1db4c0faaabf286102d919c.png

 

  • .lua517ebee433de4253958b98663cb35efa.png

 

Conclusion:

.map is just fine as it is, but .lua allows better manipulation, the very important one being able to load a .lua map with async based on priority, and minimizing client side creation lag or prioritizing other server objects over other less important things

 

Hope this clears up some of the confusion. Keep in mind this was a very basic test without much fiddling around, if someone could confirm it by doing their own please do.

Edited by Mega9
  • Like 3
Link to comment

@CodyJ(L)
You keep repeating the same thing. Can you tell us some info for instance? Like how much objects were you testing, how does it generally work?

I can create 30,000 objects in an instant and edit their properties if needed or move them while they're being created without any stuttering. Maximum ever lag i had recorded for it was merely one second, but in 95% cases it's barely even noticeable that it did anything.

Edited by John Smith
  • Like 1
Link to comment

On average most of my mapping hits about 50+ thousand objects using .lua, my fps drops to 50% of what I usually experience, using .map my fps doesn't drop a single frame.

With no extra variables, every player who joined in the .lua phase reported a huge FPS drop, using .map they experienced little to no FPS drop. Maybe with a small amount of objects it won't mess with your FPS much, but as soon as you start getting a large amount of objects lag will sky rocket. You can ask any one who joined Heretrics during its open beta, at the time I was running .lua and everyone was getting lag map wise, (Myself included) after switching to .map no lag.

Edited by CodyJ(L)
  • Like 1
Link to comment

I have been using maps in lua format for years and never experienced problems.

4089 objects, 600 streamed in. (all loaded client side)

cwWVs66.png

When i took the screenshot above, only three resources were running (admin, runcode and a small spawn script)

Absolutly no lag, very low cpu and memory usage. My CPU.

  • Like 1
Link to comment

I don't know what your server is or how it looks like, if it has 3rd party mods on objects, no wonder it takes longer to load. I've just tested creating objects and it wasn't even noticeable at all.

Please note if you create huge amounts of objects at once near localPlayer (inside his stream; 300m radius) it will lag no matter which map loader type is being used due to GTA/MTA creating the objects and loading them in stream. It's kinda insane to do that around a player, it's better to warp him somewhere safe until objects are created because here are results:

Spoiler

30000 Objects
Executing client-side command: tick = getTickCount() x,y,z = getElementPosition(localPlayer) for i = 1, 30000 do createObject(912, 5000, y, z + 150) end result = getTickCount() - tick outputChatBox("Result: "..result.." ms")
Result: 154 ms
Command executed!

50000 Objects
restart: Resource restarting...
Executing client-side command: tick = getTickCount() x,y,z = getElementPosition(localPlayer) for i = 1, 50000 do createObject(912, 5000, y, z + 150) end result = getTickCount() - tick outputChatBox("Result: "..result.." ms")
Result: 260 ms
Command executed!

100000 Objects
restart: Resource restarting...
Executing client-side command: tick = getTickCount() x,y,z = getElementPosition(localPlayer) for i = 1, 100000 do createObject(912, 5000, y, z + 150) end result = getTickCount() - tick outputChatBox("Result: "..result.." ms")
Result: 523 ms

The process depends on client's CPU but even on slower systems it makes 100k objects outside stream under a second or two

Edited by John Smith
  • Like 1
Link to comment

It's probably best to ask the devs how objects actually are loaded internally, but I'm guessing it's all based on the already existing systems in GTA sa. No matter if you're using custom objects or built in objects the loading time should be equal. So to figure out why .lua maps would be slower than .map maps (which does seems to be the case when loading maps with over 1000 objects or so). I've had a deeper look on the code itself to see what's differ. This line here:

<object id="object (a51_jetdoor) (1)" breakable="true" interior="0" collisions="true" alpha="255" model="3095" doublesided="true" scale="1" dimension="0" posX="2522.3999" posY="-1273.19995" posZ="32.9" rotX="0" rotY="270" rotZ="359.75"></object>

Corresponds to this line in Lua code:

{3095,2522.3999,-1273.19995,32.9,0,270,359.75,1,0,0,255,true,true,true}

Note that the first line in the Lua code is the model number and not the ID from the map file saying "object (a51_jetdoor) (1)". Now that wouldn't be there if it wasn't used for something right? It's possible that MTA when loading a .map file into memory process the data within by sorting, hashing or indexing in a way that makes it faster to find and load a specific object during stream in. While in the converted Lua code you need to loop through the whole table in order to find the specific object you want to load. Obviously that will have a negative impact on the CPU.

Luckily since we're dealing with Lua it wouldn't be that hard to process the data differently, like only loading the 1000 objects that is close to a player instead of say 50´000 objects at once, a timer could also be used to load blocks of objects with a few seconds delay between each block. In any case there need to be an index so I'll guess I'll add a few different versions, one with index from 1 to N and one with a hash sum of the ID as index so that all of you with big maps can test the difference in performance, it might even be possible to make the .lua maps load faster than .map maps.

Quote
  • Lua map converted with OP's website, without blips attribute (I also highly suggest removing the said feature as it may cause significant changes in performance & loading times) & ran client side

The plan is to make all additional features optional and select able, for now I've disabled that line.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...