Mailing List Archive

rPi3 ram consumption causing playback freezing
i've had my rpi3 for a few weeks now and on the whole, it's been next to perfect.

recently, i've found that playback can sometimes be extremely laggy so i initially went with a nightly reboot to freshen everything up. this sorted things getting out of hand over a few days.
however i think i've now found that if i play something in the morning/over lunch, then come dinner time the playback will be laggy.

'htop' is showing ~85% general usage, ~1% buffer, and the remaining ~14% as buffer cache.... which brings total ram consumption to completely maxed out @ 100%.

clearing the pagecache sorted the problem out with the following command without a reboot being required:
sync; echo 1 > /proc/sys/vm/drop_caches


the rpi config i use is as follows:
rasbian latest & fully updated, mythtv-light used as per wiki.
gpu_mem=192 (so 796MB remaining for the system)
vm.swappiness=10
MythFE theme: MythCenter-wide
rpi3 gets left on 24/7 and playback is stopped when not using it (going back to either recorded tv/main menu)

what'd be the best way to sort this problem out? is there something i can tweak to properly stop it happening in the first place, or will running cron with the drop_caches cmd be the way forward?

thanks..

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: rPi3 ram consumption causing playback freezing [ In reply to ]
Tim Draper <veehexx@zoho.com> wrote:

> 'htop' is showing ~85% general usage, ~1% buffer, and the remaining ~14% as buffer cache.... which brings total ram consumption to completely maxed out @ 100%.

Ah, no it isn't "maxed out" ! You have 14% "available".
The idea of the buffer cache is that any memory not otherwise used will be used to hold pages waiting to be written to disk (should be very little in this application, shown as "Dirty" in /proc/mem) and pages recently read from disk. If anything requests more memory, then pages are dropped from the read cache to free up pages to satisfy the request - and this should be a very low latency operation.

Memory that isn't in use or used for buffer cache is wasted memory.

> clearing the pagecache sorted the problem out with the following command without a reboot being required:
> sync; echo 1 > /proc/sys/vm/drop_caches

That suggests that the full buffers aren't necessarily the problem, more likely a symptom of the real problem.
FWIW, on my Mac (still on OS X 10.8) I have a similar problem. IN THEORY, cache should be dropped when the memory is wanted for something else. In practice, I find memory management is going wrong somewhere and the system will swap stuff to disk to make space, in preference to dropping cache space - I think it has faulty logic in determining when "inactive"* memory should be re-assigned. The result is exactly as you describe - the system gets slow and laggy due to the swapping until I drop the caches.

It would be interesting to try and see what is being used for what - but TBH that's beyond my technical skills here.

* On OS X, "inactive" is a class of memory that's been recently used, but is currently free. I believe it includes both read-cache and memory previously allocated to an application.

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: rPi3 ram consumption causing playback freezing [ In reply to ]
On 15/07/17 18:15, Tim Draper wrote:
> i've had my rpi3 for a few weeks now and on the whole, it's been next to perfect.
>
> recently, i've found that playback can sometimes be extremely laggy so i initially went with a nightly reboot to freshen everything up. this sorted things getting out of hand over a few days.
> however i think i've now found that if i play something in the morning/over lunch, then come dinner time the playback will be laggy.
>
> 'htop' is showing ~85% general usage, ~1% buffer, and the remaining ~14% as buffer cache.... which brings total ram consumption to completely maxed out @ 100%.
>
> clearing the pagecache sorted the problem out with the following command without a reboot being required:
> sync; echo 1 > /proc/sys/vm/drop_caches
>
>
> the rpi config i use is as follows:
> rasbian latest & fully updated, mythtv-light used as per wiki.
> gpu_mem=192 (so 796MB remaining for the system)
> vm.swappiness=10
> MythFE theme: MythCenter-wide
> rpi3 gets left on 24/7 and playback is stopped when not using it (going back to either recorded tv/main menu)
>
> what'd be the best way to sort this problem out? is there something i can tweak to properly stop it happening in the first place, or will running cron with the drop_caches cmd be the way forward?

I've got an rPi3 I leave on 24/7, gets used 2 or 3 times a day at least
and doesn't experience any memory issues and seems pretty flawless as
long as you playback what's expected to work. 256MB for gpu though.

Does nothing much apart from running mythtv and squeezelite and
currently free says:
$ free -h
total used free shared buffers cached
Mem: 733M 687M 45M 38M 49M 228M
-/+ buffers/cache: 409M 323M
Swap: 99M 8.3M 91M

I haven't much fiddled with the default mythtv setup apart from using
Steppes theme and the mythtv-light package. I last updated about 2
weeks ago (when the interlacing issues were fixed). I can see a kernel
update waiting though... I'm currently on:

Linux pi-3 4.9.28-v7+ #998 SMP Mon May 15 16:55:39 BST 2017 armv7l GNU/Linux

Maybe there's a bug in the new kernel update if yours is a newer
version? Either way I won't be updating soon! I guess doing the drop
cache regularly with cron would work around it until it gets fixed; or
try downgrading the kernel. Or maybe turn off swapping completely and
see if that makes a difference.

Sorry not much help.

Stefan








_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: rPi3 ram consumption causing playback freezing [ In reply to ]
On 15/07/17 18:15, Tim Draper wrote:
> i've had my rpi3 for a few weeks now and on the whole, it's been next to perfect.
>
> recently, i've found that playback can sometimes be extremely laggy so i initially went with a nightly reboot to freshen everything up. this sorted things getting out of hand over a few days.
> however i think i've now found that if i play something in the morning/over lunch, then come dinner time the playback will be laggy.
>
> 'htop' is showing ~85% general usage, ~1% buffer, and the remaining ~14% as buffer cache.... which brings total ram consumption to completely maxed out @ 100%.
>
> clearing the pagecache sorted the problem out with the following command without a reboot being required:
> sync; echo 1 > /proc/sys/vm/drop_caches
>
>
> the rpi config i use is as follows:
> rasbian latest & fully updated, mythtv-light used as per wiki.
> gpu_mem=192 (so 796MB remaining for the system)
> vm.swappiness=10
> MythFE theme: MythCenter-wide
> rpi3 gets left on 24/7 and playback is stopped when not using it (going back to either recorded tv/main menu)
>
> what'd be the best way to sort this problem out? is there something i can tweak to properly stop it happening in the first place, or will running cron with the drop_caches cmd be the way forward?
>
> thanks..
>
My rpi3 is running current kernel on Raspbian Jessie Linux raspberrypi3
4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

With Firmware: Jul 3 2017 14:16:43, version
4139c62f14cafdb7d918a3eaa0dbd68cf434e0d8

mythfrontend version from mythtv-light is MythTV Version :
v29-pre-512-g42d4a31, I am also using Steppes theme (2.29)

Note gpu_mem minimum is really 256.

There is a utility bcmstat.sh which gives lots on information on memory
and gpu usage, htop and free only give part of the story.

Just get it from https://github.com/MilhouseVH/bcmstat

put in your home folder (make sure it is executable) and run it
./bcmstat.sh gx (the README.md in the github repo gives instructions)

It is probably easier if you can run bcmstat.sh from another PC over
SSH, on my rpi3 I have to stop LiveTV to switch tabs to see the output
in a terminal session.

In particular the columns GPUMem Free and Memory Free/Used are of
interest.

bcmstat.sh shows an amber colour (warning) for GPUMem Free when I am
watching LIveTV HD channels (H264) with gpu_mem=192, it is green with
gpu_mem=256

Mike

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: rPi3 ram consumption causing playback freezing [ In reply to ]
On 07/15/2017 01:15 PM, Tim Draper wrote:
> i've had my rpi3 for a few weeks now and on the whole, it's been next to perfect.
>
> recently, i've found that playback can sometimes be extremely laggy so i initially went with a nightly reboot to freshen everything up. this sorted things getting out of hand over a few days.
> however i think i've now found that if i play something in the morning/over lunch, then come dinner time the playback will be laggy.
>
> 'htop' is showing ~85% general usage, ~1% buffer, and the remaining ~14% as buffer cache.... which brings total ram consumption to completely maxed out @ 100%.
>
> clearing the pagecache sorted the problem out with the following command without a reboot being required:
> sync; echo 1 > /proc/sys/vm/drop_caches
>
>
> the rpi config i use is as follows:
> rasbian latest & fully updated, mythtv-light used as per wiki.
> gpu_mem=192 (so 796MB remaining for the system)
> vm.swappiness=10
> MythFE theme: MythCenter-wide
> rpi3 gets left on 24/7 and playback is stopped when not using it (going back to either recorded tv/main menu)
>
> what'd be the best way to sort this problem out? is there something i can tweak to properly stop it happening in the first place, or will running cron with the drop_caches cmd be the way forward?
>
> thanks..
>
> _______________________________________________
>
Did you look at the recommendations in the wiki
https://www.mythtv.org/wiki/Raspberry_Pi#System_Performance
In particular, item 1, setting the raspberry pi into performance mode,
has to be run after each reboot, or before starting the frontend.
Otherwise, the raspberry pi goes into a "power saving" mode where it
slows down the CPU and causes the type of issue you describe.

Peter
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: rPi3 ram consumption causing playback freezing [ In reply to ]
On 16/07/17 22:12, Peter Bennett wrote:
> In particular, item 1, setting the raspberry pi into performance mode,
> has to be run after each reboot, or before starting the frontend.
> Otherwise, the raspberry pi goes into a "power saving" mode where it
> slows down the CPU and causes the type of issue you describe.

Ah! This probably explains why when my family watches sport in HD, the
Pi freezes after an hour or so, but after a reboot everything is fine again.

Thanks for the tip

Regards

Jeff