Repository navigation
Faster directory archives: gzip level 1 default and optional zstd - #52
Merged
Merged
Conversation
Directory archives written by `put()` used tarfile's default gzip level 9 on
a single core. On a 12.4 GB Oasis inputs directory that took 369 s locally
(~23 min on Fargate) for a 7.9x ratio; level 1 takes 32 s for 7.1x.
- Default gzip compresslevel is now 1 (configurable via `archive_compresslevel`)
- New `archive_compression` option ('gz' or 'zst') and per call
`put(..., compression=...)` override; zstd is multi-threaded
(`archive_threads`, -1 for every core) via the stdlib `compression.zstd`
on Python 3.14+ or the `zstandard` package (new `[zstd]` extra)
- `extract()` detects zstd archives by magic bytes
- Archive options are kept by `to_config()`
- New `archive_suffix()` returns the extension for the configured format
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sambles
requested review from
SkylordA and
vinulw
and removed request for
SkylordA
October 22, 2026 10:31
vinulw
approved these changes
Oct 22, 2026
vinulw
left a comment
Contributor
There was a problem hiding this comment.
Some minor comments but fine to approve as is.
| from fsspec.implementations.dirfs import DirFileSystem | ||
|
|
||
| from oasis_data_manager.errors import OasisDataManagerException | ||
| from oasis_data_manager.filestore.archive import ARCHIVE_SUFFIXES, GZIP, compress_dir, extract_archive, validate_compression |
Contributor
There was a problem hiding this comment.
minor: ARCHIVE_FILE_SUFFIX variable below not used anywhere, should be removed as ARCHIVE_SUFFIXES takes precendence.
| options = {zstd.CompressionParameter.compression_level: level} | ||
| if threads and zstd.CompressionParameter.nb_workers.bounds()[1] > 0: | ||
| options[zstd.CompressionParameter.nb_workers] = threads | ||
| with zstd.ZstdFile(archive_fp, "w", options=options) as zf, tarfile.open(fileobj=zf, mode="w|") as tar: |
Contributor
There was a problem hiding this comment.
minor: tarfile defaults to using compression.zstd if installed. I don't think you need to chain the opening of the tar like this, you can pass the CompressionParameter options via a kwarg options.
ARCHIVE_SUFFIXES in filestore/archive.py now determines archive suffixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write with tarfile.open(..., "w:zst", options=...) and let tarfile auto-detect zstd on read, instead of wrapping a ZstdFile in a streamed tar. Reads on 3.14+ are now seekable; the zstandard fallback is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sambles
added a commit
that referenced
this pull request
Oct 23, 2026
Directory archives written by `put()` used tarfile's default gzip level 9 on
a single core. On a 12.4 GB Oasis inputs directory that took 369 s locally
(~23 min on Fargate) for a 7.9x ratio; level 1 takes 32 s for 7.1x.
- Default gzip compresslevel is now 1 (configurable via `archive_compresslevel`)
- New `archive_compression` option ('gz' or 'zst') and per call
`put(..., compression=...)` override; zstd is multi-threaded
(`archive_threads`, -1 for every core) via the stdlib `compression.zstd`
on Python 3.14+ or the `zstandard` package (new `[zstd]` extra)
- `extract()` detects zstd archives by magic bytes
- Archive options are kept by `to_config()`
- New `archive_suffix()` returns the extension for the configured format
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove unused ARCHIVE_FILE_SUFFIX constant
ARCHIVE_SUFFIXES in filestore/archive.py now determines archive suffixes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use tarfile's native zstd support on Python 3.14+
Write with tarfile.open(..., "w:zst", options=...) and let tarfile
auto-detect zstd on read, instead of wrapping a ZstdFile in a streamed
tar. Reads on 3.14+ are now seekable; the zstandard fallback is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to OasisLMF/OasisPlatform#1478
Directory archives written by
put()used tarfile's default gzip level 9 on a single core. On a 12.36 GB Oasis inputs directory that took 369 s locally (~23 min on a Fargate worker) for a 7.9x ratio. Level 1 takes 32 s for 7.1x.Faster directory archives
put()now default to gzip level 1 instead of 9, about 11x faster on Oasis inputs for ~10% larger archives. The level is configurable witharchive_compresslevel.archive_compressionstorage option (gzdefault, orzst) and a per-callput(..., compression=...)override. zstd is multi-threaded (archive_threads, -1 for every core) using the standard librarycompression.zstdon Python 3.14+, or thezstandardpackage (new[zstd]extra) on older versions.extract()detects zstd archives from their header, whatever the file name.ARCHIVE_FILE_SUFFIXconstant fromoasis_data_manager.filestore.backends.base; suffixes come fromARCHIVE_SUFFIXESinoasis_data_manager.filestore.archive.Changes
oasis_data_manager/filestore/archive.pywithcompress_dir,open_archiveandextract_archive. On Python 3.14+ zstd goes through tarfile's built-in support (tarfile.open(..., "w:zst", options=...)to write, auto-detected on read, so reads can seek). Older versions stream through thezstandardpackage.BaseStoragetakesarchive_compression,archive_compresslevelandarchive_threads, keeps them into_config(), and addsarchive_suffix().AwsS3Storage.put()passescompressionthrough.ARCHIVE_FILE_SUFFIXconstant.Benchmark (real 12.36 GB inputs, 16-core laptop)
Testing
tests/filestorage/test_archive.py: round trip for gz and zst, thezstandardfallback, the default level,putsuffix and per-call override, andto_config()round trip.tests/filestorage/test_local.pypasses. Five local-storage "outside root" tests intest_general.pyfail the same way without this change.test_archive.pyhas not been rerun since.🤖 Generated with Claude Code