You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Rust包在aarch64架构下的构建时长是x86-64的2倍?

多架构软件包构建性能分析:Rust vs Go在AWS EC2实例上的表现

我负责为Intel64和ARM64架构编译一系列软件包,打包为.rpm、.deb、.apk格式,并构建对接Artifactory的流水线。我们为GitHub Enterprise Server搭建了自研原生ARM64运行器,搭配现有自研Intel64运行器,均基于亚马逊EC2计算优化实例,硬件配置如下:

CPU架构实例类型vCPUs内存uname -m
amd64/x86_64c5.2xlarge816 GBx86_64
arm64/aarch64c6g.2xlarge816 GBaarch64
arm64/aarch64c7g.2xlarge816 GBaarch64

宿主为运行EKS优化版Amazon Linux 2的EKS集群,运行器为单次工作流后销毁重建的K8S/EKS Pod(类Docker容器),采用多平台镜像,容器系统为Ubuntu "Focal Fossa" 20.04 LTS。

通过自研GitHub Actions运行器编写工作流,分别在Intel和ARM64运行器上下载Rust项目源码编译并验证架构正确性。选取lychee作为测试对象,构建脚本如下:

sudo apt-get -y update
sudo apt-get -y install --no-install-recommends \
  build-essential \
  ca-certificates \
  curl \
  file \
  git \
  gpg \
  gpg-agent \
  gzip \
  libssl-dev \
  openssh-client \
  pkg-config \
  software-properties-common \
  tar \
  wget \
  ;

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "${HOME}/.cargo/env"

# shellcheck disable=2154
wget --header "Authorization: Bearer ${GITHUB_TOKEN}" \
    "https://github.com/lycheeverse/lychee/archive/refs/tags/v0.15.1.tar.gz"
tar zxvf "v0.15.1.tar.gz"

### Start measuring time

cd "lychee-0.15.1/" || true
cargo fetch --target="${ARCH}-unknown-linux-gnu" --locked
cargo install cargo-auditable --locked

# The `mold` linker is pre-installed.
mold -run cargo auditable build --timings --frozen --release

sudo install -Dm755 target/release/lychee -t "/usr/local/bin/"

### Stop measuring time

5次构建平均时长:

  • Intel(c5):6分18秒(基准)
  • Graviton 2(c6g):12分2秒(约2倍)
  • Graviton 3(c7g):9分36秒(约1.5倍)

预期架构间性能相当或ARM64略优,但实际Rust构建在ARM64上表现不佳,怀疑是Rust构建流水线在glibc Linux的ARM64上未充分优化。为排除硬件问题,后续测试Go项目OpenTofu(超30万行代码,含外部依赖),结果如下:

  • Intel(c5):3分35秒(基准)
  • Graviton 3(c7g):2分18秒(约0.64倍)

ARM64性能提升36%,排除Graviton硬件问题,推测问题源于Rust或lychee本身。

内容的提问来源于stack exchange,提问作者Ryan Parman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 08:13:24