Jump to content

[Project / WIP] dayzChunks - Load Objects in a chunk style as opposed to all at once


striker

Recommended Posts

This is an extremely ALPHA project and by no means is appropriate for production servers! ONLY FOR DEVELOPMENT SERVERS (when released)

 

Hey guys,

Intro

Just want to share with you my latest project that I have been working on. One of the biggest issues I have seen with running a server is low fps do to the shear amount of objects in the server. I pondered on how I could solve this issue. One of the first games to pop into my head was Minecraft. Why is Minecraft significant? It's significant because the size the levels can be can practically be unlimited to the average person, and the way they achieve this is, well, level chunks. So I decided I would take this concept and apply it to the object spawning mechanism.

 

The Mechanism

The way dayz currently spawns in objects is it spawns everything in at once when the server starts. This creates lower FPS on the client side because the clients have to account for all of those vehicles. The way I have reworked the mechanism is to put all the objects into an array for later access. I get the chuck the players are in by using a function that divides their location by the chunk size. This in turn, creates a array location which can also get the objects within their chunk. You can also apply a chunk radius which will be added and subtracted from the current chunks location. This is done to prevent only one chunk to load at once.

 

Benchmark

Here is a few screen shots of the script in action and then without the script. This is on a public server with less than a thousand objects on the server. (FPS in upper right hand corner)

 

With chunk script

ArmA2OA+2014-12-07+16-36-03-48.png

ArmA2OA+2014-12-07+16-35-01-43.png

 

Without chunk script

ArmA2OA+2014-12-07+16-41-58-69.png

ArmA2OA+2014-12-07+16-43-45-08.png

Result: As you can see from the pictures, rural areas on the map, FPS increase is close to +20, while on the city side of the spectrum, FPS increase is a mere +5 FPS.

 

But that is not where the script is suppose to shine... What if I told you we could have 10,000 object on the server with a decent FPS? Lets try it at 2,000 vehicles first shall we  ;)

 

With chunk script

ArmA2OA+2014-12-07+17-09-36-75.png

 

Without chunk script

ArmA2OA+2014-12-07+17-33-59-19.png

 

Result: Yep, chunks helped tremendously with the FPS of the client. It's FPS was a shear +38 fps more and there was 2,000 vehicles.

 

The performance increase is great but there still is a long road(network lag) ahead of the script.

 

Any thoughts? Should I continue with it? IS IT THE FUTURE?

 

Ill share the script once I have it to an exceptionable point. However, if there is a massive influx of people who want to see it for themselves, I might release what I have now.

 

 

 

 

Appreciate and support my work? btn_donate_LG.gif

Link to comment
Share on other sites

Why is this not standard in dayz!!!

 

dude you may just changed they way dayz works forever!

 

Question time.

 

1. Are the chunks loaded local or still serverside?

 

2. If im in a chunk with 100+ vehicles will it affect others in different chunks?

 

3. Is there any lag/loadtime when moving from chunk to chunk? (i saw there was network lag in your post is this the issue? )

Link to comment
Share on other sites

Hey everyone,

 

Thanks for your interest, ill be releasing some code tomorrow.  :lol:

 

I have to get the Build Vectors update out first, then Ill be moving onto this project more.  :)

 

@f3cuk, I seen your work from Sandbirds link in his post, and mixing the too scripts should be a really good mixture. Your script handles objects that can be spawned client side and my script to handle objects that need to be synced across all clients. So, in basic terms, mine will handle Vehicles, Storage, Doors, and the Dynamic Debris stuff, while yours handles Map Addons, and most Modular Building Objects. We can discuss more if you would like.

 

striker

Link to comment
Share on other sites

The Mechanism

The way dayz currently spawns in objects is it spawns everything in at once when the server starts. This creates lower FPS on the client side because the clients have to account for all of those vehicles. The way I have reworked the mechanism is to put all the objects into an array for later access. I get the chuck the players are in by using a function that divides their location by the chunk size. This in turn, creates a array location which can also get the objects within their chunk. You can also apply a chunk radius which will be added and subtracted from the current chunks location. This is done to prevent only one chunk to load at once.

If i understood it correctly, you are iterating over the array x times per minute and check if the player is near the object?

The question is, if this is realy more sufficient then the current solution. Do you plan the to delete the objects after the player has left the corridor? Because this would produce a lot of lag, but keeping them would result in lower fps...

Well the other Question is, why are your fps so low? Our server has >7000 Objects and the fps is pretty good about 60fps on most clients. The only issue we got (why we need to delete them sometimes) is, that the player sometimes spawn as seagull, if there was a lot of action... so the synchronization is a huge problem.

 

This way maybe it would be better to spawn the non gear objects local instead and broadcast all damage informations about the network.

Link to comment
Share on other sites

I am always happy with some nice ideas but I am not sure if Minecraft is what we want here ;))

I have a tekkit lite server now for about 2 years and one of the things which does not work very well in my opinion is chunk-loading. People moving fast (flying around) or teleporting (not important in epoch) slow down the server enormeously.

 

How does that normally work in dze: is the load only generated at server start as you point out in 'The Mechanism' or is the game looping over all objects the map all x secs/mins? How did you then create the screenshots with the measurements? Is that what we see when you login or at any time standing there. I guess I did not understand processing of objects so far ,)

Link to comment
Share on other sites

is the load only generated at server start

did you mean loot?

the lootspawn is triggered every few seconds, the lootspawn function gets called and then checks if you are in a vehicle or something like that. if not it gets all buildings arround you, reads and adds some variables (if loot got spawned or when the building got lootet) and then the loot gets spawned or not... this function also spawns the zombies following some rules. afterwards  there is a cleanup loop which delets the lootpiles and resets the variables.

 

This was a very short and inaccurate explanation, if you want to see how it realy works consider the file "player_spawnCheck.sqf".

Link to comment
Share on other sites

If i understood it correctly, you are iterating over the array x times per minute and check if the player is near the object?

The question is, if this is realy more sufficient then the current solution. Do you plan the to delete the objects after the player has left the corridor? Because this would produce a lot of lag, but keeping them would result in lower fps...

Well the other Question is, why are your fps so low? Our server has >7000 Objects and the fps is pretty good about 60fps on most clients. The only issue we got (why we need to delete them sometimes) is, that the player sometimes spawn as seagull, if there was a lot of action... so the synchronization is a huge problem. This way maybe it would be better to spawn the non gear objects local instead and broadcast all damage informations about the network.

 

Ugh all these assumptions..

 

--

 

I'm not sure what approach striker is talking about, but the way we did it (note present tense) is simply spawning objects around a player that is within their view range. It's hardly optimized and already producing really good results. After I'm done optimizing it, which basically means making a better prediction of what needs to spawn when in order to prevent a player from seeing objects appear.

  • If a player is not moving, do not update - Done
  • Only update when the player has moved X meters from when the last check took place - Done
  • Increase check interval if player gets close to the edge of the update radius - Done
  • Calculate the speed in which a player is moving and adjust either the interval/or object spawn range - To do
  • Based on the the direction and speed the player is moving, shift the center of the object spawn radius. - To do
  • Adjust settings based on PC performance, a faster pc can have a lower radius because it handles objects spawning quicker - To do
Link to comment
Share on other sites

  • If a player is not moving, do not update - Done
  • Only update when the player has moved X meters from when the last check took place - Done
  • Increase check interval if player gets close to the edge of the update radius - Done
  • Calculate the speed in which a player is moving and adjust either the interval/or object spawn range - To do
  • Based on the the direction and speed the player is moving, shift the center of the object spawn radius. - To do
  • Adjust settings based on PC performance, a faster pc can have a lower radius because it handles objects spawning quicker - To do

 

Well yeah, this this sounds more interesting, but maybe you should think about spawning all buildables without gear just local, this way the game itself does not have to synchronize them. The only important synchronizations could be done via script.

 

Specially how do you plan to handle the gear, if you are really deleting the objects (since you did not answer this question)?

Link to comment
Share on other sites

Well yeah, this this sounds more interesting, but maybe you should think about spawning all buildables without gear just local, this way the game itself does not have to synchronize them. The only important synchronizations could be done via script.

 

Specially how do you plan to handle the gear, if you are really deleting the objects?

 

We spawn all indestructible / non-interactive objects local on the client. For more info check the thread SandBird linked above.

--

Striker is working on something that would do the same thing but for the objects spawned by the server (e.g. destructible / interactive objects).

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...