You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Landed via the C ABI core + CDict work (PRs #386, #387): ZSTD_createCDict / ZSTD_createCDict_byReference / ZSTD_freeCDict / ZSTD_sizeof_CDict / ZSTD_compress_usingCDict / ZSTD_getDictID_fromCDict, the full DDict mirror, and the simple/context/frame/error surface (39 symbols total). Remaining in this issue: the advanced parameter API (ZSTD_CCtx_setParameter family, ZSTD_compress2, ZSTD_compressStream2, estimates), the streaming ZSTD_CStream/ZSTD_DStream surface, and the _advanced dictionary variants + *_usingDict one-shots.
Summary
Phase 6.2 of #28: complete the v1.5.7 advanced/streaming/dictionary C API surface on top of the FFI foundation from #126 (Phase 6.1). After this issue lands, libzstd.so.1 produced by c-api/ is symbol-complete vs upstream v1.5.7 except for multi-threaded compression (Phase 6.4 / #64) and legacy decoders (Phase 6.5/6.6 / #65/#66).
Deliverables
1. Advanced parameter API (ZSTD_CCtx_setParameter family)
Requires #27 (configurable parameters API) to be merged first — that issue exposes the Rust-side parameter struct this FFI layer wraps.
Streaming ZSTD_CStreamInSize() / ZSTD_CStreamOutSize() return the same values upstream does (matches ZSTD_BLOCKSIZE_MAX).
Out of scope
Multi-threaded ZSTD_c_nbWorkers > 0 → 6.4 (chore: release v0.0.7 #64). This issue treats nbWorkers > 0 as a graceful no-op (single-threaded fallback) with a deprecation warning, so consumers that set it don't crash.
ZSTD_CCtx_setParameter accepts every v1.5.7 ZSTD_cParameter discriminant; rejects out-of-bounds values via ZSTD_cParam_getBounds.
Streaming round-trip via ZSTD_compressStream2 + ZSTD_decompressStream produces byte-exact output on a 16 MiB random + low-entropy + high-entropy corpus.
Dictionary round-trip via ZSTD_compress_usingCDict + ZSTD_decompress_usingDDict matches the same Rust-API roundtrip byte-for-byte.
Dictionary training via ZDICT_trainFromBuffer produces a dictionary that a C consumer can use with ZSTD_compress_usingDict, decode-side via our .so succeeds.
Progress
Landed via the C ABI core + CDict work (PRs #386, #387):
ZSTD_createCDict/ZSTD_createCDict_byReference/ZSTD_freeCDict/ZSTD_sizeof_CDict/ZSTD_compress_usingCDict/ZSTD_getDictID_fromCDict, the full DDict mirror, and the simple/context/frame/error surface (39 symbols total). Remaining in this issue: the advanced parameter API (ZSTD_CCtx_setParameterfamily,ZSTD_compress2,ZSTD_compressStream2, estimates), the streamingZSTD_CStream/ZSTD_DStreamsurface, and the_advanceddictionary variants +*_usingDictone-shots.Summary
Phase 6.2 of #28: complete the v1.5.7 advanced/streaming/dictionary C API surface on top of the FFI foundation from #126 (Phase 6.1). After this issue lands,
libzstd.so.1produced byc-api/is symbol-complete vs upstream v1.5.7 except for multi-threaded compression (Phase 6.4 / #64) and legacy decoders (Phase 6.5/6.6 / #65/#66).Deliverables
1. Advanced parameter API (
ZSTD_CCtx_setParameterfamily)Requires #27 (configurable parameters API) to be merged first — that issue exposes the Rust-side parameter struct this FFI layer wraps.
Wrappers:
ZSTD_CCtx_setParameter,ZSTD_CCtx_getParameter,ZSTD_CCtx_setPledgedSrcSizeZSTD_DCtx_setParameter,ZSTD_DCtx_getParameterZSTD_cParam_getBounds,ZSTD_dParam_getBoundsZSTD_CCtx_reset,ZSTD_DCtx_resetZSTD_compress2,ZSTD_compressStream2ZSTD_estimateCCtxSize,ZSTD_estimateDCtxSize,ZSTD_estimateCCtxSize_usingCParams,ZSTD_estimateCStreamSize,ZSTD_estimateDStreamSizeParameter enum (
ZSTD_cParameter,ZSTD_dParameter) covers all v1.5.7 entries:ZSTD_c_compressionLevel,ZSTD_c_windowLog,ZSTD_c_hashLog,ZSTD_c_chainLog,ZSTD_c_searchLog,ZSTD_c_minMatch,ZSTD_c_targetLength,ZSTD_c_strategyZSTD_c_enableLongDistanceMatching,ZSTD_c_ldmHashLog,ZSTD_c_ldmMinMatch,ZSTD_c_ldmBucketSizeLog,ZSTD_c_ldmHashRateLogZSTD_c_contentSizeFlag,ZSTD_c_checksumFlag,ZSTD_c_dictIDFlagZSTD_c_jobSize,ZSTD_c_overlapLog,ZSTD_c_rsyncableZSTD_c_nbWorkers— accepts only0in this issue; non-zero handled by 6.4 (chore: release v0.0.7 #64)ZSTD_c_useRowMatchFinder,ZSTD_c_targetCBlockSize(already implemented via perf(encoding): implement row-based match finder for fast/dfast levels #67 / feat: block splitting for improved compression ratio #23 internals)2. Streaming API
ZSTD_CStream/ZSTD_DStreamare aliases forZSTD_CCtx/ZSTD_DCtxper v1.5.x design. The streaming functions ride on top of the same opaque contexts.Wrappers:
ZSTD_createCStream,ZSTD_freeCStream,ZSTD_initCStream,ZSTD_compressStream,ZSTD_flushStream,ZSTD_endStream,ZSTD_CStreamInSize,ZSTD_CStreamOutSizeZSTD_createDStream,ZSTD_freeDStream,ZSTD_initDStream,ZSTD_decompressStream,ZSTD_DStreamInSize,ZSTD_DStreamOutSizeZSTD_inBuffer/ZSTD_outBufferstructs are#[repr(C)]aliases of our streaming buffer types.3. Dictionary API
Compression-side (
ZSTD_CDict):ZSTD_createCDict,ZSTD_createCDict_byReference,ZSTD_createCDict_advancedZSTD_freeCDict,ZSTD_sizeof_CDictZSTD_compress_usingCDict,ZSTD_compress_usingCDict_advancedZSTD_CCtx_loadDictionary,ZSTD_CCtx_loadDictionary_byReference,ZSTD_CCtx_loadDictionary_advancedZSTD_CCtx_refCDict,ZSTD_CCtx_refPrefix,ZSTD_CCtx_refPrefix_advancedDecompression-side (
ZSTD_DDict):ZSTD_createDDict,ZSTD_createDDict_byReference,ZSTD_createDDict_advancedZSTD_freeDDict,ZSTD_sizeof_DDictZSTD_decompress_usingDDictZSTD_DCtx_loadDictionary,ZSTD_DCtx_refDDict,ZSTD_DCtx_refPrefixZSTD_getDictID_fromCDict,ZSTD_getDictID_fromDDict,ZSTD_getDictID_fromDict,ZSTD_getDictID_fromFramezdict.htraining API:ZDICT_trainFromBufferZDICT_optimizeTrainFromBuffer_fastCoverZDICT_trainFromBuffer_fastCoverZDICT_finalizeDictionaryZDICT_isError,ZDICT_getErrorNameZDICT_getDictHeaderSize,ZDICT_getDictID4. ABI invariants
ZSTD_inBuffer/ZSTD_outBuffersize_ofsnapshots match upstreamsizeof(ZSTD_inBuffer)(= 24 bytes on 64-bit per upstreamzstd.h).ZSTD_cParameter/ZSTD_dParameterenum discriminants match upstream numeric values byte-for-byte (asserted via the vendored header diff in feat(c-api): #28 Phase 6.1 — C ABI core (cdylib + vendored headers + simple/context/error wrappers) #126 plusstatic_assertionsinabi.rs).ZSTD_CStreamInSize()/ZSTD_CStreamOutSize()return the same values upstream does (matchesZSTD_BLOCKSIZE_MAX).Out of scope
ZSTD_c_nbWorkers > 0→ 6.4 (chore: release v0.0.7 #64). This issue treatsnbWorkers > 0as a graceful no-op (single-threaded fallback) with a deprecation warning, so consumers that set it don't crash.Acceptance criteria
c_consumer.cfrom feat(c-api): #28 Phase 6.1 — C ABI core (cdylib + vendored headers + simple/context/error wrappers) #126 to drive streaming + advanced + dictionary paths).ZSTD_CCtx_setParameteraccepts every v1.5.7ZSTD_cParameterdiscriminant; rejects out-of-bounds values viaZSTD_cParam_getBounds.ZSTD_compressStream2+ZSTD_decompressStreamproduces byte-exact output on a 16 MiB random + low-entropy + high-entropy corpus.ZSTD_compress_usingCDict+ZSTD_decompress_usingDDictmatches the same Rust-API roundtrip byte-for-byte.ZDICT_trainFromBufferproduces a dictionary that a C consumer can use withZSTD_compress_usingDict, decode-side via our.sosucceeds.c-api/tests/symbols.rs) updated to cover the full v1.5.7 surface.nbWorkers = N > 0returns gracefully (current FFI: ignored with warning), to be replaced by real MT in 6.4 (chore: release v0.0.7 #64).Estimate
~10-12 working days (~60 wrappers including ABI tests).
Blocked by
ZSTD_CCtx_setParameteris a thin shim on top of feat: configurable compression parameters API #27'sCompressionParametersbuilder.References
zstd.hv1.5.7 advanced API sectionzdict.hv1.5.7