Skip to content

Commit a467d93

Browse files
committed
Improve comments
1 parent 223580a commit a467d93

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

LLama/Batched/BatchedExecutor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public sealed class BatchedExecutor
1919
private int _batchQueueHead;
2020
private int _batchedTokenCount;
2121
private bool _batchedTokenCountDirty = true;
22+
// Skip compacting the queue until this many processed batches accumulate at the front.
2223
private const int CleanupThreshold = 16;
2324

2425
/// <summary>
@@ -205,6 +206,7 @@ void RequeueFront(IBatch batch)
205206
_batchedTokenCountDirty = true;
206207
}
207208

209+
// Remove batches that have already been consumed so the head index does not grow without bound.
208210
void CleanupQueue()
209211
{
210212
if (_batchQueueHead == 0)

LLama/Common/FixedSizeQueue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public class FixedSizeQueue<T>
1616
private int _count;
1717
private T[]? _window;
1818

19+
// Minimum capacity for the temporary buffer used to expose a contiguous view.
1920
private const int MinimumWindowSize = 4;
21+
// Resize multiplier for the temporary buffer to reduce copy churn as it grows.
2022
private const int WindowGrowthFactor = 2;
2123

2224
/// <inheritdoc />
@@ -123,6 +125,9 @@ IEnumerator IEnumerable.GetEnumerator()
123125
return GetEnumerator();
124126
}
125127

128+
/// <summary>
129+
/// Returns up to <paramref name="count"/> of the most recent items as a contiguous span.
130+
/// </summary>
126131
internal ReadOnlySpan<T> AsSpan(int count)
127132
{
128133
count = Math.Min(count, _count);

0 commit comments

Comments
 (0)