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

stream reading features #206

Merged
merged 1 commit into from
Sep 6, 2022
Merged

Conversation

michaelkirk
Copy link
Member

@michaelkirk michaelkirk commented Sep 2, 2022

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

This greatly reduces the peak memory usage needed to parse a GeoJSON FeatureCollection by utilizing the FeatureIterator's trick of seeking to the "features": [ array without actually parsing the FeatureCollection. Note there are some robustness issues with this approach, some of which can be improved, but overall I think it's worth the trade-off.

There is a small (0-1%) CPU regression in our deserialization bench due to this change, but the peak memory profile of the stream_reader_writer examples decreased 90% - from 2.22MiB to 237Kib.

Before:
Screen Shot 2022-09-02 at 2 42 04 PM

After:
Screen Shot 2022-09-02 at 2 40 29 PM

Notice that overall memory allocations stayed the same (see #88 (comment)), but the peak usage is much lower since we never hold the entire data structure in memory at once.

Copy link
Member

@frewsxcv frewsxcv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍 😍 😍 😍 😍 😍 😍

Can't wait to test this out on rgis

@michaelkirk
Copy link
Member Author

bors r=frewsxcv

Can't wait to test this out on rgis

I'd be curious to hear if it helps any! With rgis I assume you're ultimately holding the entire feature collection in memory anyway, so it might not be a huge win.

Though it does seem like geojson's in-memory geometry representations are particularly inefficient, so it could help a bit!

@bors
Copy link
Contributor

bors bot commented Sep 6, 2022

Build succeeded:

@bors bors bot merged commit 2f8ca02 into georust:master Sep 6, 2022
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