assert-json-diff
assert-json-diff copied to clipboard
avoid recursion
When comparing deep json structures, the recursion can be dangerous.
As far as I understand recursion is mainly dangerous because you risk overflowing the stack. However I think thats unlikely when diffing JSON, unless your JSON has huge levels of nestings. What do you think?
Have you seen any problems caused by the recursion or have you benchmarked it?
I have not seen any overflow, so I think we're safe here.
What I can observe on production: when we use this change + https://github.com/davidpdrsn/assert-json-diff/pull/30, then the server consumes much less memory.
Hm I wouldn't expect recursion to impact memory usage that much. Have you tried it with just https://github.com/davidpdrsn/assert-json-diff/pull/30?
Hm I wouldn't expect recursion to impact memory usage that much. Have you tried it with just #30?
No I have not. This would take some time. Do you need that?
No I have not. This would take some time. Do you need that?
Yes. I don't think we refactor the code without a good reason as the change might introduce bugs.
No I have not. This would take some time. Do you need that?
Yes. I don't think we refactor the code without a good reason as the change might introduce bugs.
OK I did the experiment. The memory usage went from 120 MB to 320 MB.
Alright. Thanks for testing it! I'll actually review the code then :)
cargo clippy
is failing for parts of the code that were not touched by this PR.
If you want, I can open a new PR for that.
I wont say no to that. Go for it! 😅
https://github.com/davidpdrsn/assert-json-diff/pull/32
@davidpdrsn The pipeline is green now.
@davidpdrsn ok for you to merge this?