Fix quadratic zstd list load compression#7753
Conversation
PR Summary by QodoAvoid quadratic ZSTD dict compression during chunked QList loads
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
🤖 Augment PR SummarySummary: This PR fixes quadratic behavior in QList post-load ZSTD dictionary compression when RDB list loading appends additional listpack chunks. Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
26d7a3d to
185ec3b
Compare
Post-load zstd compression now scans backward from the tail and stops at the first already-compressed node, avoiding repeated scans of previously processed chunks.
185ec3b to
e0de255
Compare
| if (any_compressed) | ||
| dict_bulk_finished_ = 1; |
There was a problem hiding this comment.
lets say that all nodes we see are too small, so none are compressed, then this flag is not set. then we need to walk the full list every time, when called from CoolOff? because dict_bulk_finished_ is not 1.
Wouldn't it be better to mark the list finished once we are able to walk its length, even if we didnt compress some nodes? What would walking over it a second time (and each time) accomplish, as we can't compress in the second/third/Nth pass anyway?
The only false returns I see in CompressNodeWithDict is when the node is not compressible anyway (too small/not enough gain on compression) which are going to be permanent.
There was a problem hiding this comment.
hmm, you have a point.
There was a problem hiding this comment.
I will make it as conservative as possible.
A completed BackfillCompressWithZstdDict walk is terminal: RAW nodes left behind can never compress on a rescan since CompressNodeWithDict failures are permanent. Previously the all-nodes-too-small case set neither flag, forcing CoolOff to re-walk the whole list on every push. Now only a real dict mismatch (nodes tried, none compressed) sets dict_bulk_failed_; every other outcome sets dict_bulk_finished_.
Summary:
Fix chunked RDB list loading with experimental zstd dictionaries so post-load compression scans only newly appended nodes after the initial pass.
Changes:
Validation: