-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.foldl over (not so) large list is causing stack overflow #169
Comments
Which version of jrsonnet do you use? |
|
Nonetheless, I'll look what can be done here. |
Making this call tailstrict I wonder if there should be forced (i.e not-lazy) object comprehension syntax for patterns like this |
Thank you for looking into it. I tried to extract the core issue from our actual code. But maybe it is not actually showing the real issue. We have quite complex jsonnet that works in go-jsonnet but was getting stack overflow in jrsonnet. I was trying to pinpoint which jsonnet code is doing that, but concluded it was just something around how many of those "mutations" we have in the list.
For me we had to actually bump
Is there a way to debug this better? |
Oh, so it happens in the real code, not this one. I am planning on finishing #121, which will solve many stack size issues. EDIT: Turns out, there is a way to grow stack in rust safely: https://docs.rs/stacker/latest/stacker/ |
Great. We will evaluate once next version is released. Thank you |
I have implemented dynamic stack growth on master, so you should not experience need to use --os-stack anymore. |
While this is not a permanent solution, this issue is resolved for now, with better solution in development. |
What happens
std.foldl
seems to be implemented internally with recursion, or otherwise causing stack overflow when iteration over large array.Additionally, memory usage grows immensely with more
foldl
countWhat is expected
std.foldl
should not cause stack overflow even with infinite arraysVerison
Context
We use "large"
foldl
to apply list of "mutations" onto list of kubernetes manifests.The example below is simplified version of our use case. We run into stack overflow issues with ~50 mutations, but our code is more complex. So to reproduce here, the number is higher than our practical use case, but not that big still.
Or code works ok with
go-jsonnet
, but reaches stack overflow injrsonnet
. If we bumpos-stack
we get it work but memory consumption of our use case gets to >30GB.How to reproduce
Run:
Result:
with
--max-stack 4096
For comparison here is
go-jsonnet
result:The text was updated successfully, but these errors were encountered: