簡易檢索 / 詳目顯示

研究生: 汪宗諺
Wang, Tsung-Yen
論文名稱: Rust 程式的非同步執行內容之追蹤方法論
Tracing Asynchronous Execution Contexts for Rust Programs
指導教授: 涂嘉恒
Tu, Chia­-Heng
學位類別: 碩士
Master
系所名稱: 電機資訊學院 - 資訊工程學系
Department of Computer Science and Information Engineering
論文出版年: 2022
畢業學年度: 110
語文別: 英文
論文頁數: 52
中文關鍵詞: Rust 程式語言效能分析/追蹤程式語言非同步模型效能分析/追蹤工具
外文關鍵詞: Rust Programming Language, Performance Profiling/Tracing, Asynchronous Programming Model, Performance Profiling/Tracing Tool
相關次數: 點閱:144下載:16
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • 隨著高效能程式的發展, 如何充分的利用硬體資源也成為了一個相當重要的主題,
    Rust 程式語言提供了非同步的執行模型 來幫助我們更加善用硬體資源, 但因為非
    同步執行模型的使用, 開發人員在實際了解程式行為和效能分析上十分困難, 因此我
    們提出了一套方法論以及相對應框架的實作來解決這些問題。本論文建構了一套對
    使用者友善且自動化的方法來追蹤與分析使用非同步模型的 Rust 程式。基於現有的
    追蹤工具 uftrace 以及視覺化工具 Trace­viewer , 並搭配本論文中依據 future­rs
    執行模型所建立的解析程式, 可以產生出 Rust 非同步程式碼的追蹤結果。利用這
    個追蹤的結果, 開發人員能夠觀察採用不同的 Rust async runtimes 的程式在非同
    步模型下的行為, 發現因為誤用非同步模型而造成的非預期行為, 同時開發人員也能
    夠利用它快速的找出一些潛在效能問題, 像是 “Blocking Issue” 或者平行度不佳的
    情況。總結來說, 本論文提出了一套追蹤 Rust 非同步程式內容的方法與實做, 利用
    uftrace 動態追蹤的方式以及自動化的插入程式碼, 且利用 state­machine based 的解
    析程式解析追蹤資料。利用我們們實做的框架, 開發者可以快速的觀察到非同步程式
    碼的執行行為, 同時也可以發現因為使用非同步程式模型產生的潛在效能問題像是
    “Blocking Issue” 以及平行度不佳等問題。

    With the development of high-performance applications, getting the most out of the hardware resources become an important topic, Rust programming language provides the asynchronous programming model to let the developers get the most out of the hardware resources. However, because of the usage of the asynchronous programming model, it is hard to un­derstand the asynchronous execution context and the performance of the program. Hence, we propose a tracing methodology and the implementation of the framework to solve these problems. In this thesis, we propose a user­fridenly and automatic tracing methodology to trace the asynchronous context of Rust programs. The tracing framework is based on the open­source tracing tool uftrace and visualization tool Trace­viewer, simultaneously integrating them with a parser that is constructed from the library “future­rs”. With the tracing results, we can get the real behavior of the asynchronous execution context (i.e. whether a fu­ture is polled expectedly or not). Furthermore, we can see if there are any potential points
    for performance improvement such as the “Blocking Issue” or the poor parallelism with the tracing result as well. In summary, we propose a tracing methodology and its correspond­ing implementation for Rust asynchronous execution context tracing. The implementation of our tracing framework leverages uftrace for instrumenting the programs dynamically and automatically and uses a state­machine based parser to process the tracing data. So the developers can use our framework to observe the behavior of async context rapidly and find out potential performance issues such as “Blocking Issue” and poor parallelism.

    Abstract ii Acknowledge iv Table of Contents v List of Tables vii List of Figures viii Chapter 1. Introduction 1 1.1. Why Rust? 1 1.2. Asynchronous Programming Model in Rust 3 1.2.1. Future Trait 3 1.2.2. async/await 4 1.2.3. Runtime 6 1.3. Open­source tools used in our framework 7 1.3.1. uftrace and Trace­viewer 9 1.4. Problems in the asynchronous programming model 10 1.5. Thesis Organization 11 Chapter 2. Related Work 12 2.1. Tracing/Profiling async context in other languages 12 2.2. Tracing/Profiling tool in Rust 14 2.2.1. Perf and flamegraph 14 2.2.2. Tokio­tracing 15 2.2.3. Tokio­console 15 Chapter 3. Methodology 18 3.1. Execution context tracking with a state machine 18 3.2. Complete framework: Rust async­context tracer 22 3.2.1. Dynamic instrumentation with uftrace 22 3.2.2. Get the tracing data with uftrace 25 3.2.3. Post­processing 25 3.2.4. Visualize with Trace­viewer 30 3.3. Implementation 30 Chapter 4. Use cases and experiments 33 4.1. Common async code patterns: Execution behavior of async context 33 4.1.1. Simulate IO operations with sleep 33 4.1.2. File operations 34 4.1.3. Mutex lock 38 4.1.4. Channel 38 4.2. Common async code patterns: Performance issues in async context 40 4.2.1. Client/Server pattern 40 4.2.2. Case study: Zenoh application 41 4.3. Verify on different runtime: Tokio 45 Chapter 5. Conclusion 50 References 51

    [1] Asynchrony. [Online]. Available: (computer_programming) https://en.wikipedia.org/wiki/Asynchrony_
    [2] Uftrace ­ function graph tracer for c/c++/rust. [Online]. Available: https://github.com/
    namhyung/uftrace
    [3] Trace­viewer ­ analysis and visualization tool. [Online]. Available: http://google.
    github.io/trace­viewer/
    [4] Futures and promises. [Online]. Available: https://en.wikipedia.org/wiki/Futures_and_
    promises
    [5] The async ecosystem. [Online]. Available: https://rust­lang.github.io/async­book/08_
    ecosystem/00_chapter.html
    [6] A. Ryhl, “Async: What is blocking?” 2020. [Online]. Available: https://ryhl.io/blog/async­what­is­blocking/
    [7] Executors and system io. [Online]. Available: https://rust­lang.github.io/async­book/
    02_execution/05_io.html
    [8] Gecko. [Online]. Available: https://en.wikipedia.org/wiki/Gecko_software
    [9] Firefox. [Online]. Available: https://en.wikipedia.org/wiki/Firefox
    [10] Amazon s3. [Online]. Available: https://aws.amazon.com/s3/
    [11] Aws. [Online]. Available: https://en.wikipedia.org/wiki/Amazon_Web_Services
    [12] cloudflare. [Online]. Available: https://en.wikipedia.org/wiki/Cloudflare
    [13] zenoh. [Online]. Available: https://zenoh.io/
    [14] Mozilla. [Online]. Available: https://zh.m.wikipedia.org/zh­tw/Mozilla
    [15] stackoverflow. [Online]. Available: https://stackoverflow.com/
    [16] ownership. [Online]. Available: https://doc.rust­lang.org/book/ch04­01­what­is­ownership.html
    [17] Callback hell. [Online]. Available: http://callbackhell.com/
    [18] Eclipse foundation. [Online]. Available: Foundation https://en.wikipedia.org/wiki/Eclipse_
    [19] Data distribution services. [Online]. Available: https://en.wikipedia.org/wiki/Data_
    Distribution_Service
    [20] Message queing telemetry transport. [Online]. Available: https://en.wikipedia.org/
    wiki/MQTT
    [21] async­std. [Online]. Available: https://github.com/async­rs/async­std
    [22] tokio runtime. [Online]. Available: https://github.com/tokio­rs/tokio
    [23] types-­of-­future. [Online]. Available: https://cfsamson.github.io/books­futures­explained/1_futures_in_rust.html
    [24] epoll. [Online]. Available: https://en.wikipedia.org/wiki/Epoll
    [25] kqueue. [Online]. Available: https://en.wikipedia.org/wiki/Kqueue
    [26] Iocp. [Online]. Available: https://en.wikipedia.org/wiki/Input/output_completion_port
    [27] Task wakeups with waker. [Online]. Available: https://rust­lang.github.io/async­book/
    02_execution/03_wakeups.html
    [28] cppreference.com: std::async. [Online]. Available: https://en.cppreference.com/w/cpp/thread/async
    [29] Net async tool. [Online]. Available: https://docs.microsoft.com/zh­tw/visualstudio/
    profiling/analyze­async?view=vs­2022
    [30] chrome developer tool. [Online]. Available: https://developer.chrome.com/docs/devtools/
    [31] async­profile. [Online]. Available: https://github.com/ConradIrwin/async­profile
    [32] asyncio. [Online]. Available: https://docs.python.org/3/library/asyncio.html
    [33] Panopticon. [Online]. Available: https://github.com/kunalb/panopticon
    [34] go tool trace. [Online]. Available: https://github.com/golang/go/blob/master/src/runtime/trace/trace.go
    [35] Perf­tool. [Online]. Available: https://perf.wiki.kernel.org/index.php/Main_Page
    [36] flamegraph­rs. [Online]. Available: https://github.com/flamegraph­rs/flamegraph
    [37] tokio­tracing. [Online]. Available: https://github.com/tokio­rs/tracing
    [38] open­telemetry. [Online]. Available: https://opentelemetry.io/
    [39] tokio­console. [Online]. Available: https://github.com/tokio­rs/console
    [40] Implementation of our work. [Online]. Available: https://github.com/eddie9712/Rust­Async­Context­Tracer
    [41] stream trait. [Online]. Available: https://rust­lang.github.io/async­book/05_streams/
    01_chapter.html
    [42] Flume channel. [Online]. Available: https://github.com/zesterer/flume
    [43] Tokio tutorial. [Online]. Available: https://tokio.rs/tokio/tutorial

    下載圖示
    校外:立即公開
    QR CODE