use of com.facebook.presto.memory.MemoryPool in project presto by prestodb.
the class TestMemoryRevokingScheduler method testQueryMemoryNotRevokedWhenNotEnabled.
@Test
public void testQueryMemoryNotRevokedWhenNotEnabled() throws Exception {
// The various tasks created here use a small amount of system memory independent of what's set explicitly
// in this test. Triggering spilling based on differences of thousands of bytes rather than hundreds
// makes the test resilient to any noise that creates.
QueryId queryId = new QueryId("query");
// use a larger memory pool so that we don't trigger spilling due to filling the memory pool
MemoryPool queryLimitMemoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(100, GIGABYTE));
SqlTask sqlTask1 = newSqlTask(queryId, queryLimitMemoryPool);
TestOperatorContext operatorContext11 = createTestingOperatorContexts(sqlTask1, "operator11");
allOperatorContexts = ImmutableSet.of(operatorContext11);
List<SqlTask> tasks = ImmutableList.of(sqlTask1);
MemoryRevokingScheduler scheduler = new MemoryRevokingScheduler(singletonList(queryLimitMemoryPool), () -> tasks, queryContexts::get, 1.0, 1.0, ORDER_BY_REVOCABLE_BYTES, false);
try {
scheduler.start();
assertMemoryRevokingNotRequested();
// exceed the query memory limit of 500KB
operatorContext11.localRevocableMemoryContext().setBytes(600_000);
scheduler.awaitAsynchronousCallbacksRun();
assertMemoryRevokingNotRequested();
} finally {
scheduler.stop();
}
}
use of com.facebook.presto.memory.MemoryPool in project presto by prestodb.
the class TestMemoryRevokingScheduler method testCountAlreadyRevokedMemoryWithinAPool.
@Test
public void testCountAlreadyRevokedMemoryWithinAPool() throws Exception {
// Given
MemoryPool anotherMemoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(10, BYTE));
SqlTask sqlTask1 = newSqlTask(new QueryId("q1"), anotherMemoryPool);
OperatorContext operatorContext1 = createContexts(sqlTask1);
SqlTask sqlTask2 = newSqlTask(new QueryId("q2"), memoryPool);
OperatorContext operatorContext2 = createContexts(sqlTask2);
List<SqlTask> tasks = ImmutableList.of(sqlTask1, sqlTask2);
MemoryRevokingScheduler scheduler = new MemoryRevokingScheduler(asList(memoryPool, anotherMemoryPool), () -> tasks, queryContexts::get, 1.0, 1.0, ORDER_BY_CREATE_TIME, false);
try {
scheduler.start();
allOperatorContexts = ImmutableSet.of(operatorContext1, operatorContext2);
/*
* sqlTask1 fills its pool
*/
operatorContext1.localRevocableMemoryContext().setBytes(12);
scheduler.awaitAsynchronousCallbacksRun();
assertMemoryRevokingRequestedFor(operatorContext1);
/*
* When sqlTask2 fills its pool
*/
operatorContext2.localRevocableMemoryContext().setBytes(12);
scheduler.awaitAsynchronousCallbacksRun();
/*
* Then sqlTask2 should be asked to revoke its memory too
*/
assertMemoryRevokingRequestedFor(operatorContext1, operatorContext2);
} finally {
scheduler.stop();
}
}
Aggregations