WebAssembly 简介 - 陈思衡第三届中国Rust开发者大会 WebAssembly 简介 WebAssembly(简称 Wasm)是一种新的编译目标,帮助在 web 中运行高性能应用。它是一种低级语言,设计为编 译器目标,以在 web 浏览器中高效运行。 WebAssembly 介绍 WebAssembly 代码可以以接近原生的速度 运行,且具有很小的二进制大小和快速加 载速度。 # 高性能 WebAssembly chart Wasm 的 memory 是 host 内存中的一部分。 对于 Wasm 而言,这块内存是从 0 开始的,而不是 host 所看到的地址。 WebAssembly 机制 memory Wasm 编写的 function 可以通过 “export” 导出给 host 调用。 Host 可以把自己的 function 通过 “import“ 提供给 wasm 调用。 function 简介 Photo / image / chart Wasm 实例 WebAssembly 简介 WASI 简介 WebAssembly System Interface (简称 WASI),它定义了一组 WASM 模块可以调用的系统调用接口。WASI 的目的是让 WASM 模块可以访问底层系统的功能,比如文件系统、网络等。这使得 WASM 可以作为一个更广泛的 运行时,不仅仅局限于浏览器环境。WASI0 码力 | 24 页 | 773.46 KB | 1 年前3
应用 waPC (rust) 做软件测试工具waPC? WASM 外部函数 接口 FFI Input type Return type Platform 底层 I32 I32 Unknown waPC &[u8] Result,error > Linux x86_64, macOS x86_64 ,Wi ndows x86_64, … cargo build —target wasm- unknown-unknown Rust • Read wasm file • Select engine • Wazero • Wasmer-go • Wasmertime-go • Define hostcall capability • Instantiate • Invoke - command with data • Guest 指 wasm • Operation 是我们要在 wasm 里注册 命名 • 以数据的长度,设置 以数据的长度,设置 wasm 的 linear memory 的指针 • Guest 可执行任务 • Guest 也可返回请求 host Invoke(ctx,operation,payload) WAPC 流程 • Uses Length of response and error to return result res,err:= Invoke… WAPC 流程 #[no_mangle] 0 码力 | 30 页 | 2.50 MB | 1 年前3
运⾏在浏览器中的 P2P ⽹络 - 李敏成Implementations in Rust Lib Runtime webrtc-rs native with tokio web-sys browser Browser Node (WASM) + Server Node (Native) Implement once (part of), run anywhere! Introduce rings-node A structured structured P2P network implementation. Using WebRTC and Chord algorithm. With full WebAssembly (WASM) support. Repo: https://github.com/RingsNetwork/rings-node Connect through WebRTC Route by Chord DHT Rings-node SessionManager.sign 3. PeerRing(DHT) 4. TransportManager 5. Transport Transport Interface Native Impl WASM Impl Transport Manager PeerRing(DHT) Swarm Message Handler Session Manager Measure MessageCallbacks0 码力 | 23 页 | 1.74 MB | 1 年前3
基于 Rust 语言编写的可编程的全球分布式 MQTT 服务器 王文庭1)⾃定义协议+⾃定义函数 2)对接标准协议+公共函数 场景:多⼚商协议快速兼容 geo-distributed + 函数式开发 = 边缘计算 整体架构 • Webassembly,简称wasm • ⽤⼀句话描述,那就是Webassembly是执⾏程序的标准化字节码格式 • Webassembly最初被发明,是⽤于Web浏览器。 • 由W3C⼯作组开发的Web浏览器标准,于2017年11⽉, 之类的容器最让⼈诟病的问题之⼀就是安全性; • 更低的内存和资源消耗,Wasm 运⾏时所需的资源⽐ Docker 之类的容器要少很多; • 更快的冷启动时间,Wasm的冷启动时间为微秒,⽐ Docker 的秒级启动快不少; • 更⼩的运⾏时依赖,Docker整体包⼤⼩还是偏⼤,并且依赖的东⻄偏多,很难在⼀些资源 受限的设备上跑起来; Wasm vs Docker • Kubedge? • OpenYurt OpenYurt? • Krustlet? wasm如何分发部署? 3. HPMQ函数开发说明 HPMQ平台 触发器 公共函数 (⽐如:tb2aws) 私有函数 配置 关联 关联 使⽤流程 编写函数 Hpmqfile OCI镜像 镜像仓库 hpmq-cli build hpmq-cli push 发布函数 Demo 4. HPMQ未来规划 开源(https://github0 码力 | 31 页 | 3.95 MB | 1 年前3
THE FIRST EXPLORATION OF PROJECT SPARROWcoming soon. 2.3 Unified runtime for eBPF and Wasm Summary II. Practicing Sparrow Our previous talks "GraalVM-based unified runtime for eBPF & Wasm" at GOTC 2021 (Shenzhen) & "Revisiting "Revisiting GraalVM-based unified runtime for eBPF & Wasm" at OpenInfra Days China 2021(Beijing), and the third-round discussion of this topic will come in this year, which includes Development build the Renode Rust UART peripheral example: cargo build --target wasm32-unknown-unknown --release --lib III. Sparrow Development on branch "26999-rust_uart":0 码力 | 68 页 | 13.14 MB | 1 年前3
KCL: Rust 在编译器领域的实践与探索Manager 02 用 Rust 重写 KCL Python 代码翻译 栈式虚拟机 Rust 编译器 KCL 编译器架构升级 Source Code AST LLVM IR Native/WASM Source Code AST Bit code VM Source Code Python code Pros Cons 简单易上手 生态丰富 研发效率高 性能问题 0.282s 0.283s 13.32s N/A 2. 越来越多的基础设施选择 Rust 3. 更好的性能和稳定性 4. 通过 FFI 暴露 C API 供多语言使用和扩展、方便集成 5. WASM 支持友好 6. 智能合约语言? 为什么选择 Rust? 03 重写的收益 稳定性和性能提升 IDE:用户体验提升 源于 Rust 强大的编译检查和错误 处理方式, 更少的 Bug 稳定性提升 友好的编译器架构 RustCodeBook: Rust源码解读 Compiler Base: 更通用的编译器组件 KCL Source Code AST LLVM IR Native/WASM Smart Contract Source Code AST LLVM IR ABI • Error • Span & SourceMap • Session • Paraller •0 码力 | 25 页 | 3.50 MB | 1 年前3
从零蛋开始学 Rust1.3.4 Rust ���� Web Assembly (WASM) �� Rust �������������������������������� Web ��� Rust ���������� Web Assembly (WASM) ��������������������� �� Web Assembly (WASM) �������������/�������������� CPU ���� ����� ���� Web Assembly (WASM) �� ����� Javascript ����������������� ��������� ��Rust ������ Rust ���������������������� rustup ���������rustup � Rust � ������ ��/���/shell ���������0 码力 | 168 页 | 1.24 MB | 1 年前3
Rust在Substrate 开发框架中的使用WEBASSEMBLY smart contracts staking slashing csprng governance dao parachains permissions Rust 编译为Wasm Wasm在链上存储 Rust 编译成本地可执行文件 RUNTIME Substrate Runtime Module Library 提供一系列的即插即用的功能,如 资产管理、共识、合约、自治等。0 码力 | 37 页 | 967.22 KB | 1 年前3
Learning by Contributing to Rust Compiler - 陈于康2014 ~ 2018 Some small projects • 2020 ~ 2021 More open-source projects, gomoku, youki, dapr-wasm • 2022 ~ Regular contributions to Rust My Rust experience • A real case Remove duplicated diagnostics0 码力 | 23 页 | 3.28 MB | 1 年前3
夏歌-使用Rust构建LLM应用架,让开发者能够使用简单的 Rust 写 应用 如何用 Rust 实现的 构建和部署 AI 相关工作流的 serverless 平台 • 上传 Rust function ,平台负责将 Rust 编译成 Wasm ,并运行在 WasmEdge 安全容 器中 • 平台封装了一些常用 LLM 和 SaaS 的 API ,并发布成了 crate ,比如 ChatGPT 、 telegram 、 GitHub0 码力 | 36 页 | 38.31 MB | 1 年前3
共 12 条
- 1
- 2













