Remove busy wait in logging loop

This commit is contained in:
xdark 2023-04-01 02:48:38 +03:00
parent ec83d01dca
commit e401eefc30
1 changed files with 1 additions and 7 deletions

View File

@ -949,7 +949,6 @@ public class EarlybirdServer implements EarlybirdService.ServiceIface, ServerSet
protected static class EarlybirdThriftRequestLoggingUtil { protected static class EarlybirdThriftRequestLoggingUtil {
private static final int DEFAULT_MAX_ENTRIES_TO_LOG = 50000; private static final int DEFAULT_MAX_ENTRIES_TO_LOG = 50000;
private static final int DEFAULT_BUFFER_SIZE = 10000; private static final int DEFAULT_BUFFER_SIZE = 10000;
private static final int DEFAULT_LOGGING_SLEEP_MS = 100;
@VisibleForTesting @VisibleForTesting
protected static volatile boolean thriftLoggerBusy = false; protected static volatile boolean thriftLoggerBusy = false;
@ -998,13 +997,8 @@ public class EarlybirdServer implements EarlybirdService.ServiceIface, ServerSet
try { try {
int count = 0; int count = 0;
while (count < maxEntriesToLog) { while (count < maxEntriesToLog) {
if (REQUEST_BUFFER.isEmpty()) {
Thread.sleep(DEFAULT_LOGGING_SLEEP_MS);
continue;
}
try { try {
EarlybirdRequest ebRequest = REQUEST_BUFFER.poll(); EarlybirdRequest ebRequest = REQUEST_BUFFER.take();
String logLine = serializeThriftObject(ebRequest, serializer); String logLine = serializeThriftObject(ebRequest, serializer);
thriftLogWriter.write(logLine); thriftLogWriter.write(logLine);
count++; count++;