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());
}
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");
}
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();
}
}
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();
}
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();
}
Aggregations