交大觀察與心得(一):碩一上
- January 16, 2020
- Liu, An-Chi 劉安齊

Paper: Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code
Author: Abhinav Jangda, Bobby Powers, Emery D. Berger, and Arjun Guha, University of Massachusetts Amherst
Source: USENIX ATC 2019
作者們先前開發了 BROWSIX,可以讓 Unix 程式直接轉成 JavaScript 並跑在瀏覽器。BROWSIX 基本上就是把程式碼轉成 JavaScript 並且用 Browser API 來模擬 Unix System Call。此篇作者更進一步,開發 BROWSIX-WASM(fork 自 Emscripten)將程式碼轉成 WebAssembly,一來解決原本 JavaScript 效能不佳問題,同時也能可以拿來和 Native Code 在 SPEC CPU suite of Benchmark 上做效能比較。實驗結果 WebAssembly 在現代瀏覽器(Chrome & Firefox)上慢 Native Code 大約 50%,並深入探討為什麼會這樣。
整體來說我覺得是很有趣的一篇論文,整理了重點並加入一些我個人的見解。
Continue reading我正在念交大資工所,我決定要走資工是一個漫長的過程,這篇故事想從最早開始講起,描述過往我對資工的興趣如何慢慢建立。每個人的故事都是獨一無二,但我的故事希望可以給別人一些靈感和借鏡。
Continue reading紅黑樹是一種特別的資料結構,他具有跟 AVL Tree 一樣可以自動平衡的功能。
一個紅黑樹具有一下特性:
NIL
且為黑遵循這樣的規則,可以確保在增加和刪除節點時,保持著樹的平衡狀態。紅黑數保證當 node 數量是 n
時,他的高度最多不會超過 2log(n+1)
。
在現實生活中,常常用來實作 set 和 dictionary,C++ 中的 std::set
和 std::map
背後正是紅黑樹。
Unix 中 processes 之間溝通有很多種,本篇介紹 signal 的簡易使用。可以先閱讀 Beej 的介紹。顧名思義,signal 就是程序發送和接受訊號,例如我們在使用 Shell 的時候,之所以 Ctrl-C
可以中斷程式執行,就是因為 Shell 捕捉到 Ctrl-C
發送的 SIGINT
訊號,知道有一個 interrupt signal,所以將程式中斷。
發送 signal 可以用 sigaction()
或 signal()
,不過建議使用 sigaction
因為比較新,詳細差別可以看 Stack Overflow 這篇 「What is the difference between sigaction and signal?」。
如果想觸發 signal,可以用 kill()
或 sigqueue()
,差別在於後者僅限 Linux,但後者可以藉由傳送 siginfo
加一些資訊在 signal 中。此外一些 system call 本身也會觸發 signal,例如如果嘗試 send()
到不存在的 socket
,就會觸發 SIGPIPE
。
當我們有很多 processes 時,並想用實現 shared memory 處理共用資料時,就可以使用 shared memory,來實作。建立 shared memory 可以使用 mmap
或是 System V shmget
,但根據 Stack Overflow 「How to use shared memory with Linux in C」回答,shmget
已經有點過時,mmap
則比較新和彈性。
Shared memory 讓我們可以建立一塊共用的記憶體空間,mmap
會回傳一塊記憶體空間的指標,型別是 void *
,如果我們想要放資料進去,可以用 memcpy
將物件、字串或任何東西拷貝進去。我們也可以直接將 void *
轉型成物件指標,這樣就建立 shared object,不同 process 可以直接對 process 存取物件。
Sunshine, blue sky, and sprinkles of rain — such diverse weather on August 16th-17th echoed the lively atmosphere at NTUST in Taipei, where the COSCUP was held. Participating in the conference, Rust Taiwan community hosted the “Everything in Rust” track with 11 talks, which were relevant to Rust. Speakers came from all over the world, including India, Netherlands, China, Hong Kong, and Taiwan, representing for some of the top influencers in the global Rust community. With more than one thousand attendees in COSCUP, it was the first time for these hundreds of people encountered the efflorescence of the Rust programming language.
Continue readingRecord Rust Taiwan community’s work of translating the Rust website
紀錄 Rust 台灣社群將 Rust 官網翻譯成正體中文的過程
TL;DR
I am glad to announce that the Traditional Chinese (正體中文) version of the Rust official website has been launched. Thanks to all contributors in the community. This article records our experience to achieve the work.