All Projects → coolbutuseless → zstdlite

coolbutuseless / zstdlite

Licence: MIT license
Fast, configurable in-memory compression of R objects with zstd

Programming Languages

c
50402 projects - #5 most used programming language
r
7636 projects

Labels

Projects that are alternatives of or similar to zstdlite

Lizard
Lizard (formerly LZ5) is an efficient compressor with very fast decompression. It achieves compression ratio that is comparable to zip/zlib and zstd/brotli (at low and medium compression levels) at decompression speed of 1000 MB/s and faster.
Stars: ✭ 408 (+2047.37%)
Mutual labels:  zstd
Zstd
Zstandard implementation in Wuffs
Stars: ✭ 107 (+463.16%)
Mutual labels:  zstd
P7zip
A new p7zip fork with additional codecs and improvements (forked from https://sourceforge.net/projects/p7zip/).
Stars: ✭ 222 (+1068.42%)
Mutual labels:  zstd
Lzbench
lzbench is an in-memory benchmark of open-source LZ77/LZSS/LZMA compressors
Stars: ✭ 490 (+2478.95%)
Mutual labels:  zstd
Zstd Nginx Module
Nginx modules for the Zstandard compression
Stars: ✭ 64 (+236.84%)
Mutual labels:  zstd
7 Zip Zstd
7-Zip with support for Brotli, Fast-LZMA2, Lizard, LZ4, LZ5 and Zstandard
Stars: ✭ 2,150 (+11215.79%)
Mutual labels:  zstd
Gozstd
go wrapper for zstd
Stars: ✭ 275 (+1347.37%)
Mutual labels:  zstd
7-Zip-Filetype-Theme
7-Zip Filetype Theme Windows 10 and Windows 11
Stars: ✭ 145 (+663.16%)
Mutual labels:  zstd
Squashfs Tools Ng
A new set of tools and libraries for working with SquashFS images
Stars: ✭ 76 (+300%)
Mutual labels:  zstd
Turbobench
Compression Benchmark
Stars: ✭ 211 (+1010.53%)
Mutual labels:  zstd
Pgbackrest
Reliable PostgreSQL Backup & Restore
Stars: ✭ 766 (+3931.58%)
Mutual labels:  zstd
Hs Zstd
Bindings to the Zstandard library to make it usable from the Haskell programming language.
Stars: ✭ 45 (+136.84%)
Mutual labels:  zstd
Zstd Rs
A rust binding for the zstd compression library.
Stars: ✭ 159 (+736.84%)
Mutual labels:  zstd
Dwarfs
A fast high compression read-only file system
Stars: ✭ 444 (+2236.84%)
Mutual labels:  zstd
Python Zstandard
Python bindings to the Zstandard (zstd) compression library
Stars: ✭ 233 (+1126.32%)
Mutual labels:  zstd
Linux
XanMod: Linux kernel source code tree
Stars: ✭ 310 (+1531.58%)
Mutual labels:  zstd
Libarchive
Multi-format archive and compression library
Stars: ✭ 1,625 (+8452.63%)
Mutual labels:  zstd
ZRA
ZStandard Random Access (ZRA) allows random access inside an archive compressed using ZStandard
Stars: ✭ 21 (+10.53%)
Mutual labels:  zstd
pgzstd
Postgres module for Zstandard compression/decompression with preset dictionary support
Stars: ✭ 31 (+63.16%)
Mutual labels:  zstd
Zstdnet
Zstd wrapper for .NET
Stars: ✭ 176 (+826.32%)
Mutual labels:  zstd

zstdlite

R build status Lifecycle: experimental

zstdlite provides access to the very fast (and highly configurable) zstd library for performing in-memory compression of R objects.

For rock solid general solutions to fast serialization of R objects, see the fst or qs packages.

zstd code provided with this package is v1.5.0.

What’s in the box

  • zstd_serialize() and zstd_unserialize() for converting R objects to/from a compressed representation

Installation

You can install from GitHub with:

# install.package('remotes')
remotes::install_github('coolbutuseless/zstdlite')

Basic usage of zstdlite

arr <- array(1:27, c(3, 3, 3))
lobstr::obj_size(arr)
#> 352 B
buf <- zstd_serialize(arr)
length(buf) # Number of bytes
#> [1] 117
# compression ratio
length(buf)/as.numeric(lobstr::obj_size(arr))
#> [1] 0.3323864
zstd_unserialize(buf)
#> , , 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    1    4    7
#> [2,]    2    5    8
#> [3,]    3    6    9
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3]
#> [1,]   10   13   16
#> [2,]   11   14   17
#> [3,]   12   15   18
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3]
#> [1,]   19   22   25
#> [2,]   20   23   26
#> [3,]   21   24   27

Compressing 1 million Integers

library(zstdlite)
library(lz4lite)
set.seed(1)

N                 <- 1e6
input_ints        <- sample(1:5, N, prob = (1:5)^4, replace = TRUE)
uncompressed      <- serialize(input_ints, NULL, xdr = FALSE)
compressed_lo     <- zstd_serialize(input_ints, level = -5)
compressed_mid    <- zstd_serialize(input_ints, level =  3)
compressed_mid2   <- zstd_serialize(input_ints, level = 10)
compressed_hi     <- zstd_serialize(input_ints, level = 22)
compressed_base   <- memCompress(serialize(input_ints, NULL, xdr = FALSE))
Click here to show/hide benchmark code
library(zstdlite)

res <- bench::mark(
  serialize(input_ints, NULL, xdr = FALSE),
  memCompress(serialize(input_ints, NULL, xdr = FALSE)),
  zstd_serialize(input_ints, level =  -5),
  zstd_serialize(input_ints, level =   3),
  zstd_serialize(input_ints, level =  10),
  zstd_serialize(input_ints, level =  22),
  check = FALSE
)
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.
expression median itr/sec MB/s compression_ratio
serialize(input_ints, NULL, xdr = FALSE) 3.62ms 177 1053.9 1.000
memCompress(serialize(input_ints, NULL, xdr = FALSE)) 184.41ms 5 20.7 0.079
zstd_serialize(input_ints, level = -5) 65.03ms 15 58.7 0.229
zstd_serialize(input_ints, level = 3) 85.24ms 12 44.8 0.101
zstd_serialize(input_ints, level = 10) 702.61ms 1 5.4 0.080
zstd_serialize(input_ints, level = 22) 13.02s 0 0.3 0.058

Decompressing 1 million integers

Click here to show/hide benchmark code
res <- bench::mark(
  unserialize(uncompressed),
  zstd_unserialize(compressed_lo),
  zstd_unserialize(compressed_mid2),
  zstd_unserialize(compressed_hi),
  unserialize(memDecompress(compressed_base, type = 'gzip')),
  check = TRUE
)
expression median itr/sec MB/s
unserialize(uncompressed) 604.4µs 1417 6311.8
zstd_unserialize(compressed_lo) 42.3ms 23 90.1
zstd_unserialize(compressed_mid2) 29.2ms 34 130.6
zstd_unserialize(compressed_hi) 18.1ms 58 210.6
unserialize(memDecompress(compressed_base, type = “gzip”)) 14.5ms 68 263.2

Zstd “Single File” Libary

  • To simplify the code within this package, it uses the ‘single file library’ version of zstd
  • To update this package when zstd is updated, create the single file library version
    1. cd zstd/build/single_file_libs
    2. sh create_single_file_library.sh
    3. Wait…..
    4. copy zstd/built/single_file_libs/zstd.c into zstdlite/src
    5. copy zstd/lib/zstd.h into zstdlite/src

Related Software

For a more general solution to fast serialization of R objects, see the fst or qs packages.

  • lz4 and zstd - both by Yann Collet
  • fst for serialisation of data.frames using lz4 and zstd
  • qs for fast serialization of arbitrary R objects with lz4 and zstd

Acknowledgements

  • Yann Collett for releasing, maintaining and advancing lz4 and zstd
  • R Core for developing and maintaining such a wonderful language.
  • CRAN maintainers, for patiently shepherding packages onto CRAN and maintaining the repository
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].