]> git.ipfire.org Git - thirdparty/ccache.git/commit
feat: Use base16 encoding for all hash digest keys
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Oct 2025 17:21:09 +0000 (19:21 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 25 Jan 2026 08:41:33 +0000 (09:41 +0100)
commit7d64f3baf1e99ebbaf185aeef5426f04de0638de
treec007b69eada2243176e0b52dfafe8a0c0b9d6164
parent4d66feca1ca5a60ada8040d30b7a26a18c5594c7
feat: Use base16 encoding for all hash digest keys

This reverts the mixed encoding scheme introduced in commit 47cb00f7 ("Encode
hash digests as 4 base16 digits + 29 base32hex digits") back to pure base16
encoding.

Background: The mixed base16/base32hex encoding was introduced to reduce
filename lengths slightly, thereby reducing the number of system calls when
scanning local cache directories. At the time, "the effect is very small but
there is no real downside".

However, with the introduction of remote storage helpers implemented outside
ccache's code base, a downside has emerged: key encoding inconsistency. Remote
storage helpers must now either:

1. reimplement ccache's custom encoding algorithm to maintain key consistency
   between the remote storage and ccache's local storage (and logs), or
2. use standard base16 encoding, resulting in different key representations
   between ccache and the remote storage.

By standardizing on base16 encoding throughout, we ensure that:

- remote storage helpers can use simple, standard base16 encoding
- keys are represented identically in ccache's local storage and remote storage
- external implementations don't need to replicate custom encoding logic
- debugging and key correlation across systems is straightforward

The minor filesystem performance benefit of shorter filenames is outweighed by
the ecosystem benefits of a simple, standard encoding scheme.

Local storage will for now be backward compatible: to avoid invalidating
existing cache entries, ccache will write in the new format but will try
both the new and the legacy format on cache lookup. The legacy format is
also still used for hashes that are part of the input hash. When some
other input hash material is changed (which invalidates cache entries
anyway) in the future, we'll drop the legacy format completely.
15 files changed:
src/ccache/ccache.cpp
src/ccache/core/mainoptions.cpp
src/ccache/core/manifest.cpp
src/ccache/hashutil.cpp
src/ccache/storage/local/localstorage.cpp
src/ccache/storage/remote/filestorage.cpp
src/ccache/storage/remote/httpstorage.cpp
src/ccache/storage/remote/redisstorage.cpp
src/ccache/storage/storage.cpp
src/ccache/util/string.cpp
src/ccache/util/string.hpp
test/run
test/suites/base.bash
test/suites/direct.bash
unittest/test_hash.cpp