feat(compress): move dictionary mode selection to Rust

The block-compressor dispatch already selected its strategy and row-mode index
in Rust, but C still classified the match state into no-dictionary,
ext-dictionary, attached-dictionary, or dedicated-dictionary mode. Project the
window and match-state scalars into Rust so that four-way policy is centralized
with compressor dispatch while C retains private match-state access.

Test Plan:
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo check --tests (rust)
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --tests -- -A clippy::manual-bits -D warnings (rust)
- ulimit -v 41943040; make -j1
- ulimit -v 41943040; make -j1 -C tests test
This commit is contained in:
2026-07-22 00:46:44 +02:00
parent 791b68cba7
commit a909fa6b8a
2 changed files with 42 additions and 5 deletions
+7 -5
View File
@@ -712,6 +712,9 @@ void ZSTD_rust_windowInit(ZSTD_rust_windowUpdateState* state);
U32 ZSTD_rust_windowIsEmpty(const void* nextSrc, const void* base,
U32 dictLimit, U32 lowLimit);
U32 ZSTD_rust_windowHasExtDict(U32 dictLimit, U32 lowLimit);
int ZSTD_rust_matchStateDictMode(U32 dictLimit, U32 lowLimit,
int hasDictMatchState,
int dedicatedDictSearch);
ZSTD_rust_windowDictState ZSTD_rust_windowEnforceMaxDist(
U32 blockEndIdx, U32 maxDist, ZSTD_rust_windowDictState state);
U32 ZSTD_rust_windowCheckDictValidity(U32 blockEndIdx, U32 maxDist,
@@ -1121,11 +1124,10 @@ MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
*/
MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_MatchState_t *ms)
{
return ZSTD_window_hasExtDict(ms->window) ?
ZSTD_extDict :
ms->dictMatchState != NULL ?
(ms->dictMatchState->dedicatedDictSearch ? ZSTD_dedicatedDictSearch : ZSTD_dictMatchState) :
ZSTD_noDict;
return (ZSTD_dictMode_e)ZSTD_rust_matchStateDictMode(
ms->window.dictLimit, ms->window.lowLimit,
ms->dictMatchState != NULL,
ms->dictMatchState != NULL && ms->dictMatchState->dedicatedDictSearch);
}
/* Defining this macro to non-zero tells zstd to run the overflow correction