Add single-slot backend-local ZSTD_DDict cache for repeated dict usage#4
Open
brianr2600 wants to merge 1 commit into
Open
Add single-slot backend-local ZSTD_DDict cache for repeated dict usage#4brianr2600 wants to merge 1 commit into
brianr2600 wants to merge 1 commit into
Conversation
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.
This patch introduces a single-slot backend-local
ZSTD_DDict*cache to avoid re-parsing the dictionary bytes on every row when a query passes a dictionary by column reference.ZSTD_decompress_usingDictre-parses the dictionary on every invocation. For queries fetching thousands of rows with a large (e.g., 1MB) dictionary passed per-row, this memory parse cost can dominate execution.Implementation
(dict_len, first-16-bytes, last-16-bytes)from the dictionary argument (thesize_tlength plus 32 bytes of content).ZSTD_decompress_usingDDictto bypass the parse phase.ZSTD_createDDict()._PG_fini.In local synthetic benchmarking on 1000 rows with a 256KB dict, this dropped the per-row overhead of
zstd_decompressfrom ~11.3 µs to ~2.8 µs (a 4.2x speedup).