编译加速 remote cache

本文介绍了一种名为remotecache的远程编译缓存技术,该技术通过将编译输入的SHA码作为key与编译输出建立对应关系,存储在远程缓存中,从而加速编译过程。当进行编译时,若能找到匹配的key则直接获取对应的value,否则在本地进行编译并考虑是否更新远程缓存。此外还讨论了distcc和BuildGrid等分布式编译方案。
remote cache
大致原理就是根据编译输入的sha码与编译输出建立(key,value)对,存储在远端cache.编译过程如果能匹配到key,则获取GET到value.
如果hit不到key,则客户端在本地编译,并控制是否更新远端缓存库.

https://github.com/buchgr/bazel-remote/
(
https://golang.org/pkg/net/http/
) KEY: bazel-remote/server/http.go
.......
docker run -d -v `pwd`/bazel_cache/:/data -p 8080:8080 buchgr/bazel-remote-cache --max_size=20

  build:remote --experimental_strict_action_env --remote_http_cache=http://192.168.1.102:8080
  build:remote --experimental_execution_log_file=/tmp/exec1.log
  build:remote --build_event_text_file=/tmp/bep.txt
  build:remote --remote_upload_local_results=false
  build:remote_cache --remote_upload_local_results=true

  [3,541 / 3,565] 12 actions, 7 running
  ...lation_world:simulation_world_service; 0s remote-cache
  .../backend/sim_control:sim_control; 0s remote-cache
  ...lation_world:simulation_world_service; 0s remote-cache
  Compiling .../dreamview/backend/main.cc; 0s remote-cache
  ...lation_world:simulation_world_updater; 0s remote-cache
  ...lation_world:simulation_world_updater; 0s remote-cache
  .../handlers:websocket_handler_test; 0s remote-cache
  [-----] .../backend/handlers:image_handler_cpplint ...

  ...  

  INFO: Elapsed time: 68.628s, Critical Path: 8.32s
  INFO: 1212 processes: 1212 remote cache hit.
  INFO: Build completed successfully, 3700 total actions
  modules/perception/proto/perception_lane.proto: warning: Import modules/common/proto/error_code.proto but not used.
  1============================
  [ OK ] Build passed!
  [INFO] Took 234 seconds
  ============================

===================================================================================================
distribute compilation 

  Some conclusions:
  Buildfarm: Now it maybe still exists much problems. The work plan of project Buildfarm https://github.com/bazelbuild/bazel/projects/1.
  Buildbarn: The implement of Buildfarm in go. So see Buildfarm.
  BuildGrid: This project is an open source proj by python. It seems may work for us, and not try yet.
  distcc: This proj may be mature, but cannot use in bazel directly.And the bazel team suggests that remote execution has made huge leaps in the past year and a half and should be ready for you to try as a replacement of distcc.

  In a word, try distcc or BuildGrid, and wait for Buildfarm.

在所有您想用来编译的机器上安装 distcc
启动每台机器上的 distcc 新进程
用变量名导出 DISTCC_HOSTS 环境变量
启动 distcc 监视器(这样就可以观察正在发生什么事!)
使用 CC=distcc ./configure ,而不是使用 ./configure 来进行配置
使用 make -j n ,而不是使用 make 或 make -j 2 来进行编译,其中,n 是 DISTCC_HOSTS中机器数目的两到三倍

 

转载于:https://www.cnblogs.com/cjyp/p/10622545.html

### 提高 Visual Studio 2022 编译速度的方法 为了提升Visual Studio 2022的编译效率,可以从多个方面入手优化配置和环境设置[^1]。 #### 配置并行构建 启用多核处理器的同时工作来加速C++项目的编译。这可以通过修改项目属性中的最大并发CL数选项实现。对于大多数现代计算机而言,将此值设为可用CPU核心数量加一通常能获得较好的效果。 ```cpp // 修改 .vcxproj 文件或通过图形界面调整如下参数 <PropertyGroup> <ClCompileMaximumParallelism>8</ClCompileMaximumParallelism> <!-- 假设有7个物理核心 --> </PropertyGroup> ``` #### 启用增量链接器 当仅部分文件被更改时,使用增量链接而非完全重新链接整个程序可节省大量时间。确保启用了“/INCREMENTAL”标志来进行增量链接操作。 ```batch # 在项目属性->链接器->常规中开启 /INCREMENTAL:YES 或者编辑 .vcxproj 添加如下项 <Link> <EnableIncrementalLinking>true</EnableIncrementalLinking> </Link> ``` #### 减少不必要的预处理指令 过多复杂的宏定义以及条件编译语句会拖慢编译流程。审查源码减少不必要使用的`#ifdef`等预处理命令有助于加快编译速度。 #### 更新至最新版本 保持软件处于最新的稳定版状态可以获得性能改进和其他修复补丁。定期检查是否有新的更新发布,并及时升级Visual Studio及其组件。 #### 利用远程缓存服务 如果团队成员共享相似的工作负载,则可以考虑采用二进制接口描述符(Blob)存储或其他形式的分布式编译技术,比如Microsoft提供的Remote Build Cache插件,它能够显著缩短大型解决方案初次编译所需的时间。 #### 调整磁盘读写策略 确保操作系统运行在一个快速稳定的SSD上;关闭实时防病毒扫描对工程目录的影响也可以有效防止因频繁IO请求造成的延迟问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值