Joel Rosdahl [Thu, 22 Jul 2021 11:06:40 +0000 (13:06 +0200)]
Move/split statistics functionality into core and storage::primary
- The Counters class has been moved to core::StatisticsCounters.
- Functionality in the Statistics namespace has been split into:
- core::StatsLog: Knows about “stats log” format.
- core::Statistics: Knows about properties of statistics fields and
how to present them.
- storage::primary::PrimaryStorage: Knows how to store and update
statistics in the primary storage backend.
- storage::primary::StatsFile: Knows about the “stats file” format.
Joel Rosdahl [Mon, 19 Jul 2021 10:50:20 +0000 (12:50 +0200)]
HTTP storage: Fix crash when not specifying port
Url::port(const std::string&) apparently doesn’t accept an empty string
as the port (even though Url::port() can return an empty string), so
work around that.
Joel Rosdahl [Fri, 16 Jul 2021 20:12:17 +0000 (22:12 +0200)]
Improve secondary storage framework
- Let the secondary storage framework create backend instances on demand and
track their failure state - the framework will stop calling a backend after a
connection error/timeout. This makes it possible for a backend to create a
connection in the constructor if wanted.
- Added API and implementation for redacting secrets in secondary storage URLs
and attributes. Passwords in URLs are now redacted in debug logs but not for
"ccache -p" and "ccache -k secondary_storage".
- Adapted existing storage backends to the new APIs. In particular, the Redis
backend could be simplified.
- Moved the SecondaryStorage class to src/storage/secondary, analogous to
PrimaryStorage which is in src/storage/primary.
Joel Rosdahl [Sun, 11 Jul 2021 19:57:40 +0000 (21:57 +0200)]
Remove read-only tests of HTTP and Redis storage backends
The “read-only” tests in secondary_http and secondary_redis were
inspired by the “read-only” test in secondary_file. However, that test
actually verifies the secondary storage *framework*, not the storage
backend itself, so it’s enough to just do it in secondary_file.
Joel Rosdahl [Sun, 11 Jul 2021 19:51:49 +0000 (21:51 +0200)]
Make secondary_http and secondary_redis tests independent
Instead of starting an HTTP or Redis server that lives for the duration
of the test suite, start a new one for each test case. This makes tests
more independent and also opens up for future testing of e.g. different
ports and authentication modes by allowing different server
configurations for each test case.
Joel Rosdahl [Sat, 10 Jul 2021 19:24:35 +0000 (21:24 +0200)]
Touch up Redis storage code slightly
Note: Unlike atoi, std::stoi throws an exception on conversion error so
use Util::parse_unsigned instead which throws an exception that is
caught correctly.
Gregor Jasny [Mon, 5 Jul 2021 18:18:18 +0000 (20:18 +0200)]
Fix CMake feature detection (#883)
When enabling CMake policy
<https://cmake.org/cmake/help/latest/policy/CMP0067.html> by either enabling it
directly or via a `cmake_minimum_required` of `3.8` or later, the
`test.inode_cache` test starts to fail.
This happens because this policy slightly changes the `CheckCSourceCompiles`
logic by passing-in any configured C-standard. The detection of the following
features now report absence:
To remedy the situation CMake now checks for those features within a C++
language context. In C++ those features seem to be available without enabling
any extra extensions.
It also makes the check more precise because all of the consumers are C++ (and
not C) compilation units.
Joel Rosdahl [Thu, 1 Jul 2021 06:34:54 +0000 (08:34 +0200)]
Fix source file suffix selection for libblake3
In the add_source_if_enabled function in
src/third_party/blake3/CMakeLists.txt, the suffix variable is unset on a
CMake reconfigure in an already configured build tree. This makes CMake
guess the extension and always choose “.c” on a reconfigure.
Gregor Jasny [Tue, 29 Jun 2021 09:42:50 +0000 (11:42 +0200)]
Fix Apple Clang detection
Apple Clang, when called via `gcc` emits a `Configured with` line
on stderr which confuses the compiler detection. We just ignore
stderr for the `--version` query now.
Joel Rosdahl [Sun, 27 Jun 2021 18:34:06 +0000 (20:34 +0200)]
Include $PWD in hash for -fprofile-generate with relative directory
For a relative profile directory D, GCC stores $PWD/D as part of the
profile filename in an object file generated with -fprofile-generate, so
we need to include the same information in the hash.
Joel Rosdahl [Wed, 23 Jun 2021 14:27:51 +0000 (16:27 +0200)]
Implement configurations, API and framework for secondary storage
This introduces the possibility to add one or several secondary storage
backends to query after the primary cache storage. Note that cache
statistics counters will still be kept in the primary cache directory --
secondary storage backends only store cache results and manifests.
The API should now be ready enough to implement secondary storage
backends.
The framework is also ready enough for usage, but lacks two major things
that are still to be implemented:
1. Improved statistics handling. Up until now, ccache always increments
exactly one statistics counter for each invocation (e.g. “hit”,
“miss” or “some error”). Since I want to have separate statistics for
primary and secondary storage, this model no longer works since an
invocation can result in both a “primary miss” and a “secondary hit”.
2. Improved PrimaryStorage interface. The SecondaryStorage interface
works with memory data, but PrimaryStorage, Result and Manifest still
work with files at the API level. This means that if an invocation is
a primary storage miss but a secondary storage hit, the data from
secondary storage has to be written to a temporary file only to be
read back into memory again by the Result/Manifest deserialization
code.