Search in sources :

Example 11 with TestingGcMonitor

use of io.airlift.stats.TestingGcMonitor in project hetu-core by openlookeng.

the class TestMemoryRevokingScheduler method newSqlTask.

private SqlTask newSqlTask() {
    TaskId taskId = new TaskId("query", 0, idGeneator.incrementAndGet());
    String instanceId = "Testing instance id";
    URI location = URI.create("fake://task/" + taskId);
    return createSqlTask(taskId, instanceId, location, "fake", new QueryContext(new QueryId("query"), new DataSize(1, MEGABYTE), new DataSize(2, MEGABYTE), memoryPool, new TestingGcMonitor(), executor, scheduledExecutor, new DataSize(1, GIGABYTE), spillSpaceTracker, NOOP_SNAPSHOT_UTILS), sqlTaskExecutionFactory, executor, Functions.identity(), new DataSize(32, MEGABYTE), new CounterStat(), createTestMetadataManager());
}
Also used : CounterStat(io.airlift.stats.CounterStat) QueryId(io.prestosql.spi.QueryId) DataSize(io.airlift.units.DataSize) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) QueryContext(io.prestosql.memory.QueryContext) URI(java.net.URI)

Example 12 with TestingGcMonitor

use of io.airlift.stats.TestingGcMonitor in project trino by trinodb.

the class TestMemoryTracking method setUpTest.

@BeforeMethod
public void setUpTest() {
    memoryPool = new MemoryPool(memoryPoolSize);
    queryContext = new QueryContext(new QueryId("test_query"), queryMaxMemory, memoryPool, new TestingGcMonitor(), notificationExecutor, yieldExecutor, queryMaxSpillSize, spillSpaceTracker);
    taskContext = queryContext.addTaskContext(new TaskStateMachine(new TaskId(new StageId("query", 0), 0, 0), notificationExecutor), testSessionBuilder().build(), () -> {
    }, true, true);
    pipelineContext = taskContext.addPipelineContext(0, true, true, false);
    driverContext = pipelineContext.addDriverContext();
    operatorContext = driverContext.addOperatorContext(1, new PlanNodeId("a"), "test-operator");
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) TaskId(io.trino.execution.TaskId) QueryId(io.trino.spi.QueryId) StageId(io.trino.execution.StageId) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) TaskStateMachine(io.trino.execution.TaskStateMachine) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 13 with TestingGcMonitor

use of io.airlift.stats.TestingGcMonitor in project trino by trinodb.

the class TestQueryContext method testSetMemoryPool.

@Test
public void testSetMemoryPool() {
    try (LocalQueryRunner localQueryRunner = LocalQueryRunner.create(TEST_SESSION)) {
        QueryContext queryContext = new QueryContext(new QueryId("query"), DataSize.ofBytes(10), new MemoryPool(DataSize.ofBytes(10)), new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), DataSize.ofBytes(0), new SpillSpaceTracker(DataSize.ofBytes(0)));
        // Use memory
        queryContext.getQueryMemoryContext().initializeLocalMemoryContexts("test");
        LocalMemoryContext userMemoryContext = queryContext.getQueryMemoryContext().localUserMemoryContext();
        LocalMemoryContext revocableMemoryContext = queryContext.getQueryMemoryContext().localRevocableMemoryContext();
        assertTrue(userMemoryContext.setBytes(3).isDone());
        assertTrue(revocableMemoryContext.setBytes(5).isDone());
        // Free memory
        userMemoryContext.close();
        revocableMemoryContext.close();
    }
}
Also used : LocalMemoryContext(io.trino.memory.context.LocalMemoryContext) SpillSpaceTracker(io.trino.spiller.SpillSpaceTracker) QueryId(io.trino.spi.QueryId) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Test(org.testng.annotations.Test)

Example 14 with TestingGcMonitor

use of io.airlift.stats.TestingGcMonitor in project trino by trinodb.

the class TestMemoryPools method setUp.

private void setUp(Supplier<List<Driver>> driversSupplier) {
    checkState(localQueryRunner == null, "Already set up");
    Session session = testSessionBuilder().setCatalog("tpch").setSchema("tiny").setSystemProperty("task_default_concurrency", "1").build();
    localQueryRunner = LocalQueryRunner.builder(session).withInitialTransaction().build();
    // add tpch
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    userPool = new MemoryPool(TEN_MEGABYTES);
    fakeQueryId = new QueryId("fake");
    SpillSpaceTracker spillSpaceTracker = new SpillSpaceTracker(DataSize.of(1, GIGABYTE));
    QueryContext queryContext = new QueryContext(new QueryId("query"), TEN_MEGABYTES, userPool, new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), TEN_MEGABYTES, spillSpaceTracker);
    taskContext = createTaskContext(queryContext, localQueryRunner.getExecutor(), localQueryRunner.getDefaultSession());
    drivers = driversSupplier.get();
}
Also used : TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) SpillSpaceTracker(io.trino.spiller.SpillSpaceTracker) QueryId(io.trino.spi.QueryId) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) Session(io.trino.Session)

Example 15 with TestingGcMonitor

use of io.airlift.stats.TestingGcMonitor in project trino by trinodb.

the class AbstractOperatorBenchmark method runOnce.

@Override
protected Map<String, Long> runOnce() {
    Session session = testSessionBuilder().setSystemProperty("optimizer.optimize-hash-generation", "true").setTransactionId(this.session.getRequiredTransactionId()).build();
    MemoryPool memoryPool = new MemoryPool(DataSize.of(1, GIGABYTE));
    SpillSpaceTracker spillSpaceTracker = new SpillSpaceTracker(DataSize.of(1, GIGABYTE));
    TaskContext taskContext = new QueryContext(new QueryId("test"), DataSize.of(256, MEGABYTE), memoryPool, new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), DataSize.of(256, MEGABYTE), spillSpaceTracker).addTaskContext(new TaskStateMachine(new TaskId(new StageId("query", 0), 0, 0), localQueryRunner.getExecutor()), session, () -> {
    }, false, false);
    CpuTimer cpuTimer = new CpuTimer();
    Map<String, Long> executionStats = execute(taskContext);
    CpuDuration executionTime = cpuTimer.elapsedTime();
    TaskStats taskStats = taskContext.getTaskStats();
    long inputRows = taskStats.getRawInputPositions();
    long inputBytes = taskStats.getRawInputDataSize().toBytes();
    long outputRows = taskStats.getOutputPositions();
    long outputBytes = taskStats.getOutputDataSize().toBytes();
    double inputMegaBytes = ((double) inputBytes) / MEGABYTE.inBytes();
    return ImmutableMap.<String, Long>builder().putAll(executionStats).put("elapsed_millis", executionTime.getWall().toMillis()).put("input_rows_per_second", (long) (inputRows / executionTime.getWall().getValue(SECONDS))).put("output_rows_per_second", (long) (outputRows / executionTime.getWall().getValue(SECONDS))).put("input_megabytes", (long) inputMegaBytes).put("input_megabytes_per_second", (long) (inputMegaBytes / executionTime.getWall().getValue(SECONDS))).put("wall_nanos", executionTime.getWall().roundTo(NANOSECONDS)).put("cpu_nanos", executionTime.getCpu().roundTo(NANOSECONDS)).put("user_nanos", executionTime.getUser().roundTo(NANOSECONDS)).put("input_rows", inputRows).put("input_bytes", inputBytes).put("output_rows", outputRows).put("output_bytes", outputBytes).buildOrThrow();
}
Also used : SpillSpaceTracker(io.trino.spiller.SpillSpaceTracker) TaskContext(io.trino.operator.TaskContext) TaskId(io.trino.execution.TaskId) QueryId(io.trino.spi.QueryId) StageId(io.trino.execution.StageId) QueryContext(io.trino.memory.QueryContext) TaskStats(io.trino.operator.TaskStats) TaskStateMachine(io.trino.execution.TaskStateMachine) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) CpuTimer(io.airlift.stats.CpuTimer) CpuDuration(io.airlift.stats.CpuTimer.CpuDuration) Session(io.trino.Session) MemoryPool(io.trino.memory.MemoryPool)

Aggregations

TestingGcMonitor (io.airlift.stats.TestingGcMonitor)16 DataSize (io.airlift.units.DataSize)9 QueryId (io.prestosql.spi.QueryId)9 MemoryPoolId (io.prestosql.spi.memory.MemoryPoolId)7 SpillSpaceTracker (io.prestosql.spiller.SpillSpaceTracker)7 QueryId (io.trino.spi.QueryId)7 QueryContext (io.prestosql.memory.QueryContext)6 SpillSpaceTracker (io.trino.spiller.SpillSpaceTracker)6 MemoryPool (io.prestosql.memory.MemoryPool)5 TaskId (io.prestosql.execution.TaskId)4 TaskStateMachine (io.prestosql.execution.TaskStateMachine)4 MemoryPool (io.trino.memory.MemoryPool)4 QueryContext (io.trino.memory.QueryContext)4 CounterStat (io.airlift.stats.CounterStat)3 Session (io.prestosql.Session)3 TaskContext (io.prestosql.operator.TaskContext)3 Session (io.trino.Session)3 StageId (io.trino.execution.StageId)3 TaskId (io.trino.execution.TaskId)3 TaskStateMachine (io.trino.execution.TaskStateMachine)3