You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zstd is better than zlib in all aspects, and with negative compression levels it's as good as lz4 even for compression performance. The low overhead means that we can enable compression by default without negative consequences for the absolute majority of users.
What to do
Add zstd support.
Bundle libzstd for optional usage, just like we do with zlib. Let's try not bundling it.
Remove zlib support.
Rationale: Not keeping support for zlib means less dependencies and less complex code.
Edit: Changed from lz4 to zstd according to discussion below.
Not sure if a rebase is needed, seems that the old code still works "good enough" without it...
There's some strange things going on with latest LZ4 versions, so I've stayed on the previous:
LZ4 v1.9.1
LZ4 v1.9.0
Warning : this version has a known bug in the decompression function which makes it read a few bytes beyond input limit. Upgrade to v1.9.1 is recommended.
LZ4 v1.8.3
LZ4 v1.8.2
This is maintenance release, mainly triggered by a data corruption that can only occur in v1.8.2, at level 9 (only), for some "large enough" data blocks (> 64 KB)
LZ4 v1.7.5
The main reason for staying with gzip (-1) as default was that the difference was not "big enough",
adding a new compression meant invalidating the cache - and everyone has gzip, noone has lz4.
If we want to do this for the manifest and result files, we need some kind of gzFile replacement...
Either work with a local memory buffer, or something implementing a similar stdio buffer interface.
Earlier implementations only used alternative compressions for the cache files, not the manifest.
So it worked directly on the individual files, rather than attempting to do any stream compression.
It should be relatively straight-forward to implement lz4 support now after a41ea79 and fa398de.
Since the compression abstraction already is done and does not impose much complexity on other code, I'm now positive to keep zlib support in addition to lz4. I'm now also OK with keeping support for not compressing since it's essentially of no implementation cost. @afbjorklund: Opinions?
zstd fills all the use cases of both lz4 and gzip. I think you should go straight to zstd, as then the compression setting means alot more. With gzip the setting means hardly anything (and everyone uses -9).
There also is the possibility of fixing hard-link mode by updating mtimes when a hard link gets a cache hit. (so it doesn't confuse make/ninja)
if hard link mode worked, then only heavier compression levels really make much sense, as you can't hard link with compression (unless you have transparent compression, but that is a differn't matter entirely)
zstd fills all the use cases of both lz4 and gzip.
That's a bold claim. My impression from when I looked at different alternatives was that zstd is better than gzip/libz in all aspects, but it does not match lz4 when it comes to speed. Do you have more information or insights than what's indicated by benchmarks and articles found on the net?
Yes, I think that replacing zlib with zstd makes sense. I also think that it makes sense to let the default compression method be the fastest method available so that we can say that the performance overhead is negligible.
Note that since a compression abstraction now is in place, the complexity cost of having several algorithms to choose from is less than what I originally imagined when I wrote this issue. I'll update the issue description to reflect this.
(and everyone uses -9).
Off topic, of course, but have you ever run tar -czf foo.tar.gz something? Then you've used gzip without using -9. My guess is that more people use the default -6 level than anything else.
There also is the possibility of fixing hard-link mode by updating mtimes when a hard link gets a cache hit. (so it doesn't confuse make/ninja)
I don't understand what you mean. The mtime is already updated when there is a cache hit. That's one of the problems with the hard link mode. What do you mean should/could be done?
Or did you mean to say "fixing hard-link mode by not updating mtimes [on] a cache hit"? If so, yes, that would of course be possible, but it would be a backward incompatible change that I would like to avoid if possible.
if hard link mode worked, then only heavier compression levels really make much sense
That line of reasoning doesn't cover all use cases. For instance:
The cache can be on another file system, so hard links cannot be used.
The cache can, in the future, be stored in some other way, e.g. memcached, so hard links cannot be used.
One might not want to use hard links because modifying a hard-link object file in place will corrupt the cache entry.
One might not want to use hard links because they have the above mentioned mtime problem.
@shawnl: Your suggestion about zstd piqued my interest to have a look at zstd again.
I learned that zstd has a --fast=# (AKA "negative levels") option. I'm not sure if I missed that when I evaluated different algorithms a little over a year ago or if it's something new (edit: yes, it seems to be a relatively new feature), but from some quick experiments they look very promising. I've mostly looked at compression performance since that's what I'm most interested in in this case; decompression speed doesn't feel like an issue. On a test corpus of a large file containing various concatenated object files which I hope are representative, zstd --fast=4 beat lz4 -1 on compression speed while at the same time producing a slightly smaller file! Decompression speed was not as high as lz4, but near enough.
I've now changed my mind and agree that it looks like zstd fits all use cases I see for ccache regarding compression. Unless @afbjorklund disagrees (@pavsa maybe has an opinion as well?), I think that we'll go with zstd instead (and remove zlib support).
For instance one would have to figure out how to install it on Mac and Win, and on Travis...
i.e. Travis run on Ubuntu 14.04, whereas the "libzstd-dev" package first appeared in 16.04
Travis provides both 14.04 and 16.04, so unless you need to test on 14.04, this is not a problem (and even for 14.04 it's possible to get it from an extra repo, although there's not an official one). Icecream has recently added zstd support and it builds in Travis (including Mac).
El dom., 23 de jun. de 2019 14:13, Luboš Luňák <[email protected]>
escribió:
For instance one would have to figure out how to install it on Mac and
Win, and on Travis...
i.e. Travis run on Ubuntu 14.04, whereas the "libzstd-dev" package first
appeared in 16.04
Travis provides both 14.04 and 16.04, so unless you need to test on 14.04,
this is not a problem (and even for 14.04 it's possible to get it from an
extra repo, although there's not an official one). Icecream has recently
added zstd support
Why wasn't distcc ever told about this? What is the documentation of the
protocol. I have zstd patches for distcc, including protocol documentation.
Travis provides both 14.04 and 16.04, so unless you need to test on 14.04, this is not a problem (and even for 14.04 it's possible to get it from an extra repo, although there's not an official one). Icecream has recently added zstd support and it builds in Travis (including Mac).
Thanks @llunak, that's useful to know. (And thanks for not continuing the discussion about distcc here.)
Activity
jrosdahl commentedon May 5, 2019
Related old pull request with broader scope: #118.
afbjorklund commentedon May 6, 2019
This could probably also do with some benchmarks.
afbjorklund commentedon May 9, 2019
Not sure if a rebase is needed, seems that the old code still works "good enough" without it...
There's some strange things going on with latest LZ4 versions, so I've stayed on the previous:
LZ4 v1.9.1
LZ4 v1.9.0
LZ4 v1.8.3
LZ4 v1.8.2
LZ4 v1.7.5
The main reason for staying with gzip (-1) as default was that the difference was not "big enough",
adding a new compression meant invalidating the cache - and everyone has gzip, noone has lz4.
afbjorklund commentedon May 9, 2019
Rebased the old code: #421 (could be cleaned up further, but #118 had too much cruft in it now)
afbjorklund commentedon May 9, 2019
The performance seems to again vary a lot, so thankful for someone else testing it out as well...
afbjorklund commentedon May 9, 2019
Hmm, the above was only headers - and the stderr and manifest are still using gzip compression...
So that was a bad test, basically not using lz4f. Unfortunately per on ccache.c doesn't work anymore ?
Seems like there might be some merit to the later versions of LZ4 and the special path for short files:
afbjorklund commentedon May 26, 2019
If we want to do this for the manifest and result files, we need some kind of gzFile replacement...
Either work with a local memory buffer, or something implementing a similar stdio buffer interface.
Earlier implementations only used alternative compressions for the cache files, not the manifest.
So it worked directly on the individual files, rather than attempting to do any stream compression.
jrosdahl commentedon Jun 5, 2019
It should be relatively straight-forward to implement lz4 support now after a41ea79 and fa398de.
Since the compression abstraction already is done and does not impose much complexity on other code, I'm now positive to keep zlib support in addition to lz4. I'm now also OK with keeping support for not compressing since it's essentially of no implementation cost. @afbjorklund: Opinions?
shawnl commentedon Jun 12, 2019
zstd fills all the use cases of both lz4 and gzip. I think you should go straight to zstd, as then the compression setting means alot more. With gzip the setting means hardly anything (and everyone uses -9).
shawnl commentedon Jun 12, 2019
There also is the possibility of fixing hard-link mode by updating mtimes when a hard link gets a cache hit. (so it doesn't confuse make/ninja)
if hard link mode worked, then only heavier compression levels really make much sense, as you can't hard link with compression (unless you have transparent compression, but that is a differn't matter entirely)
jrosdahl commentedon Jun 13, 2019
That's a bold claim. My impression from when I looked at different alternatives was that zstd is better than gzip/libz in all aspects, but it does not match lz4 when it comes to speed. Do you have more information or insights than what's indicated by benchmarks and articles found on the net?
Yes, I think that replacing zlib with zstd makes sense. I also think that it makes sense to let the default compression method be the fastest method available so that we can say that the performance overhead is negligible.
Note that since a compression abstraction now is in place, the complexity cost of having several algorithms to choose from is less than what I originally imagined when I wrote this issue. I'll update the issue description to reflect this.
Off topic, of course, but have you ever run
tar -czf foo.tar.gz something? Then you've used gzip without using -9. My guess is that more people use the default -6 level than anything else.jrosdahl commentedon Jun 13, 2019
I don't understand what you mean. The mtime is already updated when there is a cache hit. That's one of the problems with the hard link mode. What do you mean should/could be done?
Or did you mean to say "fixing hard-link mode by not updating mtimes [on] a cache hit"? If so, yes, that would of course be possible, but it would be a backward incompatible change that I would like to avoid if possible.
That line of reasoning doesn't cover all use cases. For instance:
[-]Switch from zlib to LZ4[/-][+]Add support for compression using LZ4[/+]jrosdahl commentedon Jun 14, 2019
@shawnl: Your suggestion about zstd piqued my interest to have a look at zstd again.
I learned that zstd has a
--fast=#(AKA "negative levels") option. I'm not sure if I missed that when I evaluated different algorithms a little over a year ago or if it's something new (edit: yes, it seems to be a relatively new feature), but from some quick experiments they look very promising. I've mostly looked at compression performance since that's what I'm most interested in in this case; decompression speed doesn't feel like an issue. On a test corpus of a large file containing various concatenated object files which I hope are representative,zstd --fast=4beatlz4 -1on compression speed while at the same time producing a slightly smaller file! Decompression speed was not as high as lz4, but near enough.I've now changed my mind and agree that it looks like zstd fits all use cases I see for ccache regarding compression. Unless @afbjorklund disagrees (@pavsa maybe has an opinion as well?), I think that we'll go with zstd instead (and remove zlib support).
16 remaining items
pavsa commentedon Jun 16, 2019
or as a git submodule from their repository?
jrosdahl commentedon Jun 16, 2019
That won't be helpful for people building from a release archive.
afbjorklund commentedon Jun 16, 2019
Implementation done, and rebased.
There are currently some build errors on master, where the
make analyzetarget is failing.llunak commentedon Jun 23, 2019
Travis provides both 14.04 and 16.04, so unless you need to test on 14.04, this is not a problem (and even for 14.04 it's possible to get it from an extra repo, although there's not an official one). Icecream has recently added zstd support and it builds in Travis (including Mac).
shawnl commentedon Jun 23, 2019
llunak commentedon Jun 23, 2019
Why should it? Distcc is practically an unrelated project to Icecream. (And in case you want to discuss this further, -> https://github.com/icecc/icecream/ , this discussion is about ccache.)
shawnl commentedon Jun 23, 2019
llunak commentedon Jun 23, 2019
I've told you what to do if you want to discuss that. It's off-topic here and I don't want to take part in hijacking this discussion.
jrosdahl commentedon Jun 24, 2019
Thanks @llunak, that's useful to know. (And thanks for not continuing the discussion about distcc here.)
Require libzstd and remove zlib support
kreuzerkrieg commentedon May 5, 2020
What if you submit a good chunk of
ccachefiles to Squash as new corpus and just see results? Or in case the dataset is too big just roll your own server for running these benchmarks - https://github.com/quixdb/squash-benchmark-web/Refresh ccache Windows console patches