feat!: 9x faster Sixel image preview #2707
Merged
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.
See #2681
Closes #2681
This PR replaces the existing neural network quantization algorithm with Wu's Color Quantizer, which offers better performance while maintaining comparable quality.
I've integrated the new algorithm into Yazi's Sixel encoding process, and the benchmark has shown that the speed is 9 times faster than before.
Old implementation (neural network via
color_quant, with highest qualitysixel_fraction = 10) – average 226.2241541ms:Old implementation (neural network via
color_quant, with defaultsixel_fraction = 20) – average 189.5763999ms:Old implementation (neural network via
color_quant, with highest speedsixel_fraction = 30) – average 175.1113751ms:New implementation (Wu - sRGB via
quantette) – average 20.9199916ms:Benchmark script:
Then run the test in release mode:
cargo test --package yazi-adapter --lib --profile release -- drivers::sixel::tests::test_sixel --exact --show-outputWith:
The
sixel_fractionconfig option has been removed, as it was specific to the old neural network algorithm and is no longer needed in the new implementation.