fix performance regression

The last improvement of memory usage introduced a performance
regression. The ingestion performance dropped by 50%-80%, because
for every inserted entry the Tags were created inefficient.
This commit is contained in:
2018-03-27 19:30:18 +02:00
parent de0f8412bd
commit 81711d551f
7 changed files with 76 additions and 47 deletions

View File

@@ -24,6 +24,7 @@ import javax.annotation.PreDestroy;
import org.lucares.pdb.api.Entry;
import org.lucares.pdb.api.Tags;
import org.lucares.pdb.api.TagsBuilder;
import org.lucares.performance.db.BlockingQueueIterator;
import org.lucares.performance.db.PerformanceDb;
import org.lucares.recommind.logs.Config;
@@ -124,7 +125,7 @@ public class TcpIngestor implements Ingestor, AutoCloseable, DisposableBean {
}
private Tags createTags(final Map<String, Object> map) {
Tags tags = Tags.create();
final TagsBuilder tags = TagsBuilder.create();
for (final java.util.Map.Entry<String, Object> e : map.entrySet()) {
final String key = e.getKey();
@@ -139,11 +140,15 @@ public class TcpIngestor implements Ingestor, AutoCloseable, DisposableBean {
// ignore: we only support key/value tags
break;
default:
tags = tags.copyAddIfNotNull(key, String.valueOf(value));
if (value instanceof String) {
tags.add(key, (String) value);
} else {
tags.add(key, String.valueOf(value));
}
break;
}
}
return tags;
return tags.build();
}
private OffsetDateTime getDate(final Map<String, Object> map) {