Skip to content

Commit

Permalink
Move QUERY_FILETRANSFER handling to improve backend performance.
Browse files Browse the repository at this point in the history
This significantly reduces the backend CPU usage for me when streaming a
recording or other file to the frontend.

Each time we send a command to the backend we perform a number of string
comparisons to find the correct handler. In the cases where that same command
is sent regularly, maybe several times a second those comparisons can stack up
to result in a high CPU load. This can be avoided by moving the most frequently
used commands to the top of the list thereby avoiding a couple of dozen or more
comparisons each time.

There may be other commands that should be moved to the top with similar
benefit.
  • Loading branch information
stuartm committed Jun 25, 2012
1 parent 7190ddc commit 529853d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mythtv/programs/mythbackend/mainserver.cpp
Expand Up @@ -434,7 +434,14 @@ void MainServer::ProcessRequestWork(MythSocket *sock)
pbs->IncrRef();
sockListLock.unlock();

if (command == "QUERY_RECORDINGS")
if (command == "QUERY_FILETRANSFER")
{
if (tokens.size() != 2)
LOG(VB_GENERAL, LOG_ERR, "Bad QUERY_FILETRANSFER");
else
HandleFileTransferQuery(listline, tokens, pbs);
}
else if (command == "QUERY_RECORDINGS")
{
if (tokens.size() != 2)
LOG(VB_GENERAL, LOG_ERR, "Bad QUERY_RECORDINGS query");
Expand Down Expand Up @@ -632,13 +639,6 @@ void MainServer::ProcessRequestWork(MythSocket *sock)
{
HandleGetRecorderNum(listline, pbs);
}
else if (command == "QUERY_FILETRANSFER")
{
if (tokens.size() != 2)
LOG(VB_GENERAL, LOG_ERR, "Bad QUERY_FILETRANSFER");
else
HandleFileTransferQuery(listline, tokens, pbs);
}
else if (command == "QUERY_GENPIXMAP2")
{
HandleGenPreviewPixmap(listline, pbs);
Expand Down

0 comments on commit 529853d

Please sign in to comment.