Live data from Hacker News

Apple Open-Sources its Compression Algorithm LZFSE

infoq.com

21–30 of 219 posts

Re: Apple Open-Sources its Compression Algorithm LZFSE

#25
post #8

Earlier quoted context omitted.

Basically an Apple-specific reimplementation of Zstd: https://github.com/Cyan4973/zstd

So, worse than LZ4 for what Apple seems to be using it for. Why didn't they just use LZ4? Confusing company, they are.

They are very much into NIH, seemingly out of paranoid fear of patent attacks (though not sure how it can protect them).

Re: Apple Open-Sources its Compression Algorithm LZFSE

#26

Waiting for first guy who take this implementation and run it through emscripten so we can actually use it in client -> server communication, eg sending compressed json payloads to the server.

Is running (not to mention downloading/parsing/compiling) emscriptened decompression code really that much faster than just transferring the data?

I think a better strategy would be to add support for LZFSE to the browsers themselves.

Re: Apple Open-Sources its Compression Algorithm LZFSE

#27
post #19

Kind of weak licence, what are you actually allowed to do with this code? Change it? Distribute your changes? https://github.com/lzfse/lzfse/blob/master/LICENSE

The very first paragraph answers the question:

> Redistribution and use in source and binary forms, with or without modification, are permitted[...]

Re: Apple Open-Sources its Compression Algorithm LZFSE

#28

If you want to see some crazy C code, check out this file from the GitHub repo: https://github.com/lzfse/lzfse/blob/master/src/lzvn_encode_b...

Excerpt from the link : if (D == D_prev) { if (L == 0) { *q++ = 0xF0 + (x + 3); // XM! } else { *q++ = (L >8 in 0..5 *q++ = (D >> 8) + (L = (1 34) { // Long dist *q++ = (L > 2) + (L

Blows my mind that people can come up with this stuff.

I'm assuming they came up with the mathematical proofs first and translated that into code, so that has something to do with it, correct?

It looks a lot like some crypto algorithms which are a nearly direct translation of the mathematical formulas.

It's not that it's incredibly difficult to follow, but it's just very "math like".

Re: Apple Open-Sources its Compression Algorithm LZFSE

#29
It's 2016. How can you launch a reasonably high profile open source project with code that looks like this? This fulfills all the TODO list for unreadable code. One character variable names, one character parameter names, full of magic numbers...

Yes. This is very performance critical code and I completely see the need to write very optimized code. That's fine. But optimizing code for speed shouldn't imply also optimizing it to use as few characters as possible.

Compression code is code that often runs at boundaries to the external world and thus is a very significant attack surface. To release compression code in a non-safe language is risky enough but then using what amounts to practically write-only code is, IMHO, irresponsible.

Post reply on HN