Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,23 @@ private static void assertLoadedContextReadsDoNotGrow(
final var widePrefixes = loadAllClusters(client, wide);
assertEquals(4, narrowPrefixes.size());
assertEquals(40, widePrefixes.size());
final int narrowReads = pageReads(client, narrow, narrowPrefixes);
final int wideReads = pageReads(client, wide, widePrefixes);
final int narrowReads = fewestPageReads(client, narrow, narrowPrefixes);
final int wideReads = fewestPageReads(client, wide, widePrefixes);
assertTrue(narrowReads > 0);
assertTrue(
wideReads <= narrowReads,
"Loaded context queries grew from " + narrowReads + " at 4 concepts to " + wideReads);
}

// The fewest over a few reads: one read can also pay for a one-off cache miss outside the graph
// (e.g. the reader's ownership lookup), which says nothing about how the context scales.
private static int fewestPageReads(
final OpenMetadataClient client,
final Ontology ontology,
final List<NativeOntologyLoadedPrefix> loaded) {
return IntStream.range(0, 3).map(i -> pageReads(client, ontology, loaded)).min().orElseThrow();
}

private static int pageReads(
final OpenMetadataClient client,
final Ontology ontology,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.openmetadata.it.tests.NativeOntologyGraphScanProbe.reads;
import static org.openmetadata.it.tests.NativeOntologyGraphScanProbe.fewestReads;
import static org.openmetadata.it.tests.OntologyBindingFixtures.CUSTOMER;
import static org.openmetadata.it.tests.OntologyBindingFixtures.INVOICE;
import static org.openmetadata.it.tests.OntologyBindingFixtures.ORDER;
Expand Down Expand Up @@ -308,8 +308,8 @@ void statementCountDoesNotGrowWithConceptsOrAssets(final TestNamespace ns) {
for (final var client : List.of(admin(), reader)) {
assertEquals(4, graph(client, narrow, "").getClusters().size());
assertEquals(12, graph(client, wide, "").getClusters().size());
final int narrowReads = reads(client, narrow);
final int wideReads = reads(client, wide);
final int narrowReads = fewestReads(client, narrow);
final int wideReads = fewestReads(client, wide);
log.info("Native data graph SQL reads: narrow={}, wide={}", narrowReads, wideReads);
assertTrue(narrowReads > 0, "The SQL counter must observe the graph request");
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
@Slf4j
final class NativeOntologyGraphScanProbe {
private static final int BUDGET_SAMPLES = 3;

private NativeOntologyGraphScanProbe() {}

/** Inserts {@code count} binding rows to topics that do not exist, ids ascending from after. */
Expand Down Expand Up @@ -210,6 +212,15 @@ static void assertInvisibleBindingRows(final Ontology ontology, final List<Long>
observed.assertBounded();
}

/**
* The fewest SQL statements a first-page graph read runs over a few reads. A single read can also
* pay for a one-off cache miss outside the graph (e.g. the reader's ownership lookup), which says
* nothing about how the graph scales.
*/
static int fewestReads(final OpenMetadataClient client, final Ontology ontology) {
return IntStream.range(0, BUDGET_SAMPLES).map(i -> reads(client, ontology)).min().orElseThrow();
}

/** The SQL statements one first-page graph read runs, each logged with its request. */
static int reads(final OpenMetadataClient client, final Ontology ontology) {
final var sequence = new AtomicInteger();
Expand Down
Loading