Fix recursive deepJoin and flattenDeepArray traversal hangs#1041
Open
He-Pin wants to merge 1 commit into
Open
Conversation
951e137 to
972f73f
Compare
22cd3c5 to
1779389
Compare
Avoid closure-based traversal helpers in std.deepJoin/std.flattenDeepArray and use an explicit array-frame stack with direct backing-array access where available. Track active arrays by identity so recursive arrays fail deterministically with the existing max-stack style error instead of overflowing the VM stack. Use platform-specific identity sets for JVM/native and JS/WASM, and cover true lazy ConcatView traversal with a >=256-element concat case.
1779389 to
bca8902
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.
Summary
std.deepJoin/std.flattenDeepArrayarray walking with a shared iterativeDeepArrayTraversal.[std.deepJoin] max stack frames exceeded[std.flattenDeepArray] max stack frames exceededCLAUDE.md.Current head:
bca8902aa3999d78176f9999f413f731e8a56b0fPerformance Notes
ArrFrameStackis an array-backed stack and clears popped slots to avoid retaining traversed arrays.java.util.IdentityHashMap; JS/WASM use a small open-addressed identity set to avoidArrayDeque/collection overhead in the hot path.ConcatViewcase at the 256-element threshold.Verification
rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].checkFormat'rtk ./mill --no-daemon 'sjsonnet.js[2.13.18].checkFormat'rtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.FileTestsrtk ./mill --no-daemon 'sjsonnet.js[2.13.18].test' sjsonnet.FileTestsrtk ./mill --no-daemon 'sjsonnet.wasm[2.13.18].test' sjsonnet.FileTestsrtk ./mill --no-daemon 'sjsonnet.jvm[3.3.8].test' sjsonnet.StdLibOfficialCompatibilityTestsrtk ./mill --no-daemon 'sjsonnet.native[2.13.18].compile'