8.5 Ports 构建调优
最后更新于
tmpfs /tmp tmpfs rw 0 0ccache 工作原理
首次编译(Cache Miss):
源代码 ──► ccache ──► 编译器 ──► 目标文件
│
└──► 存入缓存
重复编译(Cache Hit):
源代码 ──► ccache ──► 直接输出目标文件
│
└──► 命中缓存(跳过编译)# pkg install ccache# cd /usr/ports/devel/ccache/
# make install clean# ls -al /usr/local/libexec/ccache
total 56
drwxr-xr-x 3 root wheel 15 Sep 20 02:02 .
drwxr-xr-x 18 root wheel 49 Sep 20 01:39 ..
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 CC -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 c++ -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 cc -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 clang -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 clang++ -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 clang++15 -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 02:02 clang++18 -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 clang15 -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 02:02 clang18 -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 cpp13 -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 g++13 -> /usr/local/bin/ccache
lrwxr-xr-x 1 root wheel 21 Sep 20 00:29 gcc13 -> /usr/local/bin/ccache
drwxr-xr-x 2 root wheel 15 Sep 20 02:02 worldWITH_CCACHE_BUILD=yes# ccache -M 10G
Set cache size limit to 10.0 GB
root@ykla:/usr/ports/www/chromium # ccache -s
cache directory /root/.ccache
primary config /root/.ccache/ccache.conf
secondary config (readonly) /usr/local/etc/ccache.conf
cache hit (direct) 0
cache hit (preprocessed) 0
cache miss 0
cache hit rate 0.00 %
cleanups performed 0
files in cache 0
cache size 0.0 kB
max cache size 10.0 GB# ccache -s
cache directory /root/.ccache
primary config /root/.ccache/ccache.conf
secondary config (readonly) /usr/local/etc/ccache.conf
stats updated Fri Sep 20 02:05:35 2024
cache hit (direct) 20
cache hit (preprocessed) 17
cache miss 918
cache hit rate 3.87 %
called for link 121
called for preprocessing 26
compile failed 115
preprocessor error 66
bad compiler arguments 15
autoconf compile/link 523
no input file 71
cleanups performed 0
files in cache 2305
cache size 0.0 kB
max cache size 10.0 GB# pkg install ccache4# cd /usr/ports/devel/ccache4/
# make install clean# ccache -M 20G
Set cache size limit to 20.0 GB# ccache -s
Cacheable calls: 558 / 579 (96.37%)
Hits: 110 / 558 (19.71%)
Direct: 110 / 110 (100.0%)
Preprocessed: 0 / 110 ( 0.00%)
Misses: 448 / 558 (80.29%)
Uncacheable calls: 21 / 579 ( 3.63%)
Local storage:
Cache size (GB): 0.0 / 20.0 ( 0.11%)
Hits: 110 / 558 (19.71%)
Misses: 448 / 558 (80.29%)# ccache -p
(default) absolute_paths_in_stderr = false
(default) base_dir =
(default) cache_dir = /root/.cache/ccache
……省略一部分……# pkg install axel# cd /usr/ports/ftp/axel/
# make install cleanFETCH_CMD=axel # 设置使用 axel 作为下载工具
FETCH_BEFORE_ARGS=-n 10 -a # 设置 axel 下载前的参数:使用 10 个线程并显示替代进度条
FETCH_AFTER_ARGS= # 下载后执行的命令参数为空
DISABLE_SIZE=yes # 禁用文件大小检查# cd /usr/ports/www/wget2/ && make install cleanFETCH_CMD=wget2 # 设置使用 wget2 作为下载工具
FETCH_BEFORE_ARGS=-c -t 3 --max-threads=16 # 设置 wget2 下载前的参数
FETCH_AFTER_ARGS= # 下载后执行的命令参数为空
DISABLE_SIZE=yes # 禁用文件大小检查