Skip to content

tala: route large compound diagrams within existing work limits - #2986

Merged
alixander merged 6 commits into
masterfrom
fix/tala-large-routing
Nov 20, 2026
Merged

alixander merged 6 commits into
masterfrom
fix/tala-large-routing

Conversation

@alixander

@alixander alixander commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Human


AI

Fixes #2891.

TALA now renders the public example with 40 containers and 100 arrows on all three default seeds. Each previously exhausted the 120,000,000-unit search limit. The busiest search now uses 23,116,436 units. On all three seeds, every arrow is orthogonal and clears unrelated boxes.

How it works

The same orthogonal visibility graph and Dijkstra search route every arrow. TALA keeps the original lanes between hierarchy levels when a hierarchy belongs to one container or its estimated search cost fits the budget. For expensive hierarchies that span containers, linked siblings share local lanes and cross-container arrows use the ordinary port grid and edge waypoints. The estimate uses the hierarchy’s physical extent, grid spacing, and the number of arrows. The search guard still charges actual work.

The router indexes occupied segments, clears only visited search entries between arrows, and reuses bounds during balancing. Hierarchy ordering counts crossings between adjacent levels as rank inversions. A packing check prevents moving a box onto an existing wire.

What changes in the drawings

  • 24 compact diagrams, 320 arrows. All 24 SVGs match the pre-PR SVGs byte for byte on each of the three default seeds. The earlier revision changed 37 arrows on seed 1. This restores both the two clear crossing regressions and the earlier revision’s incidental improvements. Two new fixtures check the exact routes that gained crossings.
  • 149 input and seed combinations. All rendered on the PR. Of the 126 that already rendered on the base, 121 SVGs were byte-identical. The 80-arrow variant kept all its routes and moved three boxes, clearing an existing obstruction. Four other drawings changed routes. Each produced three different base SVGs in three same-seed reruns and one repeatable SVG on the PR. Across those four pairs of renders, both endpoint boxes moved on all 202 rerouted arrows. All four drawings had fewer total crossings and bends. Individually, 38 arrows worsened on at least one of length, bends or crossings and improved on none.
  • The 90-, 180-, and 230-arrow issue variants render. A sketch with eight enclosing containers and 230 arrows peaks at 102,712,091 units on seed 1. Seven arrows in that sketch have a diagonal segment. The private diagram from the issue comment still needs a run with this build.

Existing E2E fixtures

On Apple Silicon, three paired runs over the 309 existing TALA E2E fixtures put the median time inside the 385 layout and routing calls at 11.99 s on the base and 11.98 s on the PR. Aggregate route-search work went from 396.8M to 201.6M units. Those engine timings exclude compilation and SVG rendering. The complete, unmodified ./e2etests package took a median of 73.6 s on the base and 72.0 s on the PR across two measured runs per version after warm-up, with the execution order reversed for the second pair. Individual fixtures can use more search work. The full Go suite and the TALA race suite pass.

Video and build

The walkthrough shows the public 100-arrow case. It was recorded on the earlier revision. The compact-diagram behavior introduced afterward is described above.

tala-unified-routing.mp4

Use the macOS arm64 archive from the latest PR build to try the original sketch. Download this revision’s release archives.

tar -xzf d2-v0.0.0-pr.2986-macos-arm64.tar.gz
./d2-v0.0.0-pr.2986/bin/d2 --sketch --dark-theme 104 --layout tala --timeout 300 diagram.d2 out.svg
  • sent from alixander's Codex

Build a sparse orthogonal visibility graph for expensive routes, track crossings as routes are added, and reuse segment bounds during balancing. Count crossings between adjacent ranks with inversions to keep hierarchy ordering practical on dense diagrams.

- sent from alixander's Codex
Keep the smaller public case and focused routing regressions under the race detector. Its instrumentation spends several minutes in placement for the larger nested case.

- sent from alixander's Codex
Build hierarchy lanes within the container that owns the linked siblings. Reuse the regular port grid and routing search across diagrams, index accepted segments, and keep later packing moves clear of fixed routes.

- sent from alixander's Codex
- sent from alixander's Codex
- sent from alixander's Codex
@alixander
alixander merged commit 984348b into master Nov 20, 2026
15 checks passed
@alixander
alixander deleted the fix/tala-large-routing branch November 20, 2026 02:00
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

Successfully merging this pull request may close these issues.

TALA in v0.9.0 fails with "route-search work limit exceeded" on a 120-node / 100-edge diagram that the 0.4.3 plugin laid out fine

1 participant