• Do not use Works in Progress as a way of avoiding the releases system! Works in Progress can be used for sharing early betas and for getting suggestions for improvement. Releases of finished content are not allowed in this forum! If you would like to submit a finished addon, click here for instructions on how to do so.

CPU Usage (new executable available)

Status
Not open for further replies.

Oogaland

Member
As requested, I've released a modded 1.08 to tide us over until 1.09 gets out (see below). Get it here.

This is directed mostly towards the developers, but it might be of more general interest if it works out.

In my idleness today, I thought back to a time when a441 used to run a dedicated server for competition judging, but would have to take it down when he 'needed his CPU'. This struck me as slightly incongruous, since I can run DooM on my 486. I wondered whether there wasn't an opportunity in the main loop somewhere to yield some CPU time. So I looked at the code.

Somebody, it seems, had beaten me to it. This is from D_main.c:

Code:
#ifdef SAVECPU_EXPERIMENTAL
	if(realtics == 0)
	{
	    usleep(10000);

	    continue;
	}
#endif

However, it's flagged as 'experimental', and is disabled in the current build. Anyone know why? I re-enabled it and didn't notice any problems, as I'll detail in a moment. Anyway, I defined the appropriate preprocessor symbol, updated things slightly for Win32, and recompiled.

Code:
#ifdef SAVECPU_EXPERIMENTAL
	if(realtics == 0)
	{
#ifndef __WIN32__
	    usleep(10000);
#else
	    Sleep(10);
#endif
	    continue;
	}
#endif

Things went swimmingly. Processor usage was down from a constant 100% before to 50% in small rooms and 80%-100% in the larger ones. Useful, but still not great for multitasking. I then ran SRB2 again, this time in dedicated server mode, i.e. without the renderer, and also with -nomusic and -nosound. CPU usage 4%! The slight caveat is that I haven't tested it with anyone actually connected to the server yet, so i don't know if (a) there are problems with the 'experimental' code in netgames; or if (b) CPU usage will shoot back up when someone connects. I'll try it over my LAN when I can.

The upshot, for latecomers in the audience, is that someone who doesn't mind their bandwidth being used up (and I don't know how bad SRB2 is for that) could run a dedicated server as a background process without having their processor monopolised.

If all this has already been considered for 1.09/1.1, I apologise for wasting everyone's time. :oops:

Edit: In my habitual scatterbrainèdness, I forgot to emphasise the main point of this post: Has anyone tried enabling this before, and if so, what were the results?
 
It's still a temporary fix for those who can't wait that long, though.

Of course, we'd probably need to spread this EXE around, considering it could cause all kinds of errors to interchange between the two.
 
OK, I'll release it shortly. My brother's just finished on his computer, so I can test it for compatibility now. I'll adjust version numbers if necessary. Expect an edit to this post in a couple of minutes.

Edit: Couple of minutes, half an hour; same difference. Grab the updated executable from this page here. It appears to be compatible with 1.42.20, but I changed the version to 1.42.21 anyway, since downloading it isn't much of a chore and I wasn't entirely confident that CFs wouldn't rear their ugly heads when I wasn't looking.

/me goes to write a script for dedicated servers...
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top