Zandronum Chat @ irc.zandronum.com
#zandronum
Get the latest version: 3.0
Source Code

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003620Zandronum[All Projects] Bugpublic2019-03-10 22:182019-03-10 22:18
Reportervoidpointer 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusnewResolutionopen 
PlatformUbuntu 18.10OSUbuntu 18.10OS Version
Product Version 
Target VersionFixed in Version 
Summary0003620: Unnecessarily high CPU usage when zandronum-server is idle
DescriptionWhen there are zero connected clients for an instance of zandronum-server, I am seeing around 8-10% CPU usage. This is not scalable. There should be as close to 0% CPU usage as possible when there are no connected clients for a server instance of Zandronum.

After looking at the Zandronum code base a bit, I see this in sv_main.cpp:

    lPreviousTics = static_cast<LONG> ( g_lGameTime / (( 1.0 / TICRATE ) * 1000.0 ) );

    lNowTime = I_MSTime( );
    lNewTics = static_cast<LONG> ( lNowTime / (( 1.0 / TICRATE ) * 1000.0 ) );

    lCurTics = lNewTics - lPreviousTics;
    while ( lCurTics <= 0 )
    {
        // [BB] Recieve packets whenever possible (not only once each tic) to allow
        // for an accurate ping measurement.
        SERVER_GetPackets( );

        I_Sleep( 1 );
        lNowTime = I_MSTime( );
        lNewTics = static_cast<LONG> ( lNowTime / (( 1.0 / TICRATE ) * 1000.0 ) );
        lCurTics = lNewTics - lPreviousTics;
    }

The delta calculations are strange and confusing, but the `I_Sleep(1)` is very inefficient for the CPU. The sleep needs to be longer so the OS can schedule other work for the CPU.

Could we make this an `I_Sleep(500)` (2 FPS) when there are 0 connected clients, and bump it back up to 35 FPS when 1 or more clients are connected?
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

Issue Community Support
Only registered users can voice their support. Click here to register, or here to log in.
Supporters: No one explicitly supports this issue yet.
Opponents: No one explicitly opposes this issue yet.

- Issue History
Date Modified Username Field Change
2019-03-10 22:18 voidpointer New Issue






Questions or other issues? Contact Us.

Links


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker