ring-buffer-architecture.svg 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 500" style="background-color: #fafafa;">
  3. <defs>
  4. <marker id="arrowhead" markerWidth="10" markerHeight="7"
  5. refX="10" refY="3.5" orient="auto">
  6. <polygon points="0 0, 10 3.5, 0 7" fill="#333" />
  7. </marker>
  8. <marker id="red-arrowhead" markerWidth="10" markerHeight="7"
  9. refX="10" refY="3.5" orient="auto">
  10. <polygon points="0 0, 10 3.5, 0 7" fill="#d32f2f" />
  11. </marker>
  12. <marker id="blue-arrowhead" markerWidth="10" markerHeight="7"
  13. refX="10" refY="3.5" orient="auto">
  14. <polygon points="0 0, 10 3.5, 0 7" fill="#1976d2" />
  15. </marker>
  16. <marker id="green-arrowhead" markerWidth="10" markerHeight="7"
  17. refX="10" refY="3.5" orient="auto">
  18. <polygon points="0 0, 10 3.5, 0 7" fill="#388e3c" />
  19. </marker>
  20. <filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
  21. <feDropShadow dx="2" dy="2" stdDeviation="2" flood-color="#00000020"/>
  22. </filter>
  23. </defs>
  24. <!-- Title -->
  25. <text x="400" y="30" font-family="Arial, sans-serif" font-size="18" font-weight="bold" text-anchor="middle" fill="#333">
  26. Ring Buffer Architecture (8 slots shown) for Parallel Compression
  27. </text>
  28. <!-- Ring Buffer Array -->
  29. <g transform="translate(100,150)">
  30. <!-- Array slots laid out horizontally -->
  31. <!-- Slot 0 -->
  32. <rect x="0" y="0" width="70" height="50" fill="#f5f5f5" stroke="#666" stroke-width="1" rx="5" filter="url(#shadow)"/>
  33. <text x="35" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 0</text>
  34. <text x="35" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#666">Empty</text>
  35. <!-- Slot 1 - NextToWrite=1, being written by Worker Thread 2 -->
  36. <rect x="75" y="0" width="70" height="50" fill="#e8f5e8" stroke="#388e3c" stroke-width="3" rx="5" filter="url(#shadow)"/>
  37. <text x="110" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 1</text>
  38. <text x="110" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#388e3c">Writing...</text>
  39. <!-- Slot 2 - Compressed -->
  40. <rect x="150" y="0" width="70" height="50" fill="#fff3e0" stroke="#f57c00" stroke-width="2" rx="5" filter="url(#shadow)"/>
  41. <text x="185" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 2</text>
  42. <text x="185" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#666">Compressed</text>
  43. <!-- Slot 3 - Being compressed by Worker Thread 1 -->
  44. <rect x="225" y="0" width="70" height="50" fill="#e3f2fd" stroke="#1976d2" stroke-width="3" rx="5" filter="url(#shadow)"/>
  45. <text x="260" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 3</text>
  46. <text x="260" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#1976d2">Compressing...</text>
  47. <!-- Slot 4 - NextToCompress=4, uncompressed -->
  48. <rect x="300" y="0" width="70" height="50" fill="#ffebee" stroke="#d32f2f" stroke-width="2" rx="5" filter="url(#shadow)"/>
  49. <text x="335" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 4</text>
  50. <text x="335" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#666">Uncompressed</text>
  51. <!-- Slot 5 - NextToEmit=5, adding block -->
  52. <rect x="375" y="0" width="70" height="50" fill="#e1f5fe" stroke="#4fc3f7" stroke-width="3" rx="5" filter="url(#shadow)"/>
  53. <text x="410" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 5</text>
  54. <text x="410" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#4fc3f7">Adding block...</text>
  55. <!-- Slot 6 -->
  56. <rect x="450" y="0" width="70" height="50" fill="#f5f5f5" stroke="#666" stroke-width="1" rx="5" filter="url(#shadow)"/>
  57. <text x="485" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 6</text>
  58. <text x="485" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#666">Empty</text>
  59. <!-- Slot 7 -->
  60. <rect x="525" y="0" width="70" height="50" fill="#f5f5f5" stroke="#666" stroke-width="1" rx="5" filter="url(#shadow)"/>
  61. <text x="560" y="20" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#333">Slot 7</text>
  62. <text x="560" y="35" font-family="Arial, sans-serif" font-size="9" text-anchor="middle" fill="#666">Empty</text>
  63. </g>
  64. <!-- Arrows pointing to array positions - staggered vertically -->
  65. <!-- NextToWrite=1 arrow (red) -->
  66. <line x1="210" y1="100" x2="210" y2="145" stroke="#d32f2f" stroke-width="3" marker-end="url(#red-arrowhead)"/>
  67. <text x="210" y="90" font-family="Arial, sans-serif" font-size="12" font-weight="bold" text-anchor="middle" fill="#d32f2f">NextToWrite=1</text>
  68. <!-- NextToCompress=4 arrow (blue) -->
  69. <line x1="435" y1="110" x2="435" y2="145" stroke="#1976d2" stroke-width="3" marker-end="url(#blue-arrowhead)"/>
  70. <text x="435" y="100" font-family="Arial, sans-serif" font-size="12" font-weight="bold" text-anchor="middle" fill="#1976d2">NextToCompress=4</text>
  71. <!-- NextToEmit=5 arrow (light blue) -->
  72. <line x1="510" y1="120" x2="510" y2="145" stroke="#4fc3f7" stroke-width="3" marker-end="url(#arrowhead)"/>
  73. <text x="510" y="110" font-family="Arial, sans-serif" font-size="12" font-weight="bold" text-anchor="middle" fill="#4fc3f7">NextToEmit=5</text>
  74. <!-- Worker Thread 2 (wider box) -->
  75. <g transform="translate(30,250)">
  76. <rect x="0" y="0" width="160" height="70" fill="#e8f5e8" stroke="#388e3c" stroke-width="2" rx="8" filter="url(#shadow)"/>
  77. <text x="80" y="25" font-family="Arial, sans-serif" font-size="14" font-weight="bold" text-anchor="middle" fill="#333">Worker Thread 2</text>
  78. <text x="80" y="40" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#666">Currently writing</text>
  79. <text x="80" y="55" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#666">Can also compress</text>
  80. </g>
  81. <!-- Worker Thread 1 (wider box) -->
  82. <g transform="translate(240,280)">
  83. <rect x="0" y="0" width="160" height="70" fill="#e3f2fd" stroke="#1976d2" stroke-width="2" rx="8" filter="url(#shadow)"/>
  84. <text x="80" y="25" font-family="Arial, sans-serif" font-size="14" font-weight="bold" text-anchor="middle" fill="#333">Worker Thread 1</text>
  85. <text x="80" y="40" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#666">Currently compressing</text>
  86. <text x="80" y="55" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#666">Can also write</text>
  87. </g>
  88. <!-- Emit Thread (wider box) -->
  89. <g transform="translate(460,250)">
  90. <rect x="0" y="0" width="180" height="70" fill="#e1f5fe" stroke="#4fc3f7" stroke-width="2" rx="8" filter="url(#shadow)"/>
  91. <text x="90" y="25" font-family="Arial, sans-serif" font-size="14" font-weight="bold" text-anchor="middle" fill="#333">Emit Thread</text>
  92. <text x="90" y="40" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#666">Generates uncompressed blocks</text>
  93. <text x="90" y="55" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#666">Can help with compression</text>
  94. </g>
  95. <!-- Arrows from threads to array (no labels) -->
  96. <!-- Worker Thread 2 to Slot 1 -->
  97. <line x1="190" y1="285" x2="210" y2="210" stroke="#388e3c" stroke-width="2" marker-end="url(#green-arrowhead)"/>
  98. <!-- Worker Thread 1 to Slot 3 -->
  99. <line x1="320" y1="280" x2="360" y2="210" stroke="#1976d2" stroke-width="2" marker-end="url(#blue-arrowhead)"/>
  100. <!-- Emit Thread to Slot 5 -->
  101. <line x1="550" y1="250" x2="510" y2="210" stroke="#4fc3f7" stroke-width="2" marker-end="url(#arrowhead)"/>
  102. <!-- SST File Output (centered below Worker Thread 2) -->
  103. <g transform="translate(50,380)">
  104. <rect x="0" y="0" width="120" height="40" fill="#e8f5e8" stroke="#388e3c" stroke-width="2" rx="5" filter="url(#shadow)"/>
  105. <text x="60" y="25" font-family="Arial, sans-serif" font-size="12" font-weight="bold" text-anchor="middle" fill="#333">SST File</text>
  106. </g>
  107. <!-- Arrow from Worker Thread 2 to SST file -->
  108. <line x1="110" y1="320" x2="110" y2="380" stroke="#388e3c" stroke-width="2" marker-end="url(#green-arrowhead)"/>
  109. <!-- Invariant (moved to the right) -->
  110. <g transform="translate(400,430)">
  111. <text x="0" y="0" font-family="Arial, sans-serif" font-size="12" font-weight="bold" fill="#333">Invariant:</text>
  112. <text x="0" y="20" font-family="Arial, sans-serif" font-size="11" fill="#666">NextToWrite ≤ NextToCompress ≤ NextToEmit (modulo ring buffer size)</text>
  113. </g>
  114. </svg>