[mythtv-commits] mythtv commit: r14501 by danielk

mythtv at cvs.mythtv.org mythtv at cvs.mythtv.org
Tue Sep 18 03:30:20 UTC 2007


      Author: danielk
        Date: 2007-09-18 03:30:20 +0000 (Tue, 18 Sep 2007)
New Revision: 14501
   Changeset: http://cvs.mythtv.org/trac/changeset/14501

Modified:

   branches/mythtv-multirec/programs/mythbackend/httpstatus.cpp
   branches/mythtv-multirec/programs/mythbackend/scheduler.cpp
   branches/mythtv-multirec/programs/mythbackend/scheduler.h

Log:

Refs #3326. Small optimization for scheduling in multirec, use deque instead of linked list for the RecList.

The reason a doubly linked list was used is because it has O(1) performance for pop_front, pop_back, and erase, and O(n log n) performance for sort. However, this datastructure is a memory hog and has a fairly large constant in front of those (1)'s and (n log n)'s. By comparison a deque has O(1) for pop_front, pop_back and O(n log n) for sorts and has a very low memory footprint and runtime constant. erase is slow at O(n), but we don't actually need fast erase's, by deferring our erases we get the same O(n) total time for PruneOverlaps() and PruneRedundants() where n is the number of items in the worklist.

I still use the same stable sort (merge sort) for the deque as was used for the linked list.

In practice this is what a deque means for performance:
 * With just 30 recording rules resulting in 622 scheduled recordings there is no difference, the deque has a less than 1% advantage, which with just 5 runs for each datastructure is meaningless.
 * With 52 recording rules resulting in 1003 scheduled recording there is a 12% speedup in placement, the deque has a definte advantage.
 * With more recording rules resulting in more scheduled recordings the advantage stays a little over 10%

Because the advantage is not as pronounced as the 4+ times faster code for ProgramInfo::IsSameProgram() in [14500], I've left both implementations in there for now, you can switch by changing USE_DEQUE_RECLIST in scheduler.h from 1 to 0. This will make it easy to test different data against this change and revert if necessary.

 --This line, and those below, will be ignored--

M    programs/mythbackend/scheduler.h
M    programs/mythbackend/scheduler.cpp
M    programs/mythbackend/httpstatus.cpp





More information about the mythtv-commits mailing list