【问题标题】:No hits in GitLab CI for ccache在 GitLab CI 中没有命中 ccache
【发布时间】:2019-05-08 14:57:25
【问题描述】:

ccache 在 GitLab CI 中的缓存命中率为零,即使源不更改且缓存保持不变。

此外,每次构建运行时缓存的大小都会增加,这意味着它会一遍又一遍地重建。

【问题讨论】:

    标签: caching build continuous-integration gitlab ccache


    【解决方案1】:

    问题是 ccache 检查编译器是否相同的默认方式 - 通过其时间戳。由于每个 GitLab CI 实例运行一个全新的 Docker 容器,这个时间戳总是不同的,因此总是构建新的缓存。

    要解决此问题,请将CCACHE_COMPILERCHECK 设置为content,而不是默认的mtime

    来自 ccache 文档:

    compiler_check (CCACHE_COMPILERCHECK)
    By default, ccache includes the modification time (“mtime”) and size of the compiler in the hash to ensure that results retrieved from the cache are accurate. This setting can be used to select another strategy. Possible values are:
        content
            Hash the content of the compiler binary. This makes ccache very slightly slower compared to the mtime setting, but makes it cope better with compiler upgrades during a build bootstrapping process.
        mtime
            Hash the compiler’s mtime and size, which is fast. This is the default.
    

    【讨论】:

    • 也许明确指出这是关于 编译器,而不是编译后的文件。
    猜你喜欢
    • 2020-12-12
    • 1970-01-01
    • 2020-06-25
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 2022-07-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多