Repository navigation
compiler: match recursive edge selectors against existing connections - #2979
Merged
Merged
Conversation
- sent from alixander's Codex
- sent from alixander's Codex
- sent from alixander's Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human
AI
Closes #2946.
The reported diagram has 400 SQL columns and zero connections. Four global connection styles made the compiler consider pairs of columns until it reached the edge expansion limit.
For selectors such as
(** -> **)[*]and(*** -> ***)[*], the compiler tracks which branches contain connections. Sparse diagrams scan existing edges. When there are many parallel connections between a few endpoints, probing the existing endpoint-pair index can take less work. The selector uses that index when the visible endpoint pairs fit within the cost of an edge scan. Both paths preserve match order and honor the compiler limits.Performance
The styled issue example now renders to the same SVG as the unstyled control, byte for byte. Its median CLI-reported render time was 21 ms across five runs. A second fixture exposed a regression in the first version of this PR. A leading undirected rule and 365 directed connections between two nodes had exhausted the default work limit. The revised selector compiles all 365 connections.
On an Apple M4 with Go 1.27, ten alternating samples of the full graph compiler gave these medians for two four-column SQL tables with one relationship.
One pass through all ten unmodified real-world fixtures used 8.144 MiB on the base and 8.144 MiB on this branch. Across 20 additional paired samples, median CPU time for compiling all ten was 11.64 ms on the base and 11.87 ms on this branch. Rendering all ten with Dagre took 338 ms and 333 ms respectively across eight paired samples. Both differences were within run-to-run variation. The branch index adds one pointer to each IR map and field on this architecture.
All ten unmodified fixtures produced identical Dagre SVGs across revisions. Adding a global directed-edge style to each fixture made five reach the base compiler's expansion limit. This branch rendered all ten and produced identical SVGs for the five that completed on both versions.
Testing
Ran
go test ./...,go vet ./..., andgo test -race ./d2ir ./d2compiler ./d2lib. Regression tests cover sparse schemas, column endpoints, imports, board scope, arrow direction, connection order, and parallel edges under default and custom work limits.