Search in sources :

Example 6 with SpillSpaceTracker

use of com.facebook.presto.spiller.SpillSpaceTracker in project presto by prestodb.

the class TestSqlTask method createInitialTask.

public SqlTask createInitialTask() {
    TaskId taskId = new TaskId("query", 0, 0, nextTaskId.incrementAndGet());
    URI location = URI.create("fake://task/" + taskId);
    QueryContext queryContext = new QueryContext(new QueryId("query"), new DataSize(1, MEGABYTE), new DataSize(2, MEGABYTE), new DataSize(1, MEGABYTE), new DataSize(1, GIGABYTE), new MemoryPool(new MemoryPoolId("test"), new DataSize(1, GIGABYTE)), new TestingGcMonitor(), taskNotificationExecutor, driverYieldExecutor, new DataSize(1, MEGABYTE), new SpillSpaceTracker(new DataSize(1, GIGABYTE)), listJsonCodec(TaskMemoryReservationSummary.class));
    queryContext.addTaskContext(new TaskStateMachine(taskId, taskNotificationExecutor), testSessionBuilder().build(), Optional.of(PLAN_FRAGMENT.getRoot()), false, false, false, false, false);
    return createSqlTask(taskId, location, "fake", queryContext, sqlTaskExecutionFactory, new MockExchangeClientSupplier(), taskNotificationExecutor, Functions.identity(), new DataSize(32, MEGABYTE), new CounterStat(), new SpoolingOutputBufferFactory(new FeaturesConfig()));
}
Also used : TaskMemoryReservationSummary(com.facebook.presto.operator.TaskMemoryReservationSummary) SpillSpaceTracker(com.facebook.presto.spiller.SpillSpaceTracker) MockExchangeClientSupplier(com.facebook.presto.execution.TestSqlTaskManager.MockExchangeClientSupplier) CounterStat(com.facebook.airlift.stats.CounterStat) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) QueryId(com.facebook.presto.spi.QueryId) QueryContext(com.facebook.presto.memory.QueryContext) URI(java.net.URI) DataSize(io.airlift.units.DataSize) TestingGcMonitor(com.facebook.airlift.stats.TestingGcMonitor) SpoolingOutputBufferFactory(com.facebook.presto.execution.buffer.SpoolingOutputBufferFactory) MemoryPoolId(com.facebook.presto.spi.memory.MemoryPoolId) MemoryPool(com.facebook.presto.memory.MemoryPool)

Example 7 with SpillSpaceTracker

use of com.facebook.presto.spiller.SpillSpaceTracker in project presto by prestodb.

the class AbstractOperatorBenchmark method runOnce.

@Override
protected Map<String, Long> runOnce() {
    Session session = testSessionBuilder().setSystemProperty("optimizer.optimize-hash-generation", "true").build();
    MemoryPool memoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(1, GIGABYTE));
    SpillSpaceTracker spillSpaceTracker = new SpillSpaceTracker(new DataSize(1, GIGABYTE));
    TaskContext taskContext = new QueryContext(new QueryId("test"), new DataSize(256, MEGABYTE), new DataSize(512, MEGABYTE), new DataSize(256, MEGABYTE), new DataSize(1, GIGABYTE), memoryPool, new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), new DataSize(256, MEGABYTE), spillSpaceTracker, listJsonCodec(TaskMemoryReservationSummary.class)).addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0, 0), localQueryRunner.getExecutor()), session, Optional.empty(), false, false, false, 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.getRawInputDataSizeInBytes();
    long outputRows = taskStats.getOutputPositions();
    long outputBytes = taskStats.getOutputDataSizeInBytes();
    double inputMegaBytes = new DataSize(inputBytes, BYTE).getValue(MEGABYTE);
    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).build();
}
Also used : SpillSpaceTracker(com.facebook.presto.spiller.SpillSpaceTracker) TaskContext(com.facebook.presto.operator.TaskContext) TaskId(com.facebook.presto.execution.TaskId) QueryId(com.facebook.presto.spi.QueryId) QueryContext(com.facebook.presto.memory.QueryContext) TaskStats(com.facebook.presto.operator.TaskStats) TaskStateMachine(com.facebook.presto.execution.TaskStateMachine) DataSize(io.airlift.units.DataSize) TestingGcMonitor(com.facebook.airlift.stats.TestingGcMonitor) CpuTimer(com.facebook.airlift.stats.CpuTimer) CpuDuration(com.facebook.airlift.stats.CpuTimer.CpuDuration) MemoryPoolId(com.facebook.presto.spi.memory.MemoryPoolId) Session(com.facebook.presto.Session) MemoryPool(com.facebook.presto.memory.MemoryPool)

Example 8 with SpillSpaceTracker

use of com.facebook.presto.spiller.SpillSpaceTracker in project presto by prestodb.

the class TestQueryContext method testSetMemoryPool.

@Test(dataProvider = "testSetMemoryPoolOptions")
public void testSetMemoryPool(boolean useReservedPool) {
    QueryId secondQuery = new QueryId("second");
    MemoryPool reservedPool = new MemoryPool(RESERVED_POOL, new DataSize(10, BYTE));
    long secondQueryMemory = reservedPool.getMaxBytes() - 1;
    if (useReservedPool) {
        assertTrue(reservedPool.reserve(secondQuery, "test", secondQueryMemory).isDone());
    }
    try (LocalQueryRunner localQueryRunner = new LocalQueryRunner(TEST_SESSION)) {
        QueryContext queryContext = new QueryContext(new QueryId("query"), new DataSize(10, BYTE), new DataSize(20, BYTE), new DataSize(10, BYTE), new DataSize(1, GIGABYTE), new MemoryPool(GENERAL_POOL, new DataSize(10, BYTE)), new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), new DataSize(0, BYTE), new SpillSpaceTracker(new DataSize(0, BYTE)), listJsonCodec(TaskMemoryReservationSummary.class));
        // 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());
        queryContext.setMemoryPool(reservedPool);
        if (useReservedPool) {
            reservedPool.free(secondQuery, "test", secondQueryMemory);
        }
        // Free memory
        userMemoryContext.close();
        revocableMemoryContext.close();
    }
}
Also used : TaskMemoryReservationSummary(com.facebook.presto.operator.TaskMemoryReservationSummary) LocalMemoryContext(com.facebook.presto.memory.context.LocalMemoryContext) SpillSpaceTracker(com.facebook.presto.spiller.SpillSpaceTracker) QueryId(com.facebook.presto.spi.QueryId) DataSize(io.airlift.units.DataSize) TestingGcMonitor(com.facebook.airlift.stats.TestingGcMonitor) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Test(org.testng.annotations.Test)

Aggregations

TestingGcMonitor (com.facebook.airlift.stats.TestingGcMonitor)8 SpillSpaceTracker (com.facebook.presto.spiller.SpillSpaceTracker)8 DataSize (io.airlift.units.DataSize)8 QueryId (com.facebook.presto.spi.QueryId)7 MemoryPoolId (com.facebook.presto.spi.memory.MemoryPoolId)6 MemoryPool (com.facebook.presto.memory.MemoryPool)5 QueryContext (com.facebook.presto.memory.QueryContext)5 TaskMemoryReservationSummary (com.facebook.presto.operator.TaskMemoryReservationSummary)5 Session (com.facebook.presto.Session)4 TaskId (com.facebook.presto.execution.TaskId)3 TaskStateMachine (com.facebook.presto.execution.TaskStateMachine)3 TaskContext (com.facebook.presto.operator.TaskContext)3 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)3 Page (com.facebook.presto.common.Page)2 LocalMemoryContext (com.facebook.presto.memory.context.LocalMemoryContext)2 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 List (java.util.List)2 JsonCodec.listJsonCodec (com.facebook.airlift.json.JsonCodec.listJsonCodec)1