GraphType cached derived fields + plain-Python graph-op hot paths - #89
Open
yinoneliraz wants to merge 1 commit into
Open
yinoneliraz wants to merge 1 commit into
yinoneliraz wants to merge 1 commit into
Conversation
- ComputationEdge: cache computed_hash (edges are hashed on every frozenset build/lookup; fields are immutable). - GraphType: lazily cached derived fields — nodes, node_to_incoming_edges, node_to_forward_neighbors — plus seed_nodes() so transformations that know the node-set delta (merge_graphs, replace_nodes, replace_source) propagate the cache in O(delta) instead of forcing an O(E) rescan. - make_computation_node: memoize by callable, skipping repeated inspect.signature work. - replace_source / replace_destination: single-pass plain loops instead of 4 gamla-combinator passes over the edges. - merge_graphs, make_first/make_and/make_or, _make_compose_inner, _infer_composition_edges: plain-Python hot paths (kills per-edge curried closures and hidden iscoroutinefunction checks); unbound signature computed once per candidate node using the cached incoming-edges field. - duplication: use cached nodes/forward-neighbors fields. Benchmark (bot-building-shaped workload, 4498 edges, 200 replaces): 3141ms -> 677ms total; replace_source 2534ms -> 289ms. All 102 tests pass; canonical graph shapes identical to master. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
yinoneliraz
force-pushed
the
yinon/graphtype-cached-fields
branch
from
July 12, 2026 09:50
5ee8c4b to
0b9d8ce
Compare
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.
Benchmark (bot-building-shaped workload, 4498 edges, 200 replaces): 3141ms -> 677ms total; replace_source 2534ms -> 289ms. All 102 tests pass; canonical graph shapes identical to master.