Hi everyone. I was recently writing some RunUO/ServUO AI scripts for (nothing fancy, some simple Animal behavior) and this made me wonder about issues related to CPU usage in RunUO/ServUO. I am currently developing on a Intel Core i5 3570K (4 Cores at 3,4 GHz, no hyperthreading) machine with 16 GB Ram running Windows 7. In no particular order, I guess my questions boil down to the following:

Is there any experience regarding the maximum number of AIs that can be run at once in ServUO and RunUO? I noticed that if I do something crazy, like fill the green acres with 100k sheep, that my server slows down quite a bit (granted, this is a bit extreme). I guess my broader question is about the average work load of AI instances. I assume on a more powerful CPU I can run more AIs? I was wondering if there is some quantitative information available.

In the same spirit, I was wondering if there are some specific things I can do for performance optimization, i.e. some tricks I can apply in my AI scripts to make them less demanding in terms of CPU resources (just generally speaking, I'm not thinking of a particular code example here).

Also, I was wondering about parallelization / multi-threading: Do ServUO / RunUO use it? Can I expect a server with lots of AI instances to run more stable on a machine with more cores?

Thanks for reading :)
 
  • Like
Reactions: FHB
like fill the green acres with 100k sheep
I think if you say to 100k sheeps start attack someone, or just *follow* - server will Die :)
I assume on a more powerful CPU I can run more AIs
Yes, than stronger CPU - than faster it will handle the process. In AI has problems, it all need optimize better. All servers got problem with it, but only if on server realy large amount of creatures or players.

I can't tell you exactly what you need to do to optimize these things, because need to look at what problems are present now and think about how they can be conveniently solved. But in any case, from my experience, I can say that there are enough problems and you can work on them. But you should not worry, because in a standard situation, you are unlikely to encounter serious problems. At least don't use 100k sheep at a time :D

As a starting point, you can use the Profiler scripts built into the server and pay attention to the problem areas related to AI behavior. first of all, this is an AI Timer, which is triggered with a certain frequency for each monster. Accordingly, the more mobs we have, the more timers we have that trigger every second, (if not faster). and this timer, in turn, causes the logic of the behavior of mobs depending on different situations. For example, pathfinding is the most resource-intensive process. And if the monsters try to find a short path to kill you , it will create a heavy load on the server.
 
Core usage does not scale linearly with demand. The server relies heavily on a single core with other jobs like save file generation and player vendor search using other cores. I'd say your best balance of cores and speed is a simple quad core revved as high as you can get it. If you're doing more with the same box, like web server / forums, then more cores than that would still be useful.
 
Sorry for the late reply. Thanks to both of you for the answers. So, is there a point in using "parallel foreach" in scripts? @Juzzver: What is this built-in profiler? Is there any place I can read abou them?
 
Sorry for the late reply. Thanks to both of you for the answers. So, is there a point in using "parallel foreach" in scripts? @Juzzver: What is this built-in profiler? Is there any place I can read abou them?
try check it:
 
try check it:
Thanks, I'm looking at the profiling output now. Very interesting.

These are the relevant lines I suppose:

# Timer
Server.Misc.FoodDecayTimer 74 23,01342 45,13554 1702,99341 1 1 0
Server.Mobiles.BaseAI+AITimer 1.478.097 0,00040 0,18819 589,26550 9.847 12.055 10.228
Server.Misc.AutoSave 8 0,36812 0,52370 2,94496


My understanding is that the first 5 columns are "Name, Count, AverageTime.TotalSeconds, PeakTime.TotalSeconds, TotalTime.TotalSeconds". I wonder what the remaining are.
Post automatically merged:

Is it correct to say the following: The server basically stores a large number of timer objects. It then carries out a loop, whereby in each iteration these timers are sequentially accessed and compared to the system clock to find out whether they have "ticked", and when they have, the OnTick() method is called? And this is done on a single core?
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back