Earlier quoted context omitted.
I feel like the main thing that makes this look crazy is the variable naming and bit shifting. If someone saw this program with descriptive variable names and array operations, it would probably look less daunting.
Eh. I feel like long variable names would obscure the algorithm. And bit shifting and array operations aren't interchangeable…. C just tends to look like line noise for numerical algorithms sometimes.
Apple Open-Sources its Compression Algorithm LZFSE
181–190 of 219 posts
Re: Apple Open-Sources its Compression Algorithm LZFSE
#182Just a side-comment, it would be really nice if we could get the browser vendors to support a newer compression algorithm beyond gzip and deflate. I know there have been a couple others implemented, but nothing that has been implemented by multiple browsers that has stuck. Really need to get MS, Google, Apple and Mozilla to come together on this. Should be patent free.
I think Brotli is getting there, with support in Firefox and Chrome so far. https://samsaffron.com/archive/2016/06/15/the-current-state-...
mental note, setup a new dokku box, and try getting this setup...
Re: Apple Open-Sources its Compression Algorithm LZFSE
#183Earlier quoted context omitted.
I agree. The only questionable part is the stuff like *(uint16_t *)q = D; q += 2; // non-aligned access OK *(uint32_t *)q = literal; instead of memcpy(q, &D, sizeof(uint16_t)); q += 2; // non-aligned access OK memcpy(q, &literal, sizeof(uint32_t)); which is better defined behavior (i.e. doesn't violate -fstrict-aliasing) and possibly faster.
Why not test it and do a pull request?
But I could also say that I'm lazy and it's not a big deal anyway.
Re: Apple Open-Sources its Compression Algorithm LZFSE
#184I feel like LZFSE is too little, too late. It would be great to have a proper comparison, but Zstd is stable, and offers a superior compression ratio with compression and decompression speeds that seem on par with LZFSE. And Zstd is not proprietary. (This issue is relevant in this regard: https://github.com/lzfse/lzfse/issues/21 ) https://github.com/Cyan4973/zstd Edit: here is a quick comparison I did on Linux with P…
https://quixdb.github.io/squash-benchmark/unstable/ also seems to confirm this.
Re: Apple Open-Sources its Compression Algorithm LZFSE
#185A quick test resutl(zip a 1.5GB file): lzfse: real 1m44.481s user 1m17.956s sys 0m2.852s lz4: real 0m28.136s user 0m1.200s sys 0m2.240s lz4 is much faster somehow. The final size are very close.
It's not terribly useful for most applications to test compression speed. The only applications I can think of where this is relevant is data backup and archiving. There are two typical speed benchmarks you want to do. For the "compress once, decompress many times" situation, benchmark the time it takes to decompress and ignore compression time. For the "compress once, decompress once" situation, add the compression…
http://fastcompression.blogspot.com/p/compression-benchmark....
Re: Apple Open-Sources its Compression Algorithm LZFSE
#186Earlier quoted context omitted.
The article you linked is doing all of this with a binary. Last time I tried something like this with Rust, there were a lot more obstacles to cutting down this overhead with a library than a binary. Also note that towards the bottom he cuts out libstd, which loses any form of dynamic memory allocation, as well as a significant chunk of Rust's usability advantage. The biggest factor however is that you have to read t…
> as well as a significant chunk of Rust's usability advantage. What bits are you thinking of here? Just curious, as I do a lot of no_std work, and don't feel that way, and am probably blind to it :) Rust 1.10, coming out later today, has a new crate type that removes Rust-specific metadata for dynamic libraries, by the way, making them a bit smaller for this kind of case.
This is fine if you're using no_std for something where these are anathema anyway (writing bare-metal OSes comes to mind) but a huge limitation for a humble user-space library. As it stands if you want to take advantage of Rust's safety you're going to need to reimplement at least Box, probably Vec, and Rc if your program requires that kind of thing. This isn't a huge time suck, but if I were feeling out C-compatible languages before writing a library it would be a major turnoff.
I really like Rust for low-overhead binaries but it is missing a lot when it comes to writing non-rlib libraries.
Re: Apple Open-Sources its Compression Algorithm LZFSE
#187Earlier quoted context omitted.
I don't trust "make uninstall" anyway. Instead, I usually put self-compiled packages into separate directories, such as: make install INSTALL_PREFIX=/opt/lzfse or make install INSTALL_PREFIX=$HOME/.../lzfse Uninstalling is then as simple as: rm -r /opt/lzfse For convenience, I either add /opt/lzfse/bin to $PATH , or create a symlink from /opt/lzfse/bin/lzfse to /usr/bin/lzfse . More generally, I believe that uninstal…
Good luck with getting pkg-config to recognize your include files automatically, for example. Or the good old "man" utility. Alternative: maintain a HUUUUUGE list of xPATH env variables, and update them every time you recompile something and change the directory in the process. Oh, and hope that other people's Makefiles are intelligent enough to not mess up shit (e.g. use headers from system, and library .so files fr…
Re: Apple Open-Sources its Compression Algorithm LZFSE
#188Earlier quoted context omitted.
Good luck with getting pkg-config to recognize your include files automatically, for example. Or the good old "man" utility. Alternative: maintain a HUUUUUGE list of xPATH env variables, and update them every time you recompile something and change the directory in the process. Oh, and hope that other people's Makefiles are intelligent enough to not mess up shit (e.g. use headers from system, and library .so files fr…
If you are alluding to cross-compiling, rest assured that I wrote my comment being fully aware of the plenty of pitfalls, which is why I started the MXE (mingw-cross-env) project some time ago: http://mxe.cc/
I usually set up a Debian chroot with qemu and compile "natively" (e.g. for RPi). It's dog slow, yes, but at least it works reliably in contrast to cross compilation.
The only way I ever got CC to work is with the buildroot toolchain, which has the downside that it isn't Debian.
Re: Apple Open-Sources its Compression Algorithm LZFSE
#189Earlier quoted context omitted.
> as well as a significant chunk of Rust's usability advantage. What bits are you thinking of here? Just curious, as I do a lot of no_std work, and don't feel that way, and am probably blind to it :) Rust 1.10, coming out later today, has a new crate type that removes Rust-specific metadata for dynamic libraries, by the way, making them a bit smaller for this kind of case.
Unless I'm mistaken, no_std means no built-in non-manual dynamic allocation (Box, Rc, etc.), unless you use "extern crate alloc", once again requiring the nightly. Some fundamentals one expects from a modern language like Vec are also missing in either case. This is fine if you're using no_std for something where these are anathema anyway (writing bare-metal OSes comes to mind) but a huge limitation for a humble user…
By the way, you _can_ reintroduce just those things if you want to. no_std means "don't include std", but you can then require them:
#![feature(alloc)]
#![feature(collections)]
#![no_std]
extern crate alloc;
extern crate collections;
use alloc::boxed::Box;
use alloc::rc::Rc;
use collections::vec::Vec;
pub fn foo() -> Box {
Box::new(5)
}
pub fn bar() -> Rc {
Rc::new(5)
}
pub fn baz() -> Vec {
let mut v = Vec::new();
v.push(5);
v
}
Of course, as you can see, the facade crates are largely not stable, so doing this on _stable_ rust isn't quite there yet, which is a thing that matters, as you originally pointed out. I expect as Rust grows for this stuff to stabilize, after all, the std versions are re-exported, so this example is de-facto stable, other than maybe the 'use' lines, which is an easy fix in the future.Thanks for elaborating :)
Re: Apple Open-Sources its Compression Algorithm LZFSE
#190I feel like LZFSE is too little, too late. It would be great to have a proper comparison, but Zstd is stable, and offers a superior compression ratio with compression and decompression speeds that seem on par with LZFSE. And Zstd is not proprietary. (This issue is relevant in this regard: https://github.com/lzfse/lzfse/issues/21 ) https://github.com/Cyan4973/zstd Edit: here is a quick comparison I did on Linux with P…
> time ./lzfse -encode -i webster -o webster.lzfse
real 0m0.945s
user 0m0.864s
sys 0m0.062s
> time ./lzfse2 -encode -i webster -o webster.lzfse2
real 0m0.803s
user 0m0.715s
sys 0m0.072s
> time ./lzfse -decode -i webster.lzfse -o /dev/null
real 0m0.133s
user 0m0.091s
sys 0m0.036s
> time ./lzfse2 -decode -i webster.lzfse2 -o /dev/null
real 0m0.083s
user 0m0.053s
sys 0m0.025s
So, the version that ships on Mac OS X seems to be faster (10% at encoding, 35% at decoding) than what this source and makefile produce. I don’t think that has to do with my way of building them, as I used the makefile (which uses -Os) to build the original tool, and any compiler flags will not have much effect on the one using the Mac OS X library.Worryingly, the two versions also produce different files (12,209,496 bytes for the GitHub code, 12,234,159 bytes for the library on Mac OS X 10.11.5), but they can decompress each others files and produce the original file.