]> git.ipfire.org Git - thirdparty/zstd.git/commit
seekable_format: Make parallel_compression use memory properly
authorDave Vasilevsky <dave@vasilevsky.ca>
Wed, 7 May 2025 03:26:32 +0000 (23:26 -0400)
committerYann Collet <Cyan4973@users.noreply.github.com>
Thu, 8 May 2025 05:01:49 +0000 (22:01 -0700)
commit2d4cff69c439d40b2bb39300f003522da8f2c6ab
tree0f62eb409ca95b73581cd93ed1c33918114cdaef
parentf5b6531902a8e12b679b10ea748aa55ac0d40d66
seekable_format: Make parallel_compression use memory properly

Previously, parallel_compression would only handle each job's results
after ALL jobs were successfully queued. This caused all src/dst
buffers to remain in memory until then!

It also polled to check whether a job completed, which is racy without
any memory barrier.

Now, we flush results as a side effect of completing a job. Completed
frames are placed in an ordered linked-list, and any eligible frames
are flushed. This may be zero or multiple frames, depending on the
order in which jobs finish.

This design also makes it simple to support streaming input, so that
is now available. Just pass `-` as the filename, and stdin/stdout will
be used for I/O.
contrib/seekable_format/examples/parallel_compression.c