[RPi5] Cache Settings

  • Hello all,

    I am trying to understand how caching works in Kodi / Libreelec. I am new to Kodi, so did my homework on the Kodi wiki. But I feel there is a LOT of background info missing from that article.

    System: Libreelec 12.0.1 official, on Pi5, stock skin, no add-on apart from the ones available after a fresh install.

    I try to play very high bitrate 4K videos (constant 85+Mbit/sec) on Pi5 4GB / Pi5 2GB, and have serious and annoying buffering issues. I use Pi5 wired LAN interface, but it is running only on 100Mbit/sec, not Gigabit. The video source is on an SMB windows box.

    I checked the Kodi wiki: "caching" article.

    --> Buffering mode is set as: Buffer all filesystems, including local files

    --> Memory size: I tried changing to various hardcoded values (128MB, 256MB). Its unclear, if I need to reboot, or the change gets applied immediately?

    --> Read factor: Adaptive. But I also tried 4x, 10x as well.

    --> Cache Chunk size: I set it to 1 MB. Neither the UI help text nor the wiki article is really clear about what protocols do indeed honour that setting? How about SMB protocol? Does it benefit from the large chunk size, if I want to playback both giant 4K HEVC files and ordinary H.264 files over LAN?

    How about the chunk size setting under the other location: Services \ SMBclient? Does it affect the same behavior as the caching chunk size described in the previous pharagraph? The UI help text is very unclear whether SMB client honours chunk size setup under which settings-location?


    After all of this, I checked Kodi wiki: "Player Debug Info":

    I see the following behavior: at the start of the video playback, Aq and Vq goes slowly up to @99%, and when it reaches 99%, "forward" starts to increase from 1MB and goes up to max at 95MB. Even if I set up 256MB, it doesnt go above 95MB. The percentage shows 100% for the 95MB cache value, which doesnt really make sense to me.

    Under 3-4 minutes of continuous playback, "forward" slowly goes down under 1 MB. Then slowly the Vq goes down from 99% to 0%, and then the playback stops. Then the Aq+Vq starts increasing from 0% to 99%, and then playback starts again. But "forward" does not go up to 95MB, it stays around the same roughly 1 MB size. Then vq slowly goes down to 0%, playback stops and the cycle repeats ad infinitum.

    My goal to cache slightly more agressively on both the 4GB and the 2GB Pi5, so that these high bitrate 4K videos can be played back from start to finish without buffering stops.

  • Messing about with those cache settings would not make high bitrate 4K videos (UHD BDs?) play smoothly on 100Mbit LAN. You will have to upgrade to Gigabit.

  • Messing about with those cache settings would not make high bitrate 4K videos (UHD BDs?) play smoothly on 100Mbit LAN. You will have to upgrade to Gigabit.

    Yep, 4K UHD Blu-ray remuxes.

    In general, anything below constant 75Mbit plays nicely. The problem starts with those that are 80-85Mbit, and occasionally peaking at around 100Mbit.

  • Probably a LAN problem.

    Yes, the problem is that its not gigabit.

    But the questions in my opening post still apply aboutv how exactly does caching work in LE / Kodi, and how to maximize usable cache size up to the free RAM available?

  • But the questions in my opening post still apply aboutv how exactly does caching work in LE / Kodi, and how to maximize usable cache size up to the free RAM available?

    chewitt
    November 10, 2024 at 2:22 AM
  • I use Pi5 wired LAN interface, but it is running only on 100Mbit/sec, not Gigabit. The video source is on an SMB windows box.

    This seems to be the normal speed for that hardware. The NIC specs don't mean you really get it in real life.

    chewitt
    September 21, 2024 at 2:15 PM
  • This seems to be the normal speed for that hardware. The NIC specs don't mean you really get it in real life.

    chewitt
    September 21, 2024 at 2:15 PM

    If my practical LAN speed maxes somewhat below the theoretical 100Mbit/sec, and the constant bitrate of the 4K UHD videos actually exceeds that value, does it make sense to increase the bufferin Kodi to as large as to possible to delay the buffer underrun as further as possible? If I get buffer underrun 1 or 2 times during an hour, that results is a short 1min pause (during which time the buffer goes up again, and can sustain for yet another hour of plaxback), then I reached my goal.

    Only thing I am asking from this forum, why the system does not honor the value set under "caching". If I have plenty of RAM, I would like to utilize it to make the buffering as rare as possible.

    I hope it makes sense.

  • Quote

    This seems to be the normal speed for that hardware. The NIC specs don't mean you really get it in real life.

    No. The linked chewitt post reported:

    I see transfers around ~112MB/s from an RPi5 with nvme storage.

    112MB/s is 896Mbit/s, so very close to gigabit.


    Yes - you can get close to gigabit real world speed from a Pi5 ethernet port.

    This assumes the rest of the network devices and cables can handle gigabit.

  • Yeah, thats the speed i see on mine aswell.

  • chewitt
    November 10, 2024 at 2:22 AM

    I appreciate that you updated the title of my thread. But it will mislead other readers thinking we are discussing how to squeeze out the theoretical max from the Pi5 NIC if the negotiated speed is 100Mbit/s full-duplex.

    When in fact I desperately ask you guys to give some hints about how the caching in Kodi/LE works?

  • Kodi allows you to fiddle with the type of input stream that uses buffering (it differentiates between online and several different types of local sources), the size of the buffer, the buffer fill-rate, and (separately) the SMB/NFS read-chunk size. Note that since K21 the buffer settings have all moved into the GUI so config in advancedsettings.xml will be correctly ignored.

    Users generally (and wrongly) believe that "bigger buffer is better" but when you have insufficient bandwidth the buffer always drains to zero and then you stall playback until the buffer is full again and can resume. Having a larger buffer or a slow fill rate means you will wait for longer before playback resumes. Fast fill rates also imply the availability of faster/higher bandwidth. In practically all scenarios, smaller buffers and moderate fill rates (small changes on defaults, not radical ones) give best results.

    NB: Cache tweaking is never a cure for "insufficient bandwidth" and you will probably spend more man-hours of effort trying to find a combination of settings that is best (or least-worst) than it will take to fix the real problem: the NIC is negotiating 100-BaseT not 1000-BaseT. Check the router, switches, cables, ports, etc.