Optimizing to use less CPU?

10/17/2011 01:50 BaussHacker#16
Quote:
Originally Posted by pro4never View Post
Use a form of thread safe collection such as concurrent dictionary.

(was debated at great lengths in another thread while everyone /facepalmed at people's refusal to upgrade to newer versions of .net)
That thread was a joke.
10/20/2011 11:55 sonofskeletor#17
Try to build multiple threading, 1st threading handles the database and the second threading handles characters, if you can pull it off your server will run with around 3 CPU most of the time, when a character disconnects make sure it dumps the character thread otherwise the cpu will rise.

Edit:
Also go into program.cs, Event_Handler and try to remove the catch, try's because this also rises your CPU.

Also another thing you can do, is make a partition on your :C Drive and store your database there, it helps load your database faster if its on its own drive, and causes less lag.

CPU is the brain of a computer it handles what does what, ram is the speed of the computer
The better your CPU the faster it handles obviously better CPU is better performance on the other hand speed is essencial too.
10/20/2011 12:00 Korvacs#18
Dont go down the route of 1 thread per character, it was abandoned quite early on because your server really suffers when it starts to get a large number of players online.
10/20/2011 12:08 sonofskeletor#19
Quote:
Originally Posted by Korvacs View Post
Dont go down the route of 1 thread per character, it was abandoned quite early on because your server really suffers when it starts to get a large number of players online.
Thats because they dont know how to dump threads when a character disconnect figure that out like Impluse did and your laffing, on the other hand would you answer my post :)
10/20/2011 12:23 Korvacs#20
Quote:
Originally Posted by sonofskeletor View Post
Thats because they dont know how to dump threads when a character disconnect figure that out like Impluse did and your laffing, on the other hand would you answer my post :)
No its because when you get 250 people online you have 250 active threads where a handful/a threadpool would do the same job. :rolleyes:
10/20/2011 12:25 sonofskeletor#21
Agreed but who said anything about single threading for individual characters

I said 2 threads, 1st thread handles the database, mob spawns etc

2nd thread handles the whole character database.
10/20/2011 13:12 Korvacs#22
Quote:
Originally Posted by sonofskeletor View Post
when a character disconnects make sure it dumps the character thread otherwise the cpu will rise.
Quote:
Originally Posted by Korvacs View Post
Dont go down the route of 1 thread per character, it was abandoned quite early on because your server really suffers when it starts to get a large number of players online.
Quote:
Originally Posted by sonofskeletor View Post
Thats because they dont know how to dump threads when a character disconnect figure that out like Impluse did and your laffing, on the other hand would you answer my post :)
You did... :confused:
10/20/2011 13:28 sonofskeletor#23
When i said dump character thread i meant, disconnect the character from the server, and im not here for a debate i came to give advice.
10/20/2011 13:34 Korvacs#24
..Ok well they are entirely different and seperate things, a character class or structure uses up memory, not CPU, your right that the character should be disconnected from the server and provided that is done then the GC will remove the character object provided its no longer being referenced, which should be the case if the disconnection is handled correctly.

But that has nothing to do with threads.

A thread could be compared to a road, things move along/through it and are handled depending on their circumstance, a class/struct/object could be likened to a vehicle that travels along that road and exits at various points depending on their circumstance.

This is a weak analogy since its just a generalisation of threads, but you get the general idea.
10/20/2011 13:38 ryuchetval#25
I don't use 1 thread per character...i use 2 threads to handle character effects (sit, xp ko, buffs) and 2 threads to handle attacks (for all characters online).

Using 1 thread per character when a large amount of players are online will indeed make CPU go crazy as Korvacs said...anyway the most important thing that makes the CPU stressed are drops (searching in database items) and mobs searching for a target (I managed to reduce this as much as possible).

Even so...I'll make a few tests with stopwatch to see what threads take the most amount of time to run.
10/20/2011 14:11 sonofskeletor#26
This is a very good resource to use, you can moniter threads and close threads and shit with it, [Only registered and activated users can see links. Click Here To Register...]
10/20/2011 14:32 ryuchetval#27
Hmm I will test that one too and see what it does.