[mythtv-users] Takes long time to enter "Watch Recordings" menu

Tony Lill ajlill at ajlc.waterloo.on.ca
Wed Feb 28 23:57:43 UTC 2007


erland <erland_i at hotmail.com> writes:

> Suddenly it has started to take a lot of time to enter the "Watch Recordings"
> menu in MythTV, earlier it has been a bit slow and taken maybe 5 seconds but
> now it has started to take about 30 seconds instead.
>
> The problem is reproducable both on the frontend running on the same machine
> as the backend but also on a separate frontend running on a laptop. The CPU
> usage during the 30 seconds seems to be less than 20% on both the
> frontend+backend machine and the separate frontend on the laptop, so I don't
> think it is a CPU problem. Sometimes on the laptop I have even gotten a
> message saying that the connection with the backend has been lost.
>
> Most of the other menus works as fast as before, and it is also fast to step
> around inside the "Watch Recordings" menu while you have successfully
> entered it.
>
> The only difference I can see is that the number of saved recordings is a
> bit more, there are about 370 saved recordings at the moment.
>
> Has someone else seen the same problem and knows if there is a workaround ?

Just wait till you get up around a thousand!

The problem is that the frontend downloads program info for every
recording you have, not just the ones it is displaying at the
moment. This means multiple megabytes of data in your case. If you
collect up a few more recordings, it will also start causeing things
to timeout. Another possible issue is that it also checks if each
file exists, so if you have disks spun down of are using an
automounter, that adds a bunch more delay.

There is no workaround besides deleting recordings.

They are re-designing communications for 0.21 so it caches all of this
crap, and only updates what it needs. Whether or not it solves all the
problems remains to be seen.

I do have a patch...

Index: libs/libmythtv/remoteutil.h
===================================================================
--- libs/libmythtv/remoteutil.h	(revision 12753)
+++ libs/libmythtv/remoteutil.h	(working copy)
@@ -19,7 +19,7 @@
     long long usedSpaceKB;
 };
 
-vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype);
+vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype, QString where);
 vector<FileSystemInfo> RemoteGetFreeSpace();
 bool RemoteGetLoad(float load[3]);
 bool RemoteGetUptime(time_t &uptime);
Index: libs/libmythtv/tv_play.cpp
===================================================================
--- libs/libmythtv/tv_play.cpp	(revision 12753)
+++ libs/libmythtv/tv_play.cpp	(working copy)
@@ -6144,8 +6144,9 @@
     // Build jumpMenu of recorded program titles
     ProgramInfo *p;
     progLists.clear();
+    QString whereClause = " and recorded.recgroup = \"" + playbackinfo->recgroup + "\"";
     vector<ProgramInfo *> *infoList;
-    infoList = RemoteGetRecordedList(false);
+    infoList = RemoteGetRecordedList(false, whereClause);
 
     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
 
Index: libs/libmythtv/remoteutil.cpp
===================================================================
--- libs/libmythtv/remoteutil.cpp	(revision 12753)
+++ libs/libmythtv/remoteutil.cpp	(working copy)
@@ -6,13 +6,14 @@
 #include "mythcontext.h"
 #include "remoteencoder.h"
 
-vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype)
+vector<ProgramInfo *> *RemoteGetRecordedList(bool deltype, QString whereClause)
 {
     QString str = "QUERY_RECORDINGS ";
     if (deltype)
         str += "Delete";
     else
         str += "Play";
+    str += whereClause;
 
     QStringList strlist = str;
 
Index: programs/mythfrontend/playbackbox.cpp
===================================================================
--- programs/mythfrontend/playbackbox.cpp	(revision 12753)
+++ programs/mythfrontend/playbackbox.cpp	(working copy)
@@ -1462,8 +1462,15 @@
 
     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
 
+    QString whereClause = "";
+    if( recGroup != "All Programs" ) {
+      if(recGroupType[recGroup] == "category")
+	whereClause = " and recorded.category = \"" + recGroup + "\"";
+      else
+	whereClause = " and recorded.recgroup = \"" + recGroup + "\"";
+    }	
     vector<ProgramInfo *> *infoList;
-    infoList = RemoteGetRecordedList(listOrder == 0 || type == Delete);
+    infoList = RemoteGetRecordedList(listOrder == 0 || type == Delete, whereClause);
     if (infoList)
     {
         sortedList[""] = "";
Index: programs/mythbackend/mainserver.cpp
===================================================================
--- programs/mythbackend/mainserver.cpp	(revision 12753)
+++ programs/mythbackend/mainserver.cpp	(working copy)
@@ -351,10 +351,10 @@
 
     if (command == "QUERY_RECORDINGS")
     {
-        if (tokens.size() != 2)
+        if (tokens.size() < 2)
             VERBOSE(VB_IMPORTANT, "Bad QUERY_RECORDINGS query");
         else
-            HandleQueryRecordings(tokens[1], pbs);
+            HandleQueryRecordings(tokens, pbs);
     }
     else if (command == "QUERY_FREE_SPACE")
     {
@@ -996,11 +996,13 @@
     }
 }
 
-void MainServer::HandleQueryRecordings(QString type, PlaybackSock *pbs)
+void MainServer::HandleQueryRecordings(QStringList &tokens, PlaybackSock *pbs)
 {
+  QString type = tokens[1];
     MythSocket *pbssock = pbs->getSocket();
     bool islocal = pbs->isLocal();
     QString playbackhost = pbs->getHostname();
+    int i;
 
     QString fs_db_name = "";
 
@@ -1067,8 +1069,11 @@
         "  recorded.starttime = recordedprogram.starttime ) "
         "WHERE ( recorded.deletepending = 0 OR "
         "        DATE_ADD(recorded.lastmodified, INTERVAL 5 MINUTE) <= NOW() "
-        "      ) "
-        "ORDER BY recorded.starttime";
+      "      )";
+    for( i = 2; i < tokens.size(); i++ ) {
+      thequery += " "+tokens[i];
+    }
+        thequery += " ORDER BY recorded.starttime";
 
     if (type == "Delete")
         thequery += " DESC";
@@ -1208,14 +1213,14 @@
 
             QString lpath = fileprefix + "/" + basename;
             PlaybackSock *slave = NULL;
-            QFile checkFile(lpath);
+            //QFile checkFile(lpath);
 
             if (proginfo->hostname != gContext->GetHostName())
                 slave = getSlaveByHostname(proginfo->hostname);
 
-            if ((masterBackendOverride && checkFile.exists()) || 
+            if ((masterBackendOverride /*&& checkFile.exists()*/) || 
                 (proginfo->hostname == gContext->GetHostName()) ||
-                (!slave && checkFile.exists()))
+                (!slave /*&& checkFile.exists()*/))
             {
                 if (islocal)
                     proginfo->pathname = lpath;
Index: programs/mythbackend/mainserver.h
===================================================================
--- programs/mythbackend/mainserver.h	(revision 12753)
+++ programs/mythbackend/mainserver.h	(working copy)
@@ -72,7 +72,7 @@
     void HandleDone(MythSocket *socket);
 
     void HandleIsActiveBackendQuery(QStringList &slist, PlaybackSock *pbs);
-    void HandleQueryRecordings(QString type, PlaybackSock *pbs);
+    void HandleQueryRecordings(QStringList &tokens, PlaybackSock *pbs);
     void HandleStopRecording(QStringList &slist, PlaybackSock *pbs);
     void DoHandleStopRecording(ProgramInfo *pginfo, PlaybackSock *pbs);
     void HandleDeleteRecording(QStringList &slist, PlaybackSock *pbs,


More information about the mythtv-users mailing list