Files
ssw-mpc/build/measure_ray_core4.py
T
rong 4bb573d98c feat: Ray C++ 内核接进 nax Rust + armv7 真交叉编译
Ray 这条线不绕 bazel:
- wheel 里的 ray/_raylet.so 就是编好的 C++ core(34113 个导出符号,
  3638 个 ray:: 符号 default 可见,含 CoreWorkerProcess::Initialize)
- ray/nax_ray_shim.cc:259 行 C ABI shim,复用 process_helper 的初始化路径
- 实测跑通:Rust 二进制作为 driver 接入真实 GCS+raylet,
  拿到 raylet 分配的 node_id(d190801c…),probe 通过

踩坑(都已固化进 ray/build.sh):
- raylet 只编了 Python worker pool → 注册时语言声明 PYTHON
- Ray C++ 是旧 ABI → -D_GLIBCXX_USE_CXX11_ABI=0
- fmt v9/v11 撞车 → FMT_HEADER_ONLY
- Debian absl 固定自家 optional → 影子头直通 std::optional
- _raylet.so 是 CPython 扩展(253 个 Py 符号)→ build.rs 自动链 libpython
- GcsNodeInfo 手写 wire format 解析,避免 protobuf 跨 ABI

armv7 交叉编译修正(原结论有误):
- 换 armv7-unknown-linux-musleabihf + rust-lld/link-self-contained
- 不再需要外部交叉 gcc,macOS 本机 83 秒出 687 KB 静态二进制
- .cargo/config.toml 固化,无需 export 任何变量

其他:nax-orch 告警清理;README/ZYNQ 文档对齐实测。
2026-10-30 11:31:02 +08:00

80 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""第四轮:用真实目标名构建,量时间/磁盘/体积/ABI。
目标:
//src/ray/raylet —— 每节点必跑的节点代理
//src/ray/core_worker:core_worker_lib —— 「链给 Rust」的那个 C++ 库
"""
import sys
import time
sys.path.insert(0, "/tmp")
import sbfix # noqa: F401
from cubesandbox import Sandbox
SID = "ccb00b05e9f045d99fd99a6e2aecd20b"
JOBS = "8"
def log(m=""):
print(m, flush=True)
def main():
t_all = time.time()
sb = Sandbox.connect(SID)
def sh(cmd, t=120, label=""):
if label:
log(f"\n===== {label} =====")
try:
r = sb.commands.run(cmd, timeout=t)
except Exception as e:
log(f"[EXC] {type(e).__name__}: {e}")
return ""
out = (r.stdout or "").strip()
log(out if out else "(无输出)")
err = (r.stderr or "").strip()
if err:
log("STDERR: " + err[:400])
return r.stdout or ""
sh("df -h / | tail -1; du -sh /root/.cache/bazel", 60, "STEP0 起始状态")
t0 = time.time()
build = sh(
"cd /ray && S=$(date +%s); "
"bazel build -c opt --jobs=" + JOBS + " --noshow_progress "
"--distdir=/distdir --repository_cache=/root/bazelrepo "
"//src/ray/raylet //src/ray/core_worker:core_worker_lib 2>&1 | tail -40; "
"E=$(date +%s); echo BUILD_SECS=$((E-S))",
5400,
"STEP1 bazel build raylet + core_worker_lib",
)
wall = round(time.time() - t0)
log(f"\n>>> 墙钟 {wall}s = {wall/60:.1f} 分钟(jobs={JOBS} / 16 vCPU / 15 GB)")
sh(
"cd /ray && echo '--- 产物 ---'; "
"ls -lh bazel-bin/src/ray/raylet bazel-bin/src/ray/core_worker/libcore_worker_lib.a 2>/dev/null "
"| awk '{print $5, $9}'; "
"find bazel-bin/src/ray -name 'libcore_worker*' -o -name 'raylet' -type f 2>/dev/null | head -5; "
"echo '--- 磁盘 ---'; du -sh /root/.cache/bazel; du -sh bazel-bin; df -h / | tail -1; "
"echo '--- 动态依赖条数 ---'; ldd bazel-bin/src/ray/raylet 2>/dev/null | wc -l; "
"echo '--- 依赖清单 ---'; ldd bazel-bin/src/ray/raylet 2>/dev/null | awk '{print $1}' | tr '\n' ' '; echo; "
"echo '--- core_worker 静态库导出符号 ---'; "
"L=$(find bazel-bin -name 'libcore_worker_lib*.a' | head -1); echo $L; "
"nm --defined-only $L 2>/dev/null | grep -c ' T '; "
"nm --defined-only $L 2>/dev/null | grep ' T ' | grep -c '_Z'; "
"echo '--- 有无 extern \"C\" 入口 ---'; "
"nm --defined-only $L 2>/dev/null | grep -E ' T [a-z_]+$' | head -5; "
"echo end",
300,
"STEP2 产物 / 依赖 / ABI",
)
log(f"\n总耗时 {round(time.time()-t_all)}s")
main()