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

Bug: Fix allocations in byte_len_cmp when node is object or array #671

Closed
HeadHunter483 opened this issue Sep 6, 2024 · 0 comments · Fixed by #672
Closed

Bug: Fix allocations in byte_len_cmp when node is object or array #671

HeadHunter483 opened this issue Sep 6, 2024 · 0 comments · Fixed by #672
Labels
bug Something isn't working

Comments

@HeadHunter483
Copy link
Collaborator

Currently there are two cases for byte_len_cmp:

  • node is not object or array - just getting length of node value as string
  • node is object or array - encoding whole node to slice of bytes and get length of encoded slice

The latter case causes allocations on every call of byte_len_cmp operation. This can lead to OOM errors because garbage collector doesn't clear these slices so often.

Replacing encoding with counting length of object or array node recursively can help significantly reduce allocations and even remove them in certain cases.

@HeadHunter483 HeadHunter483 added the bug Something isn't working label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant