[mythtv] hdtvrecorder: dynamic ringbuffers?

John Patrick Poet john at BlueSkyTours.com
Wed Dec 22 16:00:31 UTC 2004


Daniel Thor Kristjansson wrote:

>On Wed, 22 Dec 2004, Doug Larrick wrote:
>]John Patrick Poet wrote:
>]> I have written a version of the hdtvrecorder ringbuffer code which creates a
>]> variable number of ringbuffers, per recording.
>]> Each ringbuffer is 20mb in size.  If a ringbuffer fills up, another
>]IMHO, and not having tried it, the new system sounds like a winner.  The only
>]big problem I see is if the system goes into swap, it would spiral out of
>]control needing more and more buffers as it struggles to keep up.  Perhaps
>]detecting the amount of physical RAM in the system and limiting to (say) half
>]of it (total) for ringbuffers would be the way to go.
>  
>

Yup.  And I have seen it happen.  The kernel eventually kills mythbackend.

Do you know how to detect the amount of physical RAM in the system?

>Again, not having tried it, I like this system better. The more I think 
>about it the more I think you can't avoid the possible swap problem with 
>page locking as I suggested before. Other important parts of the program 
>would get swapped out instead, and it requires privledge elevation (yuck!). 
>But by decreasing memory usage this patch will probably avoid the 
>problem altogether with reasonable memory and hard drive requirements.
>
>Perhaps growing buffer allocations make sense? Say 5mb, then 10mb, 
>and finally capped at 20mb? Then if a 5mb buffer is sufficient you only 
>use 5mb for the buffer, if 10mb is sufficient the 5mb buffer 
>eventually gets freed and you continue to use just 10mb. Capping at 20mb 
>avoids wasting 49% of a 80mb or 160mb buffer.
>
>-- Daniel
>  
>

Interesting idea.  Easy to implement, so I will.

I admit I have not done much testing with only one show recording, and 
am not sure how small a ringbuffer is sufficient for that scenario.  The 
more shows being recorded/watched, the larger the ringbuffers have to be.

I just got an early Christmas present in the form of a Seagate 400GB 
drive.  I have been wanting to completely reorganize my disks anyway, so 
my machine will probably be out of action for a few days.  I will try to 
get an initial version of this patch posted before I tear into the 
hardware, in case any of you want to play with it.

Thanks for the input,

John



More information about the mythtv-dev mailing list