From 4cacdb888b49fd309fd5d67689985dc772478e38 Mon Sep 17 00:00:00 2001 From: guhanjie Date: Fri, 21 Jul 2023 11:03:27 +0800 Subject: [PATCH] Reduce dns lookup overhead on NodeScheduler It does not need to dns lookup for hostname if HostAddress has port, which incurred additional overhead when dns too slow on some host environment. --- .../execution/scheduler/NodeScheduler.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/NodeScheduler.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/NodeScheduler.java index 0536db2c1e43..fef4831353c4 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/NodeScheduler.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/NodeScheduler.java @@ -107,17 +107,17 @@ public static List selectExactNodes(NodeMap nodeMap, List includeCoordinator || !coordinatorIds.contains(node.getNodeIdentifier())) .forEach(chosen::add); - InetAddress address; - try { - address = host.toInetAddress(); - } - catch (UnknownHostException e) { - // skip hosts that don't resolve - continue; - } - // consider a split with a host without a port as being accessible by all nodes in that host if (!host.hasPort()) { + InetAddress address; + try { + address = host.toInetAddress(); + } + catch (UnknownHostException e) { + // skip hosts that don't resolve + continue; + } + nodeMap.getNodesByHost().get(address).stream() .filter(node -> includeCoordinator || !coordinatorIds.contains(node.getNodeIdentifier())) .forEach(chosen::add); @@ -133,17 +133,17 @@ public static List selectExactNodes(NodeMap nodeMap, List