@Test public void testCacheConcurrency() throws InterruptedException { metricsPrefix = "tCC"; Object[] newConfig = {option(GraphDatabaseConfiguration.DB_CACHE),true, option(GraphDatabaseConfiguration.DB_CACHE_TIME),0, option(GraphDatabaseConfiguration.DB_CACHE_CLEAN_WAIT),0, option(GraphDatabaseConfiguration.DB_CACHE_SIZE),0.25, option(GraphDatabaseConfiguration.BASIC_METRICS),true, option(GraphDatabaseConfiguration.METRICS_MERGE_STORES),false, option(GraphDatabaseConfiguration.METRICS_PREFIX),metricsPrefix}; clopen(newConfig); final String prop = "someProp"; makeKey(prop,Integer.class); finishSchema(); TitanVertex v = graph.addVertex(prop,0); graph.tx().commit(); vids[i]=getId(v); clopen(newConfig); resetEdgeCacheCounts(); System.out.println("Retrievals: " + getEdgeCacheRetrievals()); System.out.println("Hits: " + (getEdgeCacheRetrievals()-getEdgeCacheMisses())); System.out.println("Misses: " + getEdgeCacheMisses()); assertEquals(numReads, lookups.get()); assertEquals(2 * numReads + 1 * numV, getEdgeCacheRetrievals()); int minMisses = 2*numV; assertTrue("Min misses ["+minMisses+"] vs actual ["+getEdgeCacheMisses()+"]",minMisses<=getEdgeCacheMisses() && 4*minMisses>=getEdgeCacheMisses());
@Test public void testIdCounts() { makeVertexIndexedUniqueKey("uid", Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"), ConsistencyModifier.LOCK); finishSchema(); //Schema and relation id pools are tapped, Schema id pool twice because the renew is triggered. Each id acquisition requires 1 mutations and 2 reads verifyStoreMetrics(ID_STORE_NAME, SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 3l, M_GET_SLICE, 6l)); }
public void printAllMetrics() { printAllMetrics(metricsPrefix); }
public void checkFastProperty(boolean fastProperty) { makeKey("uid",String.class); makeKey("name", String.class); makeKey("age", String.class); finishSchema(); clopen(option(GraphDatabaseConfiguration.PROPERTY_PREFETCHING), fastProperty); metricsPrefix = "checkFastProperty"+fastProperty; TitanTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start(); TitanVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john"); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); tx = graph.buildTransaction().groupName(metricsPrefix).start(); v = getV(tx, v); assertEquals("v1",v.property("uid").value()); assertEquals("25",v.property("age").value()); assertEquals("john",v.property("name").value()); tx.commit(); if (fastProperty) verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2l)); else verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 4l)); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); }
resetEdgeCacheCounts(); makeVertexIndexedUniqueKey("uid", Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema(); if (cache) clopen(option(DB_CACHE),true,option(DB_CACHE_CLEAN_WAIT),0,option(DB_CACHE_TIME),0); else clopen(); tx.makeVertexLabel("person").make(); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 3); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); resetMetrics(); resetMetrics(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 19l)); verifyStoreMetrics(INDEXSTORE_NAME, e.property("name", "edge"); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 1); v = getOnlyElement(tx.query().has("uid",1).vertices()); assertEquals(1,v.<Integer>value("uid").intValue());
resetEdgeCacheCounts(); makeVertexIndexedUniqueKey("uid",Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema(); if (cache) clopen(option(DB_CACHE),true,option(DB_CACHE_CLEAN_WAIT),0,option(DB_CACHE_TIME),0); else clopen(); tx.makeVertexLabel("person").make(); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); if (storeUsesConsistentKeyLocker()) verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 6l, M_ACQUIRE_LOCK, 0l)); else verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 3l, M_ACQUIRE_LOCK, 3l)); resetMetrics(); resetMetrics(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 19l)); verifyStoreMetrics(INDEXSTORE_NAME, e.setProperty("name","edge"); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); if (storeUsesConsistentKeyLocker()) verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2L, M_ACQUIRE_LOCK, 0L));
Object[] newConfig = {option(GraphDatabaseConfiguration.DB_CACHE),true, option(GraphDatabaseConfiguration.DB_CACHE_TIME),0}; clopen(newConfig); long vertexId = getId(previous); assertCount(numV, graph.query().vertices()); clopen(newConfig); for (int c=0;c<outerRepeat;c++) { double timecold = testAllVertices(vertexId,numV); for (int i = 0;i<innerRepeat;i++) { graph.tx().commit(); timewarm += testAllVertices(vertexId,numV); for (int j=0;j<innerRepeat;j++) { timehot += testAllVertices(vertexId,numV); clopen(newConfig); timehotglobal = timehotglobal/measurements; System.out.println(round(timecoldglobal) + "\t" + round(timewarmglobal) + "\t" + round(timehotglobal)); assertTrue(timecoldglobal + " vs " + timewarmglobal, timecoldglobal>timewarmglobal*2);
public void checkFastPropertyAndLocking(boolean fastProperty) { PropertyKey uid = makeKey("uid",String.class); TitanGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(index, ConsistencyModifier.LOCK); finishSchema(); clopen(option(GraphDatabaseConfiguration.PROPERTY_PREFETCHING), fastProperty); metricsPrefix = "metrics3"+fastProperty; ElementHelper.setProperties(v, "uid", "v1", "age", 25, "name", "john"); tx.commit(); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 7l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 4l, M_MUTATE, 7l, M_ACQUIRE_LOCK, 3l)); verifyTypeCacheMetrics(0, 0, 0, 0); tx.commit(); if (fastProperty) verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 7l)); else verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 7l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 6l, M_MUTATE, 7l, M_ACQUIRE_LOCK, 4l)); if (fastProperty) verifyTypeCacheMetrics(6, 2, 5, 5); else verifyTypeCacheMetrics(6, 2, 4, 4); tx.commit(); if (fastProperty) verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 9l, M_GET_SLICE, 9l)); else
@Test public void checkPropertyLockingAndIndex() { PropertyKey uid = makeKey("uid",String.class); TitanGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(index, ConsistencyModifier.LOCK); mgmt.makePropertyKey("name").dataType(String.class).make(); mgmt.makePropertyKey("age").dataType(Integer.class).make(); finishSchema(); metricsPrefix = "checkPropertyLockingAndIndex"; TitanTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start(); TitanVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john"); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 1); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); resetMetrics(); tx = graph.buildTransaction().groupName(metricsPrefix).start(); v = Iterables.getOnlyElement(tx.query().has("uid", Cmp.EQUAL, "v1").vertices()); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l)); verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l)); verifyStoreMetrics(METRICS_STOREMANAGER_NAME); }
finishSchema(); v.setProperty("foo", "bus"); tx.commit(); if (storeUsesConsistentKeyLocker()) verifyStoreMetrics(STORE_NAMES.get(1)); else verifyStoreMetrics(STORE_NAMES.get(0)); verifyStoreMetrics(STORE_NAMES.get(1)); verifyStoreMetrics(STORE_NAMES.get(2)); verifyStoreMetrics(STORE_NAMES.get(3), ImmutableMap.of(M_MUTATE, 1l)); assertEquals(1, Iterables.size(v.getProperties())); tx.commit(); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_GET_SLICE, 2l)); verifyStoreMetrics(STORE_NAMES.get(1)); verifyStoreMetrics(STORE_NAMES.get(2)); verifyStoreMetrics(STORE_NAMES.get(3), ImmutableMap.of(M_MUTATE, 2l));
finishSchema(); verifyStoreMetrics(EDGESTORE_NAME); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); assertEquals(1, Iterators.size(v.properties())); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2l)); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 2l)); verifyStoreMetrics(ID_STORE_NAME);
@Override public WriteConfiguration getConfiguration() { WriteConfiguration config = getBaseConfiguration(); ModifiableConfiguration mconf = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,config, BasicConfiguration.Restriction.NONE); mconf.set(BASIC_METRICS,true); mconf.set(METRICS_MERGE_STORES,false); mconf.set(PROPERTY_PREFETCHING,false); mconf.set(DB_CACHE, false); return config; }
Object[] newConfig = {option(GraphDatabaseConfiguration.DB_CACHE),true, option(GraphDatabaseConfiguration.DB_CACHE_TIME),0}; clopen(newConfig); assertEquals(numV, Iterables.size(graph.getVertices())); clopen(newConfig); for (int c=0;c<outerRepeat;c++) { double timecold = testAllVertices(vertexId,numV); for (int i = 0;i<innerRepeat;i++) { graph.commit(); timewarm += testAllVertices(vertexId,numV); for (int j=0;j<innerRepeat;j++) { timehot += testAllVertices(vertexId,numV); clopen(newConfig); timehotglobal = timehotglobal/measurements; System.out.println(round(timecoldglobal) + "\t" + round(timewarmglobal) + "\t" + round(timehotglobal)); assertTrue(timecoldglobal + " vs " + timewarmglobal, timecoldglobal>timewarmglobal*2); assertTrue(timewarmglobal + " vs " + timehotglobal, timewarmglobal>timehotglobal*1.2);
@Override public WriteConfiguration getConfiguration() { WriteConfiguration config = getBaseConfiguration(); ModifiableConfiguration mconf = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,config, BasicConfiguration.Restriction.NONE); mconf.set(BASIC_METRICS,true); mconf.set(METRICS_MERGE_STORES,false); mconf.set(PROPERTY_PREFETCHING,false); mconf.set(DB_CACHE,false); return config; }
Object[] newConfig = {option(GraphDatabaseConfiguration.DB_CACHE),true, option(GraphDatabaseConfiguration.DB_CACHE_TIME),0, option(GraphDatabaseConfiguration.DB_CACHE_CLEAN_WAIT),0, option(GraphDatabaseConfiguration.DB_CACHE_SIZE),0.25, option(GraphDatabaseConfiguration.BASIC_METRICS),true, option(GraphDatabaseConfiguration.METRICS_MERGE_STORES),false, option(GraphDatabaseConfiguration.METRICS_PREFIX),metricsPrefix}; clopen(newConfig); final String prop = "property"; makeKey(prop,Integer.class); finishSchema(); vids[i]=v.getLongId(); clopen(newConfig); resetEdgeCacheCounts(); System.out.println("Retrievals: " + getEdgeCacheRetrievals()); System.out.println("Hits: " + (getEdgeCacheRetrievals()-getEdgeCacheMisses())); System.out.println("Misses: " + getEdgeCacheMisses()); assertEquals(numReads, lookups.get()); assertEquals(2 * numReads + 2 * numV + 2, getEdgeCacheRetrievals()); int minMisses = 4*numV+2; assertTrue("Min misses ["+minMisses+"] vs actual ["+getEdgeCacheMisses()+"]",minMisses<=getEdgeCacheMisses() && 4*minMisses>=getEdgeCacheMisses());
@Test public void testIdCounts() { makeVertexIndexedUniqueKey("uid",Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema(); //Schema and relation id pools are tapped, Schema id pool twice because the renew is triggered. Each id acquisition requires 1 mutations and 2 reads verifyStoreMetrics(ID_STORE_NAME, SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 3l, M_GET_SLICE, 6l)); }
public void printAllMetrics() { printAllMetrics(metricsPrefix); }