Skip to content

Commit

Permalink
[GC] Batch item to scan from the worklist.
Browse files Browse the repository at this point in the history
  • Loading branch information
deadalnix committed Oct 19, 2024
1 parent 3cbfa8e commit 0037c22
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sdlib/d/gc/scanner.d
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,17 @@ private:
activeThreads++;

auto stop = w.cursor;
auto start = stop - 1;
auto start = stop;

uint length = 0;
foreach (_; 0 .. Worker.MaxRefill) {
length += w.worklist[--start].length;

enum RefillTargetSize = PageSize;
if (start == 0 || length >= RefillTargetSize) {
break;
}
}

w.cursor = start;
worker.refill(w.worklist[start .. stop]);
Expand Down Expand Up @@ -216,7 +226,7 @@ private:

struct Worker {
enum WorkListCapacity = 16;
enum MaxRefill = 1;
enum MaxRefill = 4;

private:
shared(Scanner)* scanner;
Expand Down

0 comments on commit 0037c22

Please sign in to comment.