Repository navigation
graph_close indexes the edges once, so a closure is linear in the graph instead of the reached set times the edges - #1298
Merged
Conversation
…ph instead of the reached set times the edges graph_close rescanned every edge for every node it reached. It now groups the edges by source once and walks only each reached node's own edges. The returned set gets the same members in the same insertion order, so emission is unchanged; all three callers pass string keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
graph_closerescanned the whole edge list for every node it reached, so a closure cost (nodes reached) × (edges). It now groups the edges by source once and walks only each reached node's own edges. The C emitter calls it three times per build (the lend fixpoint, live/device reachability, andforky), so large programs paid the quadratic term on every emission.The result is unchanged: the same
Setcomes back with the same members in the same insertion order (Set.prototype.forEachvisits values added during the walk, as the oldfor..ofdid). All three callers pass string keys, so map lookup matches the old===.Same output
.bendundertests/,demos/andbench/(1,626 files) with main and with this branch: the same exit status for all 1,626, the same stderr for all 1,626, and all 737 emitted.cfiles byte-identical.comp.tsis 64,000 ttok with this change (main: 63,980), at the cap, not over it.tsc -p bend2/packreports the same 12 errors as main.Speed
C emission time (
bend chain.bend -o chain.c, one run each, Apple M-series) for a chain of N defs where each calls the next:The repository's own demos are too small to show it:
app_slash_boss_3d(3.2 MB of C) emits in about 1.3 s either way, within run-to-run noise.🤖 Generated with Claude Code