<mxfile host="Electron">
  <diagram id="gmp-scheduler" name="Go GMP Scheduler">
    <mxGraphModel dx="900" dy="650" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="850" math="0" shadow="0">
      <root>
        <mxCell id="0"/>
        <mxCell id="1" parent="0"/>
        <mxCell id="title" value="Go Scheduler: G-M-P Model" style="text;html=1;fontSize=18;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="330" y="20" width="300" height="30" as="geometry"/>
        </mxCell>
        <mxCell id="gs" value="G — Goroutines (runnable tasks)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="60" y="80" width="220" height="40" as="geometry"/>
        </mxCell>
        <mxCell id="g1" value="G1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
          <mxGeometry x="60" y="140" width="50" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="g2" value="G2" style="ellipse;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
          <mxGeometry x="120" y="140" width="50" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="g3" value="G3" style="ellipse;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
          <mxGeometry x="180" y="140" width="50" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="g4" value="G..." style="ellipse;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
          <mxGeometry x="240" y="140" width="50" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="lrq1" value="P1 Local Run Queue&#xa;(max 256 Gs)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
          <mxGeometry x="380" y="120" width="170" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="lrq2" value="P2 Local Run Queue" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
          <mxGeometry x="380" y="200" width="170" height="40" as="geometry"/>
        </mxCell>
        <mxCell id="grq" value="Global Run Queue&#xa;(shared, needs lock)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="1">
          <mxGeometry x="380" y="300" width="170" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="p1" value="P — Logical Processor&#xa;GOMAXPROCS" style="shape=cube;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="620" y="110" width="140" height="70" as="geometry"/>
        </mxCell>
        <mxCell id="p2" value="P2" style="shape=cube;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
          <mxGeometry x="620" y="200" width="140" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="m1" value="M — OS Thread" style="shape=process;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="840" y="110" width="140" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="m2" value="M2" style="shape=process;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="1">
          <mxGeometry x="840" y="200" width="140" height="50" as="geometry"/>
        </mxCell>
        <mxCell id="kernel" value="OS Kernel / CPUs" style="shape=cloud;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
          <mxGeometry x="840" y="300" width="140" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="netpoller" value="Netpoller&#xa;(epoll/kqueue:&#xa;network-ready Gs)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
          <mxGeometry x="60" y="300" width="180" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="steal" value="Work stealing:&#xa;idle P takes half the Gs&#xa;from a busy P's LRQ" style="text;html=1;fontSize=11;align=center;fillColor=#fff2cc;" vertex="1" parent="1">
          <mxGeometry x="380" y="400" width="240" height="60" as="geometry"/>
        </mxCell>
        <mxCell id="e1" value="" style="endArrow=classic;html=1;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" source="g2" target="lrq1" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e2" value="" style="endArrow=classic;html=1;" edge="1" source="lrq1" target="p1" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e3" value="" style="endArrow=classic;html=1;" edge="1" source="lrq2" target="p2" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e4" value="" style="endArrow=classic;html=1;" edge="1" source="p1" target="m1" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e5" value="" style="endArrow=classic;html=1;" edge="1" source="p2" target="m2" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e6" value="" style="endArrow=classic;html=1;" edge="1" source="m1" target="kernel" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e7" value="" style="endArrow=classic;html=1;" edge="1" source="m2" target="kernel" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e8" value="" style="endArrow=classic;html=1;dashed=1;" edge="1" source="netpoller" target="grq" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e9" value="fallback / overflow" style="endArrow=classic;html=1;dashed=1;" edge="1" source="grq" target="p1" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
        <mxCell id="e10" value="steal" style="endArrow=classic;html=1;dashed=1;startArrow=classic;" edge="1" source="p1" target="p2" parent="1">
          <mxGeometry relative="1" as="geometry"/>
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
