Search in sources :

Example 1 with DiskStorageEngine

use of com.srotya.sidewinder.core.storage.disk.DiskStorageEngine in project sidewinder by srotya.

the class TestSetTagIndex method testTagIndexPerformance.

// @Test
public void testTagIndexPerformance() throws IOException, InterruptedException {
    MiscUtils.delete(new File("target/perf/index-dir"));
    MiscUtils.delete(new File("target/perf/data-dir"));
    DiskStorageEngine engine = new DiskStorageEngine();
    HashMap<String, String> conf = new HashMap<>();
    conf.put("index.dir", "target/perf/index-dir");
    conf.put("data.dir", "target/perf/data-dir");
    engine.configure(conf, Executors.newScheduledThreadPool(1, new BackgrounThreadFactory("bgt")));
    final long ms = System.currentTimeMillis();
    ExecutorService es = Executors.newCachedThreadPool();
    for (int k = 0; k < 6; k++) {
        es.submit(() -> {
            for (int i = 0; i < 200_000_000; i++) {
                try {
                    engine.getOrCreateTimeSeries("db1", "m1", "v10", Arrays.asList(String.valueOf(i % 10_000), "test=" + "asdasdasd" + String.valueOf(i % 5), "test2=" + String.valueOf(i % 5), "goliath=" + String.valueOf(i % 100_000), "goliath2=" + String.valueOf(i % 1_500)), 4096, true);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (i % 1_000_000 == 0) {
                    System.out.println(i + "  " + (System.currentTimeMillis() - ms) / 1000);
                }
            }
        });
    }
    es.shutdown();
    es.awaitTermination(1000, TimeUnit.SECONDS);
    System.err.println("Index time:" + (System.currentTimeMillis() - ms));
    Map<String, Map<String, Measurement>> index = engine.getMeasurementMap();
    assertEquals(1, index.size());
    Entry<String, Map<String, Measurement>> next = index.entrySet().iterator().next();
    assertEquals("db1", next.getKey());
    Entry<String, Measurement> itr = next.getValue().entrySet().iterator().next();
    assertEquals("m1", itr.getKey());
}
Also used : Measurement(com.srotya.sidewinder.core.storage.Measurement) BackgrounThreadFactory(com.srotya.sidewinder.core.utils.BackgrounThreadFactory) HashMap(java.util.HashMap) DiskStorageEngine(com.srotya.sidewinder.core.storage.disk.DiskStorageEngine) IOException(java.io.IOException) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Measurement (com.srotya.sidewinder.core.storage.Measurement)1 DiskStorageEngine (com.srotya.sidewinder.core.storage.disk.DiskStorageEngine)1 BackgrounThreadFactory (com.srotya.sidewinder.core.utils.BackgrounThreadFactory)1 File (java.io.File)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutorService (java.util.concurrent.ExecutorService)1