RingBuffer locking problem

Description

There is a RingBuffer? locking related issue that causes long delays in loading ISO videos with several titles using storage groups. (This is the same as issue 2 in #9854.)

See the attached frontend log using "-v important,general,playback,file,extra". This is for playback of an ISO with 9 titles, played on an ION frontend, single core, hyperthreading, gigabit network connection to the backend. There are frequent sections of the log that look like this:

Adding extra instrumentation indicates that the thread running ReadPriv?() is delayed for 1 second in the WaitForReadsAllowed?() call in the generalWait.wait() statement, while the readahead thread is idle. It appears that readsallowed is changing from false to true without a notification, resulting in the full 1000ms wait. Not sure if the lack of notification is by design.

A workaround is to change the 1000ms timeout in WaitForReadsAllowed?() to something small like 25ms, resulting in big improvements in startup time. In this example, the original startup time is 4s to the bookmark dialog followed by 65s to playback, but with the 25ms timeout the startup time is 1s to the bookmark dialog followed by 14s to playback.

Fixes #9864. Make sure we wake up any sleepers the when we change from the !readsallowed to the readsallowed state.

This usually happens implicitly simply due to the differences in the size of various buffers and read sizes. But that is a bit fragile and complicates tuning buffer sizes for better overall performance.

If you are experiencing the same timeout problem Jim Stichnoth has been experiencing, this should noticably improve your myth:// streaming performance.

Add Comment

This ticket has been modified since you started editing. You should review the
other modifications which have been appended above,
and any conflicts shown in the preview below.
You can nevertheless proceed and submit your changes if you wish so.