Orgad Shaneh [Wed, 5 Oct 2022 18:24:14 +0000 (21:24 +0300)]
fix: Retain line CRLF in compiler output on Windows (#1173)
When the cached data is read, the output to fd is binary
(Util::send_to_fd), so in order to maintain the original
line endings, the output must be stored as binary too.
Joel Rosdahl [Tue, 4 Oct 2022 19:31:12 +0000 (21:31 +0200)]
feat: Improve handling of -frandom-seed and description of sloppiness
I should not be necessary to distinguish between existence and
non-existence of -frandom-seed if random_seed sloppiness is requested,
so don't hash the "-frandom-seed=" part either.
Joel Rosdahl [Mon, 3 Oct 2022 18:18:03 +0000 (20:18 +0200)]
feat: Improve statistics for remote hits/misses
ccache collects statistics about local and remote storage layer get/put
operations and describes them as "local/remote hits/misses" in the
output of "ccache -s". However, since "hits" and "misses" mean "result
hit/miss" in the "cacheable calls" section, it's easy to think that they
measure the same thing.
This commit improves the situation by:
- Adding new "local/remote hits/misses" counters that mean "result
hit/miss". These are shown if remote storage is used (since they
otherwise are redundant and equal to the normal "hits/misses"
counters) or if the -v/--verbose option is given.
- Presenting the previous "local/remote hits/misses" counters as
"local/remote reads". Only shown in verbose mode.
- Adding "local/remote writes" counters. Only shown in verbose mode.
Joel Rosdahl [Sun, 25 Sep 2022 18:28:40 +0000 (20:28 +0200)]
chore: Rename primary/secondary storage to local/remote storage
There is a feature request to be able not to use a local cache at all,
only a network cache. With such a feature, the names "primary storage"
and "secondary storage" make less sense since ccache would be operating
in "secondary only" mode, but then that storage would of course become
the primary (and only).
Let's rename "primary storage" to "local storage" and "secondary
storage" to "remote storage" – operating in "remote only" mode then
makes sense.
One of the original motivations to call networked storage "secondary" is
that the file storage can be used for local file systems as well, making
such storage "not quite remote", but in practice I guess the file
storage backend used primarily for network file systems.
Joel Rosdahl [Tue, 20 Sep 2022 17:05:38 +0000 (19:05 +0200)]
feat: Use subsecond timestamps for include file check
To avoid a race condition, ccache disables the direct mode if an include
file has a too new mtime or ctime. Previously this check used one second
resolution timestamps, which meant that a generated include file often
would disable direct mode hits for up to one second. Now ccache uses
timestamps with subsecond resolution (nanoseconds on Linux), so the
direct mode will in practice no longer have to be disabled for generated
include files.
Joel Rosdahl [Wed, 14 Sep 2022 19:19:14 +0000 (21:19 +0200)]
feat: Merge local manifest with fetched remote manifest
With read-only secondary storage, it can happen that primary storage has
a manifest named M with a result entry R1, while secondary storage also
has a manifest M but with result R2. On a compilation that matches R2,
ccache will first succeed to look up M in primary storage, fail to find
R2 and then get M from secondary storage where R2 can be found. Since M
already exists locally, ccache will simply return the cache hit but not
store knowledge of R2 locally. On a rebuild of R2, ccache therefore
needs to fetch from secondary storage again.
The improvement brought by this commit is that ccache now merges the
manifests from primary and secondary storage and stores the merged
version in primary storage. In other words, ccache setups with read-only
secondary storage will be able to accumulate local header file
combinations and seamlessly combine them with changes from secondary
storage.
Joel Rosdahl [Sun, 11 Sep 2022 11:48:05 +0000 (13:48 +0200)]
chore: Simplify cache entry reading and writing
Cache entries are now fully read into memory before (de)compressing,
checksumming and parsing, instead of streaming data like before. While
this increases memory usage when working with large object files, it
also simplifies the code a lot. Another motivation for this change is
that cache entry data is not streamed from secondary storage anyway, and
it makes sense to keep the architecture simple and similar for primary
and secondary storage code paths.
The cache entry format has modified so that the checksum covers the
potentially compressed payload (plus the header), not the uncompressed
payload (plus the header) like before. The checksum is now also stored
in an uncompressed epilogue. Since the cache entry format has been
changed, the input hash has been changed as well.
Joel Rosdahl [Mon, 5 Sep 2022 18:23:21 +0000 (20:23 +0200)]
refactor: Use memory buffers instead of streams for results
- Result objects now only know and care about the result payload part of
a result cache entry.
- Result object are no longer tightly coupled with the primary storage
implementation.
This is part of a larger refactoring effort with the goal of simplifying
how cache entries are read and processed.
Joel Rosdahl [Tue, 30 Aug 2022 18:34:32 +0000 (20:34 +0200)]
chore: Remove share-hits attribute for secondary storage
[1] added a share-hits attribute for secondary storages so that it's
possible to avoid sharing hits to primary storage for a specific
secondary storage. I believe that nobody needs that level of control --
what one would like is the ability to not use the primary storage at
all. Such a feature will be added in a a future commit, but for now the
share-hits=false functionality is just in the way, so let's remove it.
Joel Rosdahl [Sat, 27 Aug 2022 18:04:26 +0000 (20:04 +0200)]
test: Disable "output file failure" test for unsupported filesystem
The "Failure to write output file" test assumes that the filesystem
supports read-only directories. Improve this by probing this assumption
before running the test.
Joel Rosdahl [Fri, 5 Aug 2022 14:39:29 +0000 (16:39 +0200)]
feat: Improve inode cache robustness
- Only enable the inode cache at compile-time if it's possible to
determine filesystem type.
- Only use the inode cache at run-time if the filesystem type is known
to work with the inode cache instead of refusing just on NFS.