It turns out that the change in
CALCITE-3713 added an extra overhead of 20~30% HepPlanner. The hash map lookup in belongsToDag becomes much slower due to expensive computation of the hashcode and equals for the list.
A simple profiling of the planner before and after
CALCITE-3713 is shown below.
To test whether or not a vertex belongs to DAG, we can simply do graph.vertexSet().contains(vertex); There's no need to look up in mapDigestToVertex map, which incurs overhead of creating the map key. This problem was amplified by