How to optimize objects loading -
NoteND - 30.12.2018
Hey!
Thats probably my last time posting this since I dont wanna spam it really.. basically what is happening is that I'm using XML Loader to open .map file, and from that map file I'm getting object, racepickup and spawnpoint coordinates (info).. now.. racepickups and spawnpoints load fine since there arent many of them, but objects take about 10-20seconds to load which is fine, but what I do not understand is why during that time it seems like server is freezed, you can move and stuff but you cannot type anything into chat.. whatever you type will appear after objects load.. so I need help with how to optimize it so that its gonna load objects but not completely freeze the server. Thanks for help !
https://pastebin.com/gEw9SQB2
p.s. I use the same code(script) for loading racepickups and spawnpoints
Re: How to optimize objects loading -
serqq - 30.12.2018
Your server freezes because SA:MP server runs on single thread - that means it cannot run multiple blocks of code alongside each other and they are waiting "in line" to be executed. Most of the time it is not a problem as it doesn't run much demanding tasks, but parsing a big XML file can be indeed demanding.
You can try this plugin
https://sampforum.blast.hk/showthread.php?tid=653097 to make the whole function run in other thread alongside your server so it will be possible for server to process player commands etc. I've never used it myself, so I don't really know if it works.
How many objects are you trying to load? Just asking from pure curiosity.
Re: How to optimize objects loading -
BlackyX - 30.12.2018
Are you using 0.3.7 or 0.3.DL?
Re: How to optimize objects loading -
NoteND - 30.12.2018
Quote:
Originally Posted by BlackyX
Are you using 0.3.7 or 0.3.DL?
|
0.3.7 no DL
Re: How to optimize objects loading -
NoteND - 30.12.2018
Quote:
Originally Posted by serqq
Your server freezes because SA:MP server runs on single thread - that means it cannot run multiple blocks of code alongside each other and they are waiting "in line" to be executed. Most of the time it is not a problem as it doesn't run much demanding tasks, but parsing a big XML file can be indeed demanding.
You can try this plugin https://sampforum.blast.hk/showthread.php?tid=653097 to make the whole function run in other thread alongside your server so it will be possible for server to process player commands etc. I've never used it myself, so I don't really know if it works.
How many objects are you trying to load? Just asking from pure curiosity.
|
There are on average around 4000 objects, sometimes more sometimes less
EDIT: i've tried loading 30000 objects myself once I was doing some other project, and they loaded literally in a second.. so idk whats problem here
Re: How to optimize objects loading -
serqq - 30.12.2018
Quote:
Originally Posted by NoteND
EDIT: i've tried loading 30000 objects myself once I was doing some other project, and they loaded literally in a second.. so idk whats problem here
|
Were you using the same loader for reading the XML file? It sounds like your .map file may be corrupted or something.
You can try using other XML loaders, maybe this one that you're using is badly optimised.
Re: How to optimize objects loading -
NoteND - 30.12.2018
Quote:
Originally Posted by serqq
Were you using the same loader for reading the XML file? It sounds like your .map file may be corrupted or something.
You can try using other XML loaders, maybe this one that you're using is badly optimised.
|
I'm using same loader for meta.xml yes, as I said, there's only problem with objects, racepickups, spawnpoints and meta.xml info (weather, time) is red perfectly and instantly since I tried removing objects part just to see how it reads, in a second its done.
Re: How to optimize objects loading -
NaS - 30.12.2018
XML parsing is extremely slow if there are a lot of values. Just see how many values there are in an MTA .map file per entry, especially objects!
The meta.xml file is just a few bytes at most, that's why it is that fast.
Even a PAWN parser for MTA Maps is faster than the XML plugin, since half of the values in the XML aren't even usable in SAMP (the XML Plugin still parses them).
Re: How to optimize objects loading -
NoteND - 30.12.2018
Quote:
Originally Posted by NaS
XML parsing is extremely slow if there are a lot of values. Just see how many values there are in an MTA .map file per entry, especially objects!
The meta.xml file is just a few bytes at most, that's why it is that fast.
Even a PAWN parser for MTA Maps is faster than the XML plugin, since half of the values in the XML aren't even usable in SAMP (the XML Plugin still parses them).
|
So what do you suggest.. I try using filemanager or something like that?
Re: How to optimize objects loading -
NoteND - 01.01.2019
bump