Commit 5833590
authored
zstd support (#539)
This adds zstd compression support.
The current two options, zlib and fastlz is basically a choice between performance and compression ratio.
You would choose zlib if you are memory-bound and fastlz if you are cpu-bound. With zstd, you get the
performance of fastlz with the compression of zlib. And often it wins on both. See this benchmark I ran
on json files of varying sizes: https://gist.github.com/rlerdorf/788f3d0144f9c5514d8fee9477cbe787
Taking just a 40k json blob, we see that zstd at compression level 3 reduces it to 8862 bytes. Our current
zlib 1 gets worse compression at 10091 bytes and takes longer both to compress and decompress.
C Size ratio% C MB/s D MB/s SCORE Name File
8037 19.9 0.58 2130.89 0.08 zstd 22 file-39.54k-json
8204 20.3 31.85 2381.59 0.01 zstd 10 file-39.54k-json
8371 20.7 47.52 547.12 0.01 zlib 9 file-39.54k-json
8477 20.9 74.84 539.83 0.01 zlib 6 file-39.54k-json
8862 21.9 449.86 2130.89 0.01 zstd 3 file-39.54k-json
9171 22.7 554.62 2381.59 0.01 zstd 1 file-39.54k-json
10091 24.9 153.94 481.99 0.01 zlib 1 file-39.54k-json
10646 26.3 43.39 8097.40 0.01 lz4 16 file-39.54k-json
10658 26.3 72.30 8097.40 0.01 lz4 10 file-39.54k-json
13004 32.1 1396.10 6747.83 0.01 lz4 1 file-39.54k-json
13321 32.9 440.08 1306.03 0.01 fastlz 2 file-39.54k-json
14807 36.6 444.91 1156.77 0.01 fastlz 1 file-39.54k-json
15517 38.3 1190.79 4048.70 0.02 zstd -10 file-39.54k-json
The fact that decompression a dramatically faster with zstd is a win for most common memcache uses
since they tend to be read-heavy. The PR also adds a `memcache.compression_level` INI switch which
currently only applies to zstd compression. It could probably be made to also apply to zlib and fastlz.1 parent 6926c53 commit 5833590
File tree
5 files changed
+125
-3
lines changed- tests
5 files changed
+125
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
345 | 348 | | |
346 | 349 | | |
347 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
348 | 358 | | |
349 | 359 | | |
350 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| 84 | + | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| |||
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
| 161 | + | |
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
| |||
278 | 285 | | |
279 | 286 | | |
280 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
281 | 292 | | |
282 | 293 | | |
283 | 294 | | |
| |||
408 | 419 | | |
409 | 420 | | |
410 | 421 | | |
| 422 | + | |
411 | 423 | | |
412 | 424 | | |
413 | 425 | | |
| |||
897 | 909 | | |
898 | 910 | | |
899 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
900 | 925 | | |
901 | 926 | | |
902 | 927 | | |
| |||
2939 | 2964 | | |
2940 | 2965 | | |
2941 | 2966 | | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
2942 | 2970 | | |
2943 | 2971 | | |
2944 | 2972 | | |
| |||
3001 | 3029 | | |
3002 | 3030 | | |
3003 | 3031 | | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
3004 | 3035 | | |
3005 | 3036 | | |
3006 | 3037 | | |
| |||
3608 | 3639 | | |
3609 | 3640 | | |
3610 | 3641 | | |
3611 | | - | |
| 3642 | + | |
3612 | 3643 | | |
3613 | 3644 | | |
3614 | 3645 | | |
3615 | 3646 | | |
3616 | 3647 | | |
3617 | 3648 | | |
| 3649 | + | |
3618 | 3650 | | |
3619 | 3651 | | |
3620 | | - | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
3621 | 3660 | | |
3622 | 3661 | | |
3623 | 3662 | | |
| |||
3629 | 3668 | | |
3630 | 3669 | | |
3631 | 3670 | | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
3632 | 3688 | | |
3633 | 3689 | | |
3634 | 3690 | | |
| |||
3955 | 4011 | | |
3956 | 4012 | | |
3957 | 4013 | | |
| 4014 | + | |
3958 | 4015 | | |
3959 | 4016 | | |
3960 | 4017 | | |
| |||
4000 | 4057 | | |
4001 | 4058 | | |
4002 | 4059 | | |
| 4060 | + | |
4003 | 4061 | | |
4004 | 4062 | | |
4005 | 4063 | | |
| |||
4015 | 4073 | | |
4016 | 4074 | | |
4017 | 4075 | | |
| 4076 | + | |
| 4077 | + | |
| 4078 | + | |
| 4079 | + | |
| 4080 | + | |
| 4081 | + | |
| 4082 | + | |
| 4083 | + | |
| 4084 | + | |
4018 | 4085 | | |
4019 | 4086 | | |
4020 | 4087 | | |
| |||
4186 | 4253 | | |
4187 | 4254 | | |
4188 | 4255 | | |
| 4256 | + | |
4189 | 4257 | | |
4190 | 4258 | | |
4191 | 4259 | | |
| |||
4351 | 4419 | | |
4352 | 4420 | | |
4353 | 4421 | | |
| 4422 | + | |
| 4423 | + | |
| 4424 | + | |
| 4425 | + | |
| 4426 | + | |
| 4427 | + | |
4354 | 4428 | | |
4355 | 4429 | | |
4356 | 4430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
57 | 81 | | |
58 | 82 | | |
59 | 83 | | |
| |||
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
0 commit comments