core: start-blueos-core: Add runtime tuning for improved stream performance#3816
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a tune_performance() routine to the blueos-core startup script that applies sysctl-based runtime tuning on each container start to improve UDP streaming performance, constrain real-time scheduling, and reduce swap usage. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider making the sysctl tuning values configurable (e.g., via env vars or a small config file) so they can be adjusted per deployment without modifying the script.
- Ensure tune_performance() handles failures gracefully when a sysctl key is unavailable or when the container lacks permission to set it, and that such failures don't prevent the rest of the startup sequence.
- It may be helpful to group the tuning parameters as named constants or a data structure inside the script so that future adjustments to these values have a single, obvious place to change.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider making the sysctl tuning values configurable (e.g., via env vars or a small config file) so they can be adjusted per deployment without modifying the script.
- Ensure tune_performance() handles failures gracefully when a sysctl key is unavailable or when the container lacks permission to set it, and that such failures don't prevent the rest of the startup sequence.
- It may be helpful to group the tuning parameters as named constants or a data structure inside the script so that future adjustments to these values have a single, obvious place to change.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Free Tier Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
970524c to
80d48fc
Compare
80d48fc to
5483643
Compare
Summary
Adds a
tune_performance()function tocore/start-blueos-corethat applies runtime sysctl tuning on every container start. These changes were essential for improved WebRTC performance and stream stability.Changes
UDP buffer sizes (
wmem_max,rmem_max,wmem_default,rmem_default,netdev_max_backlog)From testing, the minimum UDP buffer size for stable streaming was actually 2.5 MB, but we set it to 16 MB instead to be future-proof (4K 60fps, 100 Mbps, etc). We can lower this if reviewers think it is too much.
Note that this potentially increases the RAM used by all services that use UDP, not just the streaming pipeline, since these are system-wide sysctl settings.
Swappiness (
vm.swappiness = 10)This did not come from test data. It was chosen as a better configuration than the current default (60), since the team had already mentioned during a meeting that it would be good to reduce swap use. On SD cards, swap I/O is extremely slow and creates latency spikes, so preferring file cache reclamation over swapping should improve overall responsiveness.
Real-time scheduler limits (
sched_rt_runtime_us = 950000)This is a safe rationale, not derived from test data. MCM uses many real-time (SCHED_RR/SCHED_FIFO) threads for streaming, and we do not want to let them starve the rest of the system. The setting reserves 5% of each CPU core's time (50 ms per second) for non-RT threads, preventing a scenario where aggressive RT scheduling locks out essential system processes.
Summary by Sourcery
Introduce runtime system tuning in start-blueos-core to improve streaming performance and system responsiveness by adjusting kernel networking and scheduling parameters on container startup.
Enhancements: