easyice commented on PR #12377:
URL: https://github.com/apache/lucene/pull/12377#issuecomment-1600339243

   @mikemccand @jpountz Thank you for your suggestions and fresh perspectives 
on this change, i wrote a simply benchmark for DirectMonotonicWriter, it will 
write 500 blocks each loop and observe the minimum time taken,  the results 
appear to be slightly faster,  from 492ms->425ms 
   
   here is the benchmark: 
   
   ```
   
   public class IndexBenchMarks {
   
   
       public static void main(final String[] args) throws Exception {
           doWriteMonotonic();
       }
   
       static void doWriteMonotonic() throws IOException {
           BenchMark benchMark = new BenchMark(50, 50, (1 << 
BenchMark.DIRECT_MONOTONIC_BLOCK_SHIFT) * 500);
           benchMark.run();
       }
   
       static class BenchMark {
           final int warmup;
           final int numValues;
           final int loopCount;
           static final int DIRECT_MONOTONIC_BLOCK_SHIFT = 16;
           Directory dir;
           DirectMonotonicWriter writer;
           IndexOutput metaOut;
           IndexOutput dataOut;
   
           BenchMark(int warmup, int loopCount, int numValues) {
               this.warmup = warmup;
               this.numValues = numValues;
               this.loopCount = loopCount;
           }
   
           private void init() throws IOException {
               Path tempDir = 
Files.createTempDirectory(Paths.get("/Volumes/RamDisk"), "tmp");
               dir = MMapDirectory.open(tempDir);
               metaOut = dir.createOutput("meta", IOContext.DEFAULT);
               dataOut = dir.createOutput("data", IOContext.DEFAULT);
           }
   
           private void close() throws IOException {
               metaOut.close();
               dataOut.close();
               dir.close();
           }
   
           private void doWrite() throws IOException {
               long v = 100;
               for (int i = 0; i < numValues; i++) {
                   if (i % 2 == 0) {
                       v += 5;
                   } else {
                       v += 10;
                   }
                   writer.add(v);
               }
           }
   
           void run() throws IOException {
               init();
               for (int i = 0; i < warmup; i++) {
                   writer = DirectMonotonicWriter.getInstance(metaOut, dataOut, 
numValues, DIRECT_MONOTONIC_BLOCK_SHIFT);
                   doWrite();
                   writer.finish();
               }
               System.gc();
               List<Double> times = new ArrayList<>();
               for (int i = 0; i < loopCount; i++) {
                   writer = DirectMonotonicWriter.getInstance(metaOut, dataOut, 
numValues, DIRECT_MONOTONIC_BLOCK_SHIFT);
                   long t0 = System.nanoTime();
                   doWrite();
                   writer.finish();
                   times.add((System.nanoTime() - t0) / 1000000D);
   
               }
               double min = 
times.stream().mapToDouble(Number::doubleValue).min().getAsDouble();
               System.out.println("took(ms):" + String.format(Locale.ROOT, 
"%.2f", min));
               close();
           }
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to