Perf T2-8: Single-pass all_variables#147
Open
hmzh-khn wants to merge 3 commits into
Open
Conversation
Tests verify that all_variables is the correct flat concatenation of zs, λs, and μs in player order, for both hierarchical (with μs) and Nash (without μs) game structures. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace nested vcat operations with pre-allocated vector and copyto! calls. Computes total length upfront, allocates once, then copies zs, λs, and μs segments sequentially. Eliminates intermediate array allocations from vcat splatting. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Summary
Replace nested
vcat(vcat([zs[i] for i in 1:N]...), vcat([λs[i] for i in 1:N]...), ...)with a pre-allocated vector andcopyto!calls for single-pass assembly.Changes
src/problem_setup.jl: Replace nested vcat splatting with pre-allocatedVector(undef, total_len)andcopyto!filltest/: Add tests verifying symbolic equality of all_variables for chain and Nash topologiesBenchmark Results
Known Issue (pre-existing)
The μs section iterates
values(μs)on a Dict, which has non-deterministic ordering in Julia. This is a pre-existing issue from the original code — this PR preserves the same iteration pattern. Ifall_variablesordering needs to be canonical, a follow-up should sort the μs keys. The test validates against the samevalues()call so it always passes within a single run.Testing
isequalfor 3-player chain (with μs) and 2-player Nash (without μs)Changelog
🤖 Generated with Claude Code