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

Use a concrete struct while parsing JSON to reduce memory consumption. #153

Merged
merged 2 commits into from
Nov 8, 2021

Conversation

calebbrown
Copy link
Contributor

The npm package json can be very large. Using the
map[string]interface{} results in the entire json data structure being
deserialized. This costs a lot of memory and cpu time.

The feed parser only needs the "time" portion of the json data, so by
restricting the struct to that data we avoid a lot of overhead.

Testing shows memory peaks close to 70Mb with this fix, rather than the
512Mb+ previously.

This helps mitigate issue #152

The npm package json can be very large. Using the
`map[string]interface{}` results in the entire json data structure being
deserialized. This costs a lot of memory and cpu time.

The feed parser only needs the "time" portion of the json data, so by
restricting the struct to that data we avoid a lot of overhead.

Testing shows memory peaks close to 70Mb with this fix, rather than the
512Mb+ previously.
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