Skip to content

Index weighted connection lookups - #121

Open
imrishabh18 wants to merge 2 commits into
mainfrom
agent/index-weighted-connections
Open

Index weighted connection lookups#121
imrishabh18 wants to merge 2 commits into
mainfrom
agent/index-weighted-connections

Conversation

@imrishabh18

Copy link
Copy Markdown
Member

Summary

  • build an adjacency index for explicitly weighted pad connections
  • build a set for pads that reject weak connections
  • cache the index by the immutable weighted-connections array
  • use constant-time lookups in both isStrongConnection and getStronglyConnectedPadIds
  • cover index reuse and multi-pad weighted groups with regression tests

Root cause

isStrongConnection previously scanned the entire weightedConnections array twice for every pad-pair check: once to find an explicit pair and again to determine whether either pad rejects weak connections.

Candidate generation and scoring call this function inside nested component/pad loops. On the captured large board, that repeatedly scanned 670 weighted connections across tens of thousands of candidate evaluations.

Impact

For the same 100,000-step workload in repro-large-weighted-connections.test.ts:

  • before: about 55.97 seconds
  • after: about 3.95 seconds
  • improvement: about 14× faster

The indexed run preserves the same solver state at the existing limit: 126 components packed and failed=true. Raising the parent iteration budget remains a separate change.

Validation

  • bun run typecheck
  • bun test — 127 pass, 11 pre-existing skips, 0 fail
  • focused weighted-connection tests — 7 pass, 0 fail
  • large repro benchmark — 100,000 iterations and 126 packed components in about 3.95 seconds
  • Biome formatting and git diff --check

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
calculate-packing Ready Ready Preview Aug 6, 2026 11:06am

Request Review

@imrishabh18
imrishabh18 marked this pull request as ready for review August 6, 2026 11:19
@imrishabh18
imrishabh18 requested a review from seveibar August 6, 2026 11:19
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.

1 participant