Skip to content
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

avoid recursion #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

avoid recursion #31

wants to merge 2 commits into from

Conversation

yanns
Copy link
Contributor

@yanns yanns commented Jun 29, 2022

When comparing deep json structures, the recursion can be dangerous.

@davidpdrsn
Copy link
Owner

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?

@yanns
Copy link
Contributor Author

yanns commented Jun 30, 2022

I have not seen any overflow, so I think we're safe here.

What I can observe on production: when we use this change + #30, then the server consumes much less memory.

@davidpdrsn
Copy link
Owner

Hm I wouldn't expect recursion to impact memory usage that much. Have you tried it with just #30?

@yanns
Copy link
Contributor Author

yanns commented Jun 30, 2022

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?

@davidpdrsn
Copy link
Owner

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.

@yanns
Copy link
Contributor Author

yanns commented Jun 30, 2022

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.

@davidpdrsn
Copy link
Owner

Alright. Thanks for testing it! I'll actually review the code then :)

@yanns
Copy link
Contributor Author

yanns commented Jun 30, 2022

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.

@davidpdrsn
Copy link
Owner

I wont say no to that. Go for it! 😅

@yanns
Copy link
Contributor Author

yanns commented Jun 30, 2022

#32

@yanns
Copy link
Contributor Author

yanns commented Aug 24, 2022

@davidpdrsn The pipeline is green now.

@yanns
Copy link
Contributor Author

yanns commented Sep 5, 2022

@davidpdrsn ok for you to merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants