Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUE_EXPERIMENT=toposort Feedback #3558

Open
cuematthew opened this issue Nov 6, 2024 · 0 comments
Open

CUE_EXPERIMENT=toposort Feedback #3558

cuematthew opened this issue Nov 6, 2024 · 0 comments
Assignees

Comments

@cuematthew
Copy link
Contributor

cuematthew commented Nov 6, 2024

By running cue eval and cue export with CUE_EXPERIMENT=toposort, you enable the new "topological sorting" algorithm. This can be combined with other experimental flags, e.g. CUE_EXPERIMENT=toposort,evalv3.

The intention is that "topological sorting" should produce the same output with both versions of the evaluator, though we are aware of some minor differences at the time of writing.

It is called "topological sorting" because it creates a graph of field names and attempts to find a topological walk through that graph. For example:

x: {g: _, b: _, c: _}
y: {c: _, a: _}
z: x & y

For z, we establish a graph with the following edges:

  • g before b
  • b before c
  • c before a

From these edges, there's a simple topological walk, which guarantees the output of z will be:

{g: _, b: _, c: _, a: _}

However, cycles can exist in this graph. Consider:

x: {g: _, b: _, c: _}
y: {c: _, a: _, b: _}
z: x & y

This minor change to the original example adds in the edge a before b, thus creating a cycle in z. Our algorithm detects these cycles and attempts to find a sensible place to break such cycles, in a deterministic fashion. Currently, in this particular scenario, after reaching g, it then finds the cycle (a -> b -> c -> a) and chooses b as the entry to the cycle (which is justified because of the edge g -> b, and the fact there's no edge from g (or any predecessor of g) to any other node within the cycle), so the output of z will be {g: _, b: _, c: _, a: _}.

Please use this issue to record further feedback; surprises, undesirable behaviour etc.

@cuematthew cuematthew self-assigned this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant