Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Is this a safe way to speed up my server?

Author
Message
Qqite
16
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 27th Feb 2011 23:41
My old loop for my server used to have all my functions followed by a "sync" for every loop. This didn't seem very necessary in my mind so what I did is change to this:

By changing my FPS to LPS my LPS changed from 2500 LPS to a crazy 522000 LPS. Is this valid? Or am I just slow and needed to do this a long time ago xD

Ventures of the worlds around us are only limited by imagination.
Wyldhunt
16
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 28th Feb 2011 07:14 Edited at: 28th Feb 2011 07:17
That's valid if your UI is mostly static. Since the UI is only updating once per second, it may appear to be very very laggy to anyone using it. If they click a button and your code to detect a button press is in your UI, they may need to hold the button down for a full second before it's recognized. If you're tracking button press via a global var somewhere in the main loop, the button press may be caught immediately, but the UI still wont recognize it for up to a second later. Then you'd have to reset the global keypress var in the UI functions...

Overall, it will probably work, but people will hate the laggy feeling of it if the UI has to update based on user input.
If it just auto-updates health and ammo and random game stats that are not dependent upon user input, then it may be a good idea.

Of course, this all depends upon your program too. If it's a 3d game, you have to sync every loop to update animations and characters.
Qqite
16
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 1st Mar 2011 02:34
Ok this is not good, with both methods, my server is KILLING my cpu. Running on an actual server computer, this would be ok. But we're talking a 4% to 87% difference in cpu usage. Does anyone know how to tell this program to slow down a bit? Should I pop in a "Wait 1" to make the program give leeway?

Ventures of the worlds around us are only limited by imagination.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 1st Mar 2011 17:40
Use NICE WAIT with a variable that you can adjust that will give you some control over how much power to give it under heavy loads.

I don't know if it's changed since NICE WAIT was created, but the WAIT command still uses up CPU time, while NICE WAIT (from the Matrix1Utils) gives that time back to Windows.

I do the same thing with my server and run it at 5 FPS, although the server is constantly calculating planetary orbits, and handling the dynamic weather, so I don't have it wait at all. I probably should though.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Mar 2011 18:47
Why bother trying to slow it down? Just let it run as it does and when needed, windows will let other processes have CPU time.

I've never saw the point in optimising your game loop, then forcing it to slow down?

My signature is NOT a moderator plaything! Stop changing it!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 1st Mar 2011 20:10
You would do it dynamically based on how many players you have online. If there are no players, there's no point in your CPU running flat out. (unless you're using your server as a heater)

The Wilderbeast
20
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 1st Mar 2011 20:34
I've run one of those white flexible ventilation pipes out of the exhaust on my machine and have it directed at my feet

Master Man Of Justice
18
Years of Service
User Offline
Joined: 13th Feb 2008
Location: Between Insanity and Intelligence
Posted: 2nd Mar 2011 03:54
Quote: "I've run one of those white flexible ventilation pipes out of the exhaust on my machine and have it directed at my feet"

I will go do that now. Genius! I shall run intensive programs when i get cold.

Login to post a reply

Server time is: 2026-07-16 18:25:20
Your offset time is: 2026-07-16 18:25:20