internal/core/dep: use a new visitor.marked map when recursing
Otherwise the recursing visit call will remember all the marked
nodes from the parent's visit state, causing a significant amount
of repeated work when Config.Dynamic is true without changing the result.
This is because visitor.dynamic uses the presence of leaf conjuncts
in the "marked" map to decide whether to visit a vertex,
so if the marked map is kept when recursing, the nested visitor
ends up visiting way too many vertices and repeating work.
The test case added in the previous commit now runs in about 80ms
rather than in about 7s, and the stats are much lower as well.
Fixes #2559.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I77f9a6c4ec4165eb49c685cc5656ebafce5ed9e6
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198566
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>