Skip to content

Commit e7f31c4

Browse files
committed
Partial port of commit 011a35b0a
1 parent b2c8a61 commit e7f31c4

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/Lucene.Net/Index/FlushByRamOrCountsPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public override void OnInsert(DocumentsWriterFlushControl control, ThreadState s
9797
{
9898
if (m_infoStream.IsEnabled("FP"))
9999
{
100-
m_infoStream.Message("FP", "flush: activeBytes=" + control.ActiveBytes + " deleteBytes=" + control.DeleteBytesUsed + " vs limit=" + limit);
100+
m_infoStream.Message("FP", "trigger flush: activeBytes=" + control.ActiveBytes + " deleteBytes=" + control.DeleteBytesUsed + " vs limit=" + limit);
101101
}
102102
MarkLargestWriterPending(control, state, totalRam);
103103
}

src/Lucene.Net/Index/FlushPolicy.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,28 @@ protected virtual ThreadState FindLargestNonPendingWriter(DocumentsWriterFlushCo
122122
ThreadState maxRamUsingThreadState = perThreadState;
123123
if (Debugging.AssertsEnabled) Debugging.Assert(!perThreadState.flushPending, "DWPT should have flushed");
124124
using IEnumerator<ThreadState> activePerThreadsIterator = control.AllActiveThreadStates();
125+
int count = 0;
125126
while (activePerThreadsIterator.MoveNext())
126127
{
127128
ThreadState next = activePerThreadsIterator.Current;
128129
if (!next.flushPending)
129130
{
130131
long nextRam = next.bytesUsed;
131-
if (nextRam > maxRamSoFar && next.dwpt.NumDocsInRAM > 0)
132+
if (nextRam > 0 && next.dwpt.NumDocsInRAM > 0)
132133
{
133-
maxRamSoFar = nextRam;
134-
maxRamUsingThreadState = next;
134+
count++;
135+
if (nextRam > maxRamSoFar)
136+
{
137+
maxRamSoFar = nextRam;
138+
maxRamUsingThreadState = next;
139+
}
135140
}
136141
}
137142
}
143+
if (m_infoStream.IsEnabled("FP"))
144+
{
145+
m_infoStream.Message("FP", $"{count} in-use non-flushing threads states");
146+
}
138147
if (Debugging.AssertsEnabled) Debugging.Assert(AssertMessage("set largest ram consuming thread pending on lower watermark"));
139148
return maxRamUsingThreadState;
140149
}

0 commit comments

Comments
 (0)