-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement shared buffer for multiple clients per stream ID #220
Conversation
@kpirnie Sorry to bother you but do you mind trying this out? This is a completely different implementation of the existing (and dead simple) buffer but allows multiple clients to share one stream connection. I was wondering if this idea scales fine with the amount of providers you have. Theoretically, the memory usage of this implementation should be proportional by the number of active connections to the IPTV providers and not the number of client connections necessarily. |
The Docker image for this pull request has been built and pushed to GHCR. Image URL: |
am having major buffering with this pr. idk if it something related to my set up or what |
Hi @aniel300. I can't help you without any debug logs. Please create a new issue with more context. Also, there are important notes in the release changelog. |
Context
Choices
BUFFER_MB
in favor ofBUFFER_CHUNK_NUM
which now refers to the number of chunks stored in the shared buffer with the defaults set to 4. Each chunk will be fixed to1 MB
.How it works
The stream buffer system is essentially an implementation of a Circular Buffer data structure.
Imagine a circular sushi conveyor belt (
ring.Ring
) with a fixed number of plates (BUFFER_CHUNK_NUM
). Each plate (ChunkData
) can hold a piece of sushi (chunk of data).The Chef (Writer)
At the preparation station, there's a chef (
StartWriter
) who:ChunkSize
)ChunkData
)The chef works continuously unless:
The Customers (Readers)
Customers (
ReadChunks
) sitting at different points around the belt:fromPosition
)dataNotify.Wait()
)If a customer is too slow and takes too long to check a plate, the data might get replaced by the time they look again (buffer overwrite)
This system ensures that streaming data (sushi) flows smoothly from the source (kitchen) to multiple consumers (customers) while efficiently managing memory (plates) and handling errors (food safety warnings).
Checklist before requesting a review