Skip to content

Commit

Permalink
make larger segments
Browse files Browse the repository at this point in the history
  • Loading branch information
vthacker committed Jun 19, 2023
1 parent f34e090 commit f289e21
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class LuceneIndexStoreImpl implements LogStore<LogMessage> {
private final io.micrometer.core.instrument.Timer commitsTimer;
private final io.micrometer.core.instrument.Timer refreshesTimer;

private final String MAX_RAM_BUFFER_SIZE_MB = "maxRamBufferSizeMb";

// TODO: Set the policy via a lucene config file.
public static LuceneIndexStoreImpl makeLogStore(
File dataDirectory, KaldbConfigs.LuceneConfig luceneConfig, MeterRegistry metricsRegistry)
Expand Down Expand Up @@ -148,10 +150,14 @@ private IndexWriterConfig buildIndexWriterConfig(
SnapshotDeletionPolicy snapshotDeletionPolicy,
LuceneIndexStoreConfig config,
MeterRegistry metricsRegistry) {
int ramBufferSizeMb = Integer.getInteger(MAX_RAM_BUFFER_SIZE_MB, 1024);
boolean useCFSFiles = ramBufferSizeMb <= 128;
final IndexWriterConfig indexWriterCfg =
new IndexWriterConfig(analyzer)
.setOpenMode(IndexWriterConfig.OpenMode.CREATE)
.setMergeScheduler(new KalDBMergeScheduler(metricsRegistry))
.setRAMBufferSizeMB(ramBufferSizeMb)
.setUseCompoundFile(useCFSFiles)
// we sort by timestamp descending, as that is the order we expect to return results the
// majority of the time
.setIndexSort(
Expand All @@ -162,6 +168,12 @@ private IndexWriterConfig buildIndexWriterConfig(
true)))
.setIndexDeletionPolicy(snapshotDeletionPolicy);

// See
// https://lucene.apache.org/core/9_5_0/core/org/apache/lucene/index/IndexWriterConfig.html#setUseCompoundFile(boolean)
if (ramBufferSizeMb >= 128) {
indexWriterCfg.getMergePolicy().setNoCFSRatio(0.0);
}

if (config.enableTracing) {
indexWriterCfg.setInfoStream(System.out);
}
Expand Down

0 comments on commit f289e21

Please sign in to comment.