Measure fsync (called when closing the NRT index)
@@ -59,6 +59,9 @@ import static org.apache.jackrabbit.oak.plugins.index.lucene.directory.Directory
public class NRTIndex implements Closeable {
+
+ private static final boolean REGULAR_CLOSE = Boolean.getBoolean("oak.lucene.nrt.regularClose");
+
private static final AtomicInteger COUNTER = new AtomicInteger();
private static final Logger log = LoggerFactory.getLogger(NRTIndex.class);
@@ -200,10 +203,22 @@ public class NRTIndex implements Closeable {
assertAllReadersAreClosed();
if (indexWriter != null) {
- //TODO Close call can possibly be speeded up by
- //avoiding merge and dropping stuff in memory. To be explored
- //indexWrite.close(waitForMerges)
+
+ long time = System.nanoTime();
+ if (REGULAR_CLOSE) {
indexWriter.close();
+ } else {
+ // don't merge, as anyway only keep two generations
+ indexWriter.close(false);
+ }
+ time = System.nanoTime() - time;
+ if (time > 100_000_000) {
+ // slower than 100 ms
+ log.info("Closing time: {} ns", time);
+ } else if (log.isTraceEnabled()) {
+ log.trace("Closing time: {} ns", time);
+ }
+
sizeHisto.update(dirSize(directory));
directory.close();
FileUtils.deleteQuietly(indexDir);
