EdgeAgent WASM分析
用于细分和测量MCP Tool在WASM环境中运行时间的配置文件工具。
目的
CCGrid-2026论文的MCP Tool性能测量:
- 冷启动与热启动 分离测量
- 分解运行时间:T_io、T_serialize、T_compute
- 按节点比较:设备rpi、边缘nuc、边缘orin、云
测量项目
T_exec = T_cold + T_io + T_serialize + T_compute
Where:
- T_cold: WASM 모듈 로드 + 초기화 (warm이면 ≈ 0)
- T_io: 파일/네트워크 I/O 시간
- T_serialize: JSON-RPC 파싱 + 응답 직렬화
- T_compute: 순수 연산 시간目录结构
EdgeAgent-wasm-profiling/
├── README.md # 이 파일
├── docs/
│ └── methodology.md # 측정 방법론 상세
├── scripts/
│ ├── measure_tools.py # 메인 측정 스크립트
│ ├── analyze_results.py # 결과 분석
│ └── setup_test_data.sh # 테스트 데이터 준비
├── test_data/ # 테스트용 파일들
│ ├── files/ # 텍스트/JSON 파일
│ └── images/ # 이미지 파일
├── results/ # 측정 결과 (노드별)
│ ├── device-rpi/
│ ├── edge-nuc/
│ ├── edge-orin/
│ └── cloud/
└── wasm_modules/ # WASM 바이너리 (빌드 후 복사)前提条件
所有节点都需要
- Python 3.8+
- 是时候了(
curl https://wasmtime.dev/install.sh -sSf | bash)
构建WASM模块(在开发机器上)
cd ~/EdgeAgent/wasm_mcp
cargo build --target wasm32-wasip2 --release用法
1.存储库克隆(在每个节点上)
git clone ~/EdgeAgent-wasm-profiling
cd ~/EdgeAgent-wasm-profiling2.准备测试数据
./scripts/setup_test_data.sh3.复制WASM模块
# 빌드된 WASM 모듈을 wasm_modules/ 디렉토리에 복사
cp ~/EdgeAgent/wasm_mcp/target/wasm32-wasip2/release/*.wasm ./wasm_modules/4.运行测量
# 모든 tool 측정
python3 scripts/measure_tools.py
# 특정 tool만 측정
python3 scripts/measure_tools.py --tool read_file
# Cold start만 측정
python3 scripts/measure_tools.py --mode cold
# Warm start만 측정
python3 scripts/measure_tools.py --mode warm5.结果分析
python3 scripts/analyze_results.py测量方式
Cold Start测量
每次运行创建一个新的wasmtime进程:
wasmtime run --dir=/tmp tool.wasm < request.jsonWarm Start测量(连续运行)
在同一进程中处理多个请求(HTTP模式):
# HTTP 서버 모드로 실행
wasmtime run --dir=/tmp tool-http.wasm &
curl -X POST http://localhost:8080 -d @request.json时间分解
- 外部测量:总运行时间(wall clock)
- 内部测量:在Tool中分离I/O、serialize和compute
- 响应 _timing 包括字段
输出格式
测量结果JSON
{
"tool_name": "read_file",
"node": "edge-nuc",
"mode": "cold",
"input_size": 52428800,
"output_size": 52521119,
"runs": 5,
"timing": {
"total_ms": 14289.5,
"cold_start_ms": 50.2,
"io_ms": 14100.0,
"serialize_ms": 89.3,
"compute_ms": 50.0
},
"measurements": [14312, 14256, 14289, 14301, 14290]
}参考
- 荧光闪烁논문:“WebAssembly作为无服务器运行时的性能特征”
- MCP(模型上下文协议):https://modelcontextprotocol.io/
相关文件
- WASM MCP服务器:
~/EdgeAgent/wasm_mcp/ - 现有测量结果:
~/final_result_for_scheduling/node-exectime-inputsize/
