Files
songbird/images/driver.svg
Kyle Simpson 3daf11f5d1 Driver: Implement audio scheduler (#179)
This PR implements a custom scheduler for audio threads, which reduces thread use and (often) memory consumption.

To save threads and memory (e.g., packet buffer allocations), Songbird parks Mixer tasks which do not have any live Tracks.
These are now all co-located on a single async 'Idle' task.
This task is responsible for managing UDP keepalive messages for each task, maintaining event state, and executing any Mixer task messages.
Whenever any message arrives which adds a `Track`, the mixer task is moved to a live thread.
The Idle task inspects task counts and execution time on each thread, choosing the first live thread with room, and creating a new one if needed.

Each live thread is responsible for running as many live mixers as it can in a single tick every 20ms: this currently defaults to 16 mixers per thread, but is user-configurable.
A live thread also stores RTP packet blocks to be written into by each sub-task.
Each live thread has a conservative limit of 18ms that it will aim to stay under: if all work takes longer than this, it will offload the task with the highest mixing cost once per tick onto another (possibly new) live worker thread.
2023-11-20 00:02:57 +00:00

117 lines
9.3 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1525 1096" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
<g transform="matrix(1,0,0,1,-31,-921)">
<g transform="matrix(1,0,0,1,0,900)">
<g transform="matrix(1,0,0,1,299,-52.947)">
<path d="M212.72,146.182L212.72,132.063L521.426,132.063L521.426,103.825L540.487,139.123L521.426,174.421L521.426,146.182L212.72,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
<g transform="matrix(1,0,0,1,-168.926,12.6064)">
<text x="235.411px" y="98.782px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:84.043px;">M<tspan x="301.889px " y="98.782px ">e</tspan>ssag<tspan x="515.19px " y="98.782px ">e</tspan>s</text>
</g>
</g>
<g transform="matrix(1,0,0,1,0,995)">
<g transform="matrix(1,0,0,1,299,-52.947)">
<path d="M212.72,146.182L212.72,132.063L521.426,132.063L521.426,103.825L540.487,139.123L521.426,174.421L521.426,146.182L212.72,146.182Z" style="fill:rgb(255,77,74);"/>
</g>
<g transform="matrix(1,0,0,1,-168.926,12.6064)">
<text x="235.411px" y="98.782px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:84.043px;">Cr<tspan x="314.076px " y="98.782px ">e</tspan>at<tspan x="435.517px " y="98.782px ">e</tspan>s</text>
</g>
</g>
<g transform="matrix(1,0,0,1,0,-15)">
<g transform="matrix(1,0,0,1,-168.926,1110.98)">
<text x="235.411px" y="98.782px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:84.043px;">P<tspan x="282.559px " y="98.782px ">e</tspan>rmanent</text>
</g>
<g transform="matrix(1.75342,0,0,0.430769,335.83,655.838)">
<rect x="101.876" y="1143.29" width="184.054" height="163.884" style="fill:rgb(255,193,74);stroke:rgb(62,62,62);stroke-width:3.05px;"/>
</g>
</g>
<g transform="matrix(1,0,0,1,-1507.73,1026.16)">
<path d="M1841.87,401.515C1861.04,401.559 1876.53,417.076 1876.53,436.182L1876.53,505.518C1876.53,524.651 1861,540.185 1841.87,540.185L1632.2,540.185L1632.2,401.515L1841.87,401.515Z" style="fill:rgb(255,73,27);stroke:rgb(255,5,5);stroke-width:4.07px;"/>
</g>
<g transform="matrix(1,0,0,1,-326.049,1208.17)">
<text x="503.152px" y="302.395px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;fill:white;">Driv<tspan x="592.852px " y="302.395px ">e</tspan>r</text>
</g>
<g transform="matrix(1,0,0,1,-257.171,22.6916)">
<g transform="matrix(0.724138,0,0,0.724138,223.721,413.46)">
<ellipse cx="829.267" cy="1498.79" rx="134.889" ry="73.117" style="fill:rgb(255,193,74);stroke:rgb(62,62,62);stroke-width:5.38px;"/>
</g>
<g transform="matrix(1,0,0,1,10.0851,37.8193)">
<text x="762.453px" y="1473.58px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;">C<tspan x="789.953px 819.153px 837.953px " y="1473.58px 1473.58px 1473.58px ">ore</tspan></text>
</g>
</g>
<g transform="matrix(1,0,0,1,-380.468,23.7117)">
<g transform="matrix(1.75342,0,0,1.61288,854.748,-134.087)">
<rect x="101.876" y="1143.29" width="184.054" height="163.884" style="fill:rgb(255,193,74);stroke:rgb(62,62,62);stroke-width:2.31px;"/>
</g>
<g transform="matrix(1,0,0,1,931.504,756.618)">
<text x="149.289px" y="1193.29px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;">Schedul<tspan x="330.389px " y="1193.29px ">e</tspan>r</text>
</g>
<g transform="matrix(1,0,0,1,-15.1891,-18.5496)">
<g transform="matrix(0.821616,0,0,0.821616,525.276,598.978)">
<ellipse cx="829.267" cy="1498.79" rx="134.889" ry="73.117" style="fill:white;stroke:rgb(62,62,62);stroke-width:4.74px;stroke-dasharray:23.7,23.7,0,0;"/>
</g>
<g transform="matrix(1,0,0,1,427.729,-183.18)">
<path d="M858.852,1972.01C877.965,1982.81 889.714,1997.46 889.714,2013.59C889.714,2046.75 840.054,2073.66 778.887,2073.66C746.089,2073.66 716.6,2065.92 696.296,2053.63L858.852,1972.01Z" style="fill:rgb(255,221,157);"/>
</g>
<g transform="matrix(0.821616,0,0,0.821616,525.276,598.978)">
<ellipse cx="829.267" cy="1498.79" rx="134.889" ry="73.117" style="fill:none;stroke:rgb(62,62,62);stroke-width:4.74px;stroke-dasharray:23.7,23.7,0,0;"/>
</g>
<g transform="matrix(0.806811,0,0,0.806811,542.204,653.353)">
<text x="762.453px" y="1473.58px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;">Mix<tspan x="839.603px " y="1473.58px ">e</tspan>r</text>
</g>
</g>
</g>
<g transform="matrix(1,0,0,1,-47.9044,-158.841)">
<g transform="matrix(0.724138,0,0,0.724138,223.721,413.46)">
<ellipse cx="829.267" cy="1498.79" rx="134.889" ry="73.117" style="fill:rgb(255,193,74);stroke:rgb(62,62,62);stroke-width:5.38px;"/>
</g>
<g transform="matrix(1,0,0,1,-12.6064,37.8193)">
<text x="762.453px" y="1473.58px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;">Ev<tspan x="813.303px " y="1473.58px ">e</tspan>nts</text>
</g>
</g>
<g transform="matrix(0.234011,0.0406263,-0.10801,0.622149,635.72,1439.47)">
<path d="M212.72,146.182L212.72,132.063L489.811,132.063L489.811,103.825L540.487,139.123L489.811,174.421L489.811,146.182L212.72,146.182Z" style="fill:rgb(255,77,74);"/>
</g>
<g transform="matrix(0.942841,-0.272086,0.175081,0.606697,445.215,1481.7)">
<path d="M212.72,146.182L212.72,132.063L528.222,132.063L528.222,103.825L540.487,139.123L528.222,174.421L528.222,146.182L212.72,146.182Z" style="fill:rgb(255,77,74);"/>
</g>
<g transform="matrix(1,0,0,1,57.9896,47.9044)">
<g transform="matrix(1.01835,0,0,1.01835,-11.9813,-27.0542)">
<ellipse cx="829.267" cy="1498.79" rx="134.889" ry="73.117" style="fill:white;stroke:rgb(62,62,62);stroke-width:3.82px;"/>
</g>
<g transform="matrix(1,0,0,1,9,40.3406)">
<text x="702.378px" y="1473.58px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;">W<tspan x="742.178px " y="1473.58px ">e</tspan>bsock<tspan x="900.928px " y="1473.58px ">e</tspan>t</text>
</g>
</g>
<g transform="matrix(1,0,0,1,284.905,-123.543)">
<g transform="matrix(1.01835,0,0,1.01835,-11.9813,-27.0542)">
<ellipse cx="829.267" cy="1498.79" rx="134.889" ry="73.117" style="fill:white;stroke:rgb(62,62,62);stroke-width:3.82px;"/>
</g>
<g transform="matrix(1,0,0,1,9,40.3406)">
<text x="743.378px" y="1473.58px" style="font-family:'FiraSans-Regular', 'Fira Sans', sans-serif;font-size:50px;">UDP Rx</text>
</g>
</g>
<g>
<g transform="matrix(0.106551,-0.446033,0.614174,0.146717,753.629,1845.98)">
<path d="M212.72,146.182L212.72,132.063L514.241,132.063L514.241,103.825L540.487,139.123L514.241,174.421L514.241,146.182L212.72,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
<g transform="matrix(-0.09184,-0.226458,0.585165,-0.237313,776.07,1552.03)">
<path d="M212.72,146.182L212.72,132.063L491.234,132.063L491.234,103.825L540.487,139.123L491.234,174.421L491.234,146.182L212.72,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
<g transform="matrix(-0.242347,-0.0314007,0.0811391,-0.62622,1007.44,1453.94)">
<path d="M212.72,146.182L212.72,132.063L491.234,132.063L491.234,103.825L540.487,139.123L491.234,174.421L491.234,146.182L212.72,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
<g transform="matrix(0.425191,0.595256,-0.513833,0.36703,610.905,1394.44)">
<path d="M243.19,146.182L243.19,174.421L212.72,139.123L243.19,103.825L243.19,132.063L524.033,132.063L524.033,103.825L540.487,139.123L524.033,174.421L524.033,146.182L243.19,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
<g transform="matrix(-0.238092,0.276193,-0.478275,-0.412296,812.148,1376.42)">
<path d="M246.95,146.182L246.95,174.421L212.72,139.123L246.95,103.825L246.95,132.063L507.48,132.063L507.48,103.825L540.487,139.123L507.48,174.421L507.48,146.182L246.95,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
</g>
<g transform="matrix(0.268623,0.0378223,-0.0880408,0.625287,331.337,1404.06)">
<path d="M212.72,146.182L212.72,132.063L496.118,132.063L496.118,103.825L540.487,139.123L496.118,174.421L496.118,146.182L212.72,146.182Z" style="fill:rgb(62,62,62);"/>
</g>
</g>
</svg>