Page 1 of 1
Large zones and performance
Posted: Sat Jun 25, 2016 11:10 am
by Gangrenous
Are there things we need to know about zone design and performance? I can definitely tell when my Antonica is running. I am hitting 60% on CPU usage when the zone is open. What really drives up processor usage? Is it when mobs are moving or in each others personal space? I am just trying to get a grasp on everything still. I am thinking at the current rate I would be lucky to have just a few large zones going. Something is definitely driving up CPU usage and it does not seem quite right.
Re: Large zones and performance
Posted: Sat Jun 25, 2016 2:44 pm
by Jabantiz
We have never had a large zone like antonica spawned but 60% seems high to me, I will have to test some things out.
The things that will cause the CPU to shoot up are movement and combat. If a client is logged in it will cause the biggest jump because of all the packet checks. I am not sure of anything that would cause a jump that large though, but again we never had a zone that large completely spawned.
Re: Large zones and performance
Posted: Wed Jul 06, 2016 9:02 pm
by Gangrenous
I am hitting a regular 60-70% on a very beefy system. If there is a ton of combat going on, I am on occasion hitting 100% with a few checks lowered on the ms number. I do not care for the default settings, the NPC's are a little sluggish with the defaults. I cannot imagine if clients had maybe 10 zones open. If 10 or 20 zones were open it would kill any server.
What can be done about this? A few of the zones if fully spawned have a lot of activity at any given time. There are a lot of things I can fix on my end, but this may be beyond what I can handle. With aggro changes that I implemented, that just made it worse. If you have a spawn looping through every spawn checking to see if another spawn is in range, well that just bogs it down more.
Re: Large zones and performance
Posted: Thu Jul 07, 2016 9:57 am
by Jabantiz
Reducing timers in the zone server will put a larger load on the cpu. Other then that I couldn't tell you off hand what to change as it would need a lot of investigation to figure out where optimizations need to be.
As for your agro changes, it might be a good idea to make a map in the zone server of spawns in the faction, something like map<faction id, vector<spawn id> > and then only do your distance checks on spawns within the same faction, or you could even do friendly factions with the map too. Also I assume you are doing proper distance checks, you can skip the square root part of it if you take the radius and square it then do your checks against it, that should save the cpu some calculations.
Re: Large zones and performance
Posted: Sun Jul 10, 2016 9:06 am
by Gangrenous
Question, on "always loaded" static zones...
Do the NPC's stay moving on their paths when the zone is not player occupied? How about combat checks and vicinity checks when the zone is not player occupied?
Re: Large zones and performance
Posted: Sun Jul 10, 2016 9:18 am
by Gangrenous
I reversed my code changes temporarily. Still though, Antonica should not be hitting 60%-75% usage on some adjusted settings. If I kick my rule_details back down it does drop to 45% usage, but that is still really high. Two large zones open will kill a processor. I am guessing the design does not take usage of multi-core processors? I think we definitely do not need to have the mobs stop when a player is not in the area, that is not realistic. I plan on implementing boats so I would want the boats moving if a player is not around.
The CheckAttackPlayer and CheckAttackNPC being at 2 second is just too sluggish to me. Setting them to around 400ms or below seems more realistic, the difference is like night and day. So the goal is to have them where I like them and zone usage being around 10%, hell even less would be better. If you think in a production server it will not be unrealistic for there to be players spread out in 20 or more zones. If each zone is using 10% and we do not take advantage of multiple cores then that puts usage at 200%, literally killing the ability to play. I know for certain when you go above 100% the npc's start jerking around until the processor can catch up.
If the executable can take care of multiple cores then that does help quite a bit. I still think it would be better to make some optimizations to lower usage.
I will do what I can for code but I am not at the level you guys are.
EDIT: I am seeing some past database dumps where it was defaulted to 2000ms and others 200ms, not sure which is what meant to be without looking at the default rules in the source. At 200ms the usage definitely goes past 65%
Re: Large zones and performance
Posted: Sun Jul 10, 2016 3:22 pm
by Jabantiz
The server already does use threads, I am debating some stuff with another c++ dev but I don't know if I would have the time to see it through. I also don't like the idea of stopping spawns completely when a player is not around. For now it would be best to play with timer settings until we come up with a real solution. You may also try bumping the delay time on the main zone server threads as they are currently at 10ms and 20ms, maybe pushing them up to 100-200 might help with hopefully no ill effects, this would be in zoneserver.cpp, in the global scope
Code: Select all
ThreadReturnType ZoneLoop(void* tmp)
ThreadReturnType SpawnLoop(void* tmp)
Re: Large zones and performance
Posted: Sun Jul 10, 2016 3:31 pm
by Gangrenous
Hey Jabantiz, how could i spin off multiple Antonica's as something like an instance? I want to try to get 4 going to see the effect. I am messing with some settings now and have the usage down to a better level.
Re: Large zones and performance
Posted: Sun Jul 10, 2016 4:49 pm
by Gangrenous
Okay between the regular source and my additional changes, down to 35% CPU usage. My assist changes were raising it 10% but I got that down to less than 1%. I am happy with that. I still would really like to see the usage down further but that will come in time. I just moved a check on the assist code further up, basically never iterating the zone line unless the spawn in question was in combat, I had that but it was after iterating the zone (duh).
I still would love to spin off multiple Antonica if you can tell me how.
Re: Large zones and performance
Posted: Sun Jul 10, 2016 5:49 pm
by Jabantiz
Turn antonica into an instance (by changing `instance_type` in the zone table to group_lockout) and every client going into that zone should boot up its own. They have to enter by normal means though, /zone will put you in the base zone that the instances are based off of.
Re: Large zones and performance
Posted: Wed Jul 20, 2016 7:33 am
by Gangrenous
Thanks for answering that question Jabantiz.
Re: Large zones and performance
Posted: Wed Jul 20, 2016 10:06 am
by Gangrenous
Okay, further update. I changed my Antonica to a group instance as you said. I brought in 4 characters, which spawned up 4 instances. CPU usage in Debian jumped up to around 134% and I started a battle. It seemed to handle it fairly well, not perfect. I want to do normal leveling like this sometime this week to see if I notice any bad lag. So as long as one zone is not using 100% we are okay. If a combination of zones are surpassing 100% it does seem to fair well. I think the way CPU utilization works in Linux as far as TOP goes, if you have 4 cores then you have to hit 400% before you are tapped out.