镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

ZSTD compression #1101

Closed

Description

@den-crane

I would like to have ability to fetch results compressed by ZSTD

in my case ZSTD allows to fetch 3 times less data and twice faster:

### enable_http_compression=0

time curl "http://host1:8123/?enable_http_compression=0" -H 'Accept-Encoding: zstd' --data-binary@query.sql -o http_no_compression
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  917M    0  917M  100 45885  51.0M   2550  0:00:17  0:00:17 --:--:-- 55.2M

real	0m17.996s


### compress=1 (LZ4)

time curl "http://host1:8123/?&compress=1" --data-binary @query.sql -o http_lz4
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  118M    0  118M  100 45885  29.3M  11371  0:00:04  0:00:04 --:--:-- 29.3M

real	0m4.089s


### enable_http_compression=1"  'Accept-Encoding: zstd'

time curl "http://host1:8123/?&enable_http_compression=1" -H 'Accept-Encoding: zstd' --data-binary @query.sql -o http_zstd3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 29.2M    0 29.1M  100 45885  10.8M  17025  0:00:02  0:00:02 --:--:-- 10.8M

real	0m2.713s


$ ping host1
...
64 bytes from 10.253.232.2 (10.253.232.2): icmp_seq=1 ttl=62 time=0.518 ms

1 GBit network

Activity

  1. added this to the 0.3.3 release milestone on Oct 3, 2022
  2. subkanthi commented on Oct 9, 2022

    @subkanthi
    Contributor

    Hi @zhicwu , I was looking at this , I guess the change needs to be done for request and response , would this be a good library to use - https://github.com/luben/zstd-jni

        static ClickHouseOutputStream wrap(ClickHouseFile file, OutputStream output, int bufferSize,
                Runnable postCloseAction, ClickHouseCompression compression, int compressionLevel) {
            final ClickHouseOutputStream chOutput;
            if (compression == null || compression == ClickHouseCompression.NONE) {
                chOutput = new WrappedOutputStream(file, output, bufferSize, postCloseAction);
            } else {
                switch (compression) {
                    case GZIP:
                        try {
                            chOutput = new WrappedOutputStream(file, new GZIPOutputStream(output), bufferSize,
                                    postCloseAction);
                        } catch (IOException e) {
                            throw new IllegalArgumentException("Failed to wrap input stream", e);
                        }
                        break;
                    case LZ4:
                        chOutput = new Lz4OutputStream(file, output, bufferSize, postCloseAction);
                        break;
                    default:
                        throw new UnsupportedOperationException("Unsupported compression algorithm: " + compression);
                }
            }
            return chOutput;
    
  3. zhicwu commented on Oct 9, 2022

    @zhicwu
    Contributor

    Yes, it's supposed to has better performance compare to https://github.com/airlift/aircompressor/tree/master/src/main/java/io/airlift/compress/zstd. We probably should support both and take the chance to fix compression/decompression issue in gRPC as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions