Search in sources :

Example 1 with StoreTimer

use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.

the class FDBStoreTimerTest method timerConstraintChecks.

@Test
public void timerConstraintChecks() {
    // invalid to substract a snapshot timer from a timer that has been reset after the snapshot was taken
    FDBStoreTimer latestTimer = context.getTimer();
    final StoreTimerSnapshot savedTimer;
    savedTimer = StoreTimerSnapshot.from(latestTimer);
    latestTimer.reset();
    assertThrows(RecordCoreArgumentException.class, () -> StoreTimer.getDifference(latestTimer, savedTimer));
    // invalid to subtract a snapshot timer from a timer it was not derived from
    StoreTimer anotherStoreTimer = new StoreTimer();
    assertThrows(RecordCoreArgumentException.class, () -> StoreTimer.getDifference(anotherStoreTimer, savedTimer));
}
Also used : StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) StoreTimerSnapshot(com.apple.foundationdb.record.provider.common.StoreTimerSnapshot) Test(org.junit.jupiter.api.Test)

Example 2 with StoreTimer

use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.

the class FDBStoreTimerTest method newMetricsAddedToSnapshotDifference.

@Test
public void newMetricsAddedToSnapshotDifference() {
    StoreTimer timer = new FDBStoreTimer();
    timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
    StoreTimerSnapshot snapshot = StoreTimerSnapshot.from(timer);
    timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
    timer.record(FDBStoreTimer.Events.DIRECTORY_READ, 7L);
    StoreTimer diff = StoreTimer.getDifference(timer, snapshot);
    assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getCount(), Matchers.is(1));
    assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getTimeNanos(), Matchers.is(0L));
    assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getCount(), Matchers.is(1));
    assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getTimeNanos(), Matchers.is(7L));
}
Also used : StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) StoreTimerSnapshot(com.apple.foundationdb.record.provider.common.StoreTimerSnapshot) Test(org.junit.jupiter.api.Test)

Example 3 with StoreTimer

use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.

the class FDBStoreTimerTest method unchangedMetricsExcludedFromSnapshotDifference.

@Test
public void unchangedMetricsExcludedFromSnapshotDifference() {
    StoreTimer timer = new FDBStoreTimer();
    timer.increment(FDBStoreTimer.Counts.CREATE_RECORD_STORE);
    timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
    timer.record(FDBStoreTimer.Events.CHECK_VERSION, 1L);
    timer.record(FDBStoreTimer.Events.DIRECTORY_READ, 3L);
    StoreTimerSnapshot snapshot = StoreTimerSnapshot.from(timer);
    timer.increment(FDBStoreTimer.Counts.DELETE_RECORD_KEY);
    timer.record(FDBStoreTimer.Events.DIRECTORY_READ, 7L);
    StoreTimer diff = StoreTimer.getDifference(timer, snapshot);
    assertThat(diff.getCounter(FDBStoreTimer.Counts.CREATE_RECORD_STORE), Matchers.nullValue());
    assertThat(diff.getCounter(FDBStoreTimer.Events.CHECK_VERSION), Matchers.nullValue());
    assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getCount(), Matchers.is(1));
    assertThat(diff.getCounter(FDBStoreTimer.Counts.DELETE_RECORD_KEY).getTimeNanos(), Matchers.is(0L));
    assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getCount(), Matchers.is(1));
    assertThat(diff.getCounter(FDBStoreTimer.Events.DIRECTORY_READ).getTimeNanos(), Matchers.is(7L));
}
Also used : StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) StoreTimerSnapshot(com.apple.foundationdb.record.provider.common.StoreTimerSnapshot) Test(org.junit.jupiter.api.Test)

Example 4 with StoreTimer

use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.

the class QueryPlanStructuralInstrumentationTest method unionDifferentIndex.

@Test
public void unionDifferentIndex() {
    final RecordQueryPlan plan = RecordQueryUnionPlan.from(indexPlanEquals("index_1", 2), indexPlanEquals("index_2", 4), EmptyKeyExpression.EMPTY, false);
    assertUsesIndexes(plan, Lists.newArrayList("index_1", "index_2"));
    final StoreTimer timer = new FDBStoreTimer();
    plan.logPlanStructure(timer);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_UNION), 1);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 2);
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Test(org.junit.jupiter.api.Test)

Example 5 with StoreTimer

use of com.apple.foundationdb.record.provider.common.StoreTimer in project fdb-record-layer by FoundationDB.

the class QueryPlanStructuralInstrumentationTest method in.

@Test
public void in() {
    final String indexName = "a_field";
    final IndexScanParameters scan = IndexScanComparisons.byValue(new ScanComparisons(Arrays.asList(new Comparisons.ParameterComparison(Comparisons.Type.EQUALS, "another_field")), Collections.emptySet()));
    final RecordQueryPlan plan = new RecordQueryInValuesJoinPlan(new RecordQueryIndexPlan(indexName, scan, false), "another_field", Bindings.Internal.IN, Arrays.asList(2, 4), false, false);
    assertUsesIndexes(plan, Lists.newArrayList(indexName));
    final StoreTimer timer = new FDBStoreTimer();
    plan.logPlanStructure(timer);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_IN_VALUES), 1);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 1);
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) IndexScanParameters(com.apple.foundationdb.record.provider.foundationdb.IndexScanParameters) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) IndexScanComparisons(com.apple.foundationdb.record.provider.foundationdb.IndexScanComparisons) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) IndexScanComparisons(com.apple.foundationdb.record.provider.foundationdb.IndexScanComparisons) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) RecordQueryIndexPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan) RecordQueryInValuesJoinPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryInValuesJoinPlan) Test(org.junit.jupiter.api.Test)

Aggregations

StoreTimer (com.apple.foundationdb.record.provider.common.StoreTimer)11 Test (org.junit.jupiter.api.Test)10 StoreTimerSnapshot (com.apple.foundationdb.record.provider.common.StoreTimerSnapshot)5 FDBStoreTimer (com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer)5 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)5 KeyValue (com.apple.foundationdb.KeyValue)2 Transaction (com.apple.foundationdb.Transaction)1 RecordCursorResult (com.apple.foundationdb.record.RecordCursorResult)1 StoreSubTimer (com.apple.foundationdb.record.provider.common.StoreSubTimer)1 IndexScanComparisons (com.apple.foundationdb.record.provider.foundationdb.IndexScanComparisons)1 IndexScanParameters (com.apple.foundationdb.record.provider.foundationdb.IndexScanParameters)1 Comparisons (com.apple.foundationdb.record.query.expressions.Comparisons)1 RecordQueryInValuesJoinPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryInValuesJoinPlan)1 RecordQueryIndexPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan)1 RecordQueryScanPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan)1