Repository navigation
Conversation
pitrou
left a comment
There was a problem hiding this comment.
I must think a bit more about the EncodingOptions API but otherwise this is looking rather good.
| if (worse_total_bits_counter == AlpSamplingOptions::kEarlyExitThreshold) { | ||
| break; | ||
| } | ||
| continue; |
There was a problem hiding this comment.
Unrelated to this PR, but what's the point of the "early exit" thing?
Why would we not test all pre-selected combinations (especially as kMaxCombinations = 5)?
There was a problem hiding this comment.
There is a related discussion at #48345 (comment).
The ALP paper uses early exit with at most 5 candidates and early exit threshold of 2. Our values are 5 and 4 respectively, so we cannot actually skip any candidates.
Increasing the candidate count or lowering the threshold could make it useful, but the greedy search may miss a better candidate and hurt compression ratio. In the future, we can turn these sampling constants to configurable options to make them work.
There was a problem hiding this comment.
I don't understand why increasing the candidate count would hurt compression ratio. It can only improve the compression ratio, right?
There was a problem hiding this comment.
Sorry, I didn't explain it clearly. I meant that the greedy early exit itself would hurt the compression ratio compared to not using early exit.
My suggestion is to keep the early exit algorithm as consistent with the ALP paper and make it tunable after we have more production experience.
There was a problem hiding this comment.
Ok, but my question remains: why the early exit at all? Is it just to save a bit of time when compressing?
There was a problem hiding this comment.
Yes, the ALP has designed this early exit to save some time but it doesn't tell how much time can be saved from this.
| // The encoder emits strictly increasing positions. Use the vectorized | ||
| // fast path for that common case. |
There was a problem hiding this comment.
Was the "vectorized fast path" measured to bring substantial benefits? After all, there should not be many exceptions...
There was a problem hiding this comment.
#48345 (comment) mentioned testing unroll factors of 2, 4 and 8, but provided no measurements specific to exception patching.
When I made this change, I have verified that the code path has been vectorized by gcc on godbolt. But I didn't verify its performance gain because I used Clang locally which failed to do this :/
| chunk_samples_.push_back(std::move(chunk_sample)); | ||
| chunks_sampled_++; |
There was a problem hiding this comment.
I'm curious, is chunk_samples_ unbounded, or does it stop accumulating after a certain number of samples? It's not clear by reading this code.
There was a problem hiding this comment.
The sampler itself is unbounded but the encoder will stop sampling after processing sampling_window_size values to get the preset.
|
|
||
| EncodingPreset page_preset; | ||
| if (!preset_.has_value()) { | ||
| // Use a page-specific sampler to avoid affecting the global preset. |
There was a problem hiding this comment.
Why do we not use a page-specific sampler for all pages? Is it too expensive?
There was a problem hiding this comment.
To clarify, before my change in this PR, every page performs a complete two-pass sampling and encoding strategy as described in #55449 (comment). I think this is expensive so I introduce a column-chunk-level shared sampler to avoid repeating this process over and over again.
There was a problem hiding this comment.
I think this is expensive
Did you validate this and your approach using benchmarks?
Also, IMHO we should be careful to not pessimize the compression efficiency in search for encoding speed improvements.
This might not be a problem on synthetic random data, but reduce compression efficiency on real-world data with non-random ordering.
There was a problem hiding this comment.
Good question. I've only benchmarked the speedup but not yet checked the compression ratio. I asked AI to do a quick check and indeed found several regressions. Since this is a naive approach and has regression, let me revert this part from the PR.
Rationale for this change
This PR addresses follow-up items from #48345 to improve ALP performance, format compatibility, and writer configuration.
What changes are included in this PR?
AlpConfigandWriterProperties::Builder::alp_config()to configure the vector size and sampling window.PutSpaced()temporary storage by the non-null count and avoid allocation for empty or all-null input.Are these changes tested?
Yes.
Are there any user-facing changes?
Yes. Writers can configure ALP through
AlpConfig:vector_size: defaults to 1,024; supported values are powers of two from 8 through 32,768.sampling_window_size: defaults to 122,880 non-null values and must be positive. The preset is cached at the end of the page that reaches the configured count.Was AI used for this PR?
AI assisted with implementation, review, test execution, and benchmarking.
PR code and description written by:
Reviewed before submission by: