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 ZSTD's streaming interface for compressing files #543

Merged
merged 6 commits into from
Jan 29, 2021

Conversation

pjreed
Copy link
Contributor

@pjreed pjreed commented Oct 20, 2020

This uses ZSTD's streaming compression interface when compressing files, which will significantly reduce memory usage since it no longer needs to read in the entire file at once.

One significant caveat to note about this is that the previous version of the code had a check to verify that the size of the decompressed output matched the size recorded in the compression header for the file. ZSTD's streaming interface does not record the decompressed size in its frame header (it cannot, since it does not know the size ahead of time); this means that compressed bag files recorded with the streaming interface cannot be played by older versions of rosbag2 since they will be missing that bit of information in their headers, and that will throw an exception.

Fixes #295.

Distribution Statement A; OPSEC #4584

Distro A, OPSEC #4584

Signed-off-by: P. J. Reed <preed@swri.org>
Signed-off-by: P. J. Reed <preed@swri.org>
@pjreed pjreed force-pushed the 295/use-streaming-compression branch from e4c99b2 to 2491207 Compare December 9, 2020 16:05
@emersonknapp emersonknapp self-requested a review December 18, 2020 17:05
@pjreed
Copy link
Contributor Author

pjreed commented Jan 15, 2021

Seems like a test failed after merging in the latest master, I'll investigate...

@pjreed
Copy link
Contributor Author

pjreed commented Jan 15, 2021

I'm actually not sure why that test failed -- I don't think this change would have affected it -- and everything passes for me in my environment. @emersonknapp , any ideas?

@emersonknapp
Copy link
Collaborator

emersonknapp commented Jan 21, 2021

The output suggests that the failing test is happening with CycloneDDS - are you also using cyclone locally, or running with FastDDS?

Edit: I just tried out the test locally and I happened to be using fastrtps, but when using cyclone it fails - looking in to it

@emersonknapp
Copy link
Collaborator

BTW if you update your branch - the test problem should be resolved - let me know when you feel ready for a review here

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

Thanks for your patience on this - the code looks fine. I'd like it if some of the common setup and shutdown could be deduplicated, perhaps as some utility function that sets up the ifstream/ofstream for you. But that's minor, I won't block the review on that, pursue it if you like.

I think you're fine to take this out of draft (and it will need a rebase) - and let's make sure the tests are passing, then we can go ahead and merge.

@pjreed pjreed marked this pull request as ready for review January 28, 2021 22:28
@pjreed pjreed requested a review from a team as a code owner January 28, 2021 22:28
@pjreed pjreed requested review from jikawa-az and removed request for a team January 28, 2021 22:28
@pjreed
Copy link
Contributor Author

pjreed commented Jan 28, 2021

I would also like to see the code around the compressor/decompressor setup/shutdown look a little cleaner, but I've been staring at it a while and they're just different enough that I haven't thought of a good way to do so.

Anyway, I've merged master into this and all of the tests pass for me; I was previously using FastRTPS, but switched to CycloneDDS, and everything still builds & runs fine for me. Not sure why the CI build would have a problem with it...

@emersonknapp
Copy link
Collaborator

Not sure why the CI build would have a problem with it...

The important one works - the Rpr__rosbag2__ubuntu_focal_amd64 is nice in theory but unreliable in practice in my experience, for a couple reasons

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

LGTM minus dangling unrelated changes - once that's fixed I'll kick off the ci.ros2.org build

pjreed and others added 2 commits January 29, 2021 08:46
…sion_writer.cpp

Co-authored-by: Emerson Knapp <537409+emersonknapp@users.noreply.github.com>
Signed-off-by: P. J. Reed <phillipreed@hatchbed.com>
…sion_writer.cpp

Co-authored-by: Emerson Knapp <537409+emersonknapp@users.noreply.github.com>
Signed-off-by: P. J. Reed <phillipreed@hatchbed.com>
@pjreed pjreed force-pushed the 295/use-streaming-compression branch from adb30b9 to 1d04628 Compare January 29, 2021 14:46
@pjreed
Copy link
Contributor Author

pjreed commented Jan 29, 2021

Tests still build & run for me without any failures; is there a way to make just that one run again?

@emersonknapp
Copy link
Collaborator

Gist: https://gist.githubusercontent.com/emersonknapp/6320545b1692e39a982c128f44c559bc/raw/6eb426aa03b3283fa5051a2398d609df9a203d0c/ros2.repos
BUILD args: --packages-up-to rosbag2_compression rosbag2_tests
TEST args: --packages-select rosbag2_compression rosbag2_tests
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/7554

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@emersonknapp emersonknapp merged commit 33e62f3 into ros2:master Jan 29, 2021
emersonknapp pushed a commit that referenced this pull request Feb 2, 2021
* Implement streaming compression/decompression

Distro A, OPSEC #4584

Signed-off-by: P. J. Reed <preed@swri.org>
emersonknapp pushed a commit that referenced this pull request Feb 17, 2021
* Implement streaming compression/decompression

Distro A, OPSEC #4584

Signed-off-by: P. J. Reed <preed@swri.org>
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.

Use streaming for compression
2 participants