3 ms·
> you can random access files within the tarball without unpacking it Kinda sorta. You still need a linear scan first and remember all the offsets, because the
by st_goliath 4y ago
> you can random access files within the tarball without unpacking it
Kinda sorta. You still need a linear scan first and remember all the offsets, because the tar format does not have an index.
> tar + xz with --block-size also allows this.
This also requires a linear scan + unpack stage first, with memorizing offsets. Remembering where the XZ blocks start (and corresponding uncompressed offsets) allows a sufficiently smart implementation to pretend that it can seek in the compressed stream, while under the hood seeking to the closest offset it has memorized and uncompressing from there. This is also alluded to in the GitHub issue you linked to.
Manually tuning down the block size allows that to be done faster, at the cost of compression.
But you still need an unpack/scan phase first. And potentially unpacking and skipping adjacent data when "randomly" accessing a file.
Technically, there is nothing stopping an implementation from doing this with gzip/zlib frames as well.
- rwmj 4y agoYou only have to scan to the start of the file you want to unpack. In many cases (we use this with Kubernetes CDI) the tarball contains only a few files with the disk image we want to access taking up the majority of the tarball, so in fact a full linear scan is not required and we're only unpacking the first few blocks.