[client] app: new options to reduce CPU usage

This patch increases the default cursor and frame polling interval from
1us to 1000us which for most use cases should be more then fast enough.

It also adds two new configuration options to adjust these should it be
required:

  * app:cursorPollInterval
  * app:framePollInterval
This commit is contained in:
Geoffrey McRae 2019-05-22 12:00:06 +10:00
parent fc66a4a19c
commit 84b2917706
4 changed files with 24 additions and 6 deletions

View file

@ -1 +1 @@
a12-205-g087387087e+1 a12-206-gfc66a4a19c+1

View file

@ -86,6 +86,20 @@ static struct Option options[] =
.type = OPTION_TYPE_BOOL, .type = OPTION_TYPE_BOOL,
.value.x_bool = false, .value.x_bool = false,
}, },
{
.module = "app",
.name = "cursorPollInterval",
.description = "How often to check for a cursor update in microseconds",
.type = OPTION_TYPE_INT,
.value.x_int = 1000
},
{
.module = "app",
.name = "framePollInterval",
.description = "How often to check for a frame update in microseconds",
.type = OPTION_TYPE_INT,
.value.x_int = 1000
},
// window options // window options
{ {
@ -344,8 +358,10 @@ bool config_load(int argc, char * argv[])
} }
// setup the application params for the basic types // setup the application params for the basic types
params.shmFile = option_get_string("app", "shmFile"); params.shmFile = option_get_string("app", "shmFile" );
params.shmSize = option_get_int ("app", "shmSize") * 1048576; params.shmSize = option_get_int ("app", "shmSize" ) * 1048576;
params.cursorPollInterval = option_get_int ("app", "cursorPollInterval");
params.framePollInterval = option_get_int ("app", "framePollInterval" );
params.windowTitle = option_get_string("win", "title" ); params.windowTitle = option_get_string("win", "title" );
params.autoResize = option_get_bool ("win", "autoResize" ); params.autoResize = option_get_bool ("win", "autoResize" );

View file

@ -171,8 +171,7 @@ static int cursorThread(void * unused)
{ {
if (!state.running) if (!state.running)
return 0; return 0;
usleep(params.cursorPollInterval);
usleep(1);
continue; continue;
} }
@ -285,7 +284,7 @@ static int frameThread(void * unused)
if (!state.running) if (!state.running)
break; break;
usleep(1); usleep(params.framePollInterval);
continue; continue;
} }

View file

@ -96,6 +96,9 @@ struct AppParams
SDL_Scancode escapeKey; SDL_Scancode escapeKey;
bool showAlerts; bool showAlerts;
unsigned int cursorPollInterval;
unsigned int framePollInterval;
bool forceRenderer; bool forceRenderer;
unsigned int forceRendererIndex; unsigned int forceRendererIndex;