Search in sources :

Example 1 with TaskMemoryInfo

use of io.trino.TaskMemoryInfo in project trino by trinodb.

the class TotalReservationOnBlockedNodesLowMemoryKiller method chooseTasksToKill.

private Optional<KillTarget> chooseTasksToKill(List<MemoryInfo> nodes) {
    ImmutableSet.Builder<TaskId> tasksToKillBuilder = ImmutableSet.builder();
    for (MemoryInfo node : nodes) {
        MemoryPoolInfo memoryPool = node.getPool();
        if (memoryPool == null) {
            continue;
        }
        if (memoryPool.getFreeBytes() + memoryPool.getReservedRevocableBytes() > 0) {
            continue;
        }
        node.getTasksMemoryInfo().values().stream().max(comparing(TaskMemoryInfo::getMemoryReservation)).map(TaskMemoryInfo::getTaskId).ifPresent(tasksToKillBuilder::add);
    }
    Set<TaskId> tasksToKill = tasksToKillBuilder.build();
    if (tasksToKill.isEmpty()) {
        return Optional.empty();
    }
    return Optional.of(KillTarget.selectedTasks(tasksToKill));
}
Also used : TaskMemoryInfo(io.trino.TaskMemoryInfo) TaskId(io.trino.execution.TaskId) ImmutableSet(com.google.common.collect.ImmutableSet) MemoryPoolInfo(io.trino.spi.memory.MemoryPoolInfo)

Example 2 with TaskMemoryInfo

use of io.trino.TaskMemoryInfo in project trino by trinodb.

the class LowMemoryKillerTestingUtils method tasksMemoryInfoForNode.

private static ListMultimap<QueryId, TaskMemoryInfo> tasksMemoryInfoForNode(String nodeIdentifier, Map<String, Map<String, Map<String, Long>>> tasks) {
    ImmutableListMultimap.Builder<QueryId, TaskMemoryInfo> result = ImmutableListMultimap.builder();
    for (Map.Entry<String, Map<String, Map<String, Long>>> queryNodesEntry : tasks.entrySet()) {
        QueryId query = QueryId.valueOf(queryNodesEntry.getKey());
        for (Map.Entry<String, Map<String, Long>> nodeTasksEntry : queryNodesEntry.getValue().entrySet()) {
            if (!nodeIdentifier.equals(nodeTasksEntry.getKey())) {
                continue;
            }
            for (Map.Entry<String, Long> taskReservationEntry : nodeTasksEntry.getValue().entrySet()) {
                TaskId taskId = TaskId.valueOf(taskReservationEntry.getKey());
                long taskReservation = taskReservationEntry.getValue();
                result.put(query, new TaskMemoryInfo(taskId, taskReservation));
            }
        }
    }
    return result.build();
}
Also used : TaskId(io.trino.execution.TaskId) QueryId(io.trino.spi.QueryId) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) TaskMemoryInfo(io.trino.TaskMemoryInfo) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

TaskMemoryInfo (io.trino.TaskMemoryInfo)2 TaskId (io.trino.execution.TaskId)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 QueryId (io.trino.spi.QueryId)1 MemoryPoolInfo (io.trino.spi.memory.MemoryPoolInfo)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1