Tsung-Han Ho
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Faceboo"C" - web server & web application contributed by < `dalaoqi` > 在上一篇 [Faceboo"C" - 正確性驗證](https://hackmd.io/@dalaoqi/HyZeMwjsw) 後半部利用 Apache Bench 來對 Facebooc 做效能測試,發現將 request 的數量增加為 10000 時每秒能夠處理的 request 數量大幅減少。 ![](https://i.imgur.com/pugtJGZ.png) 可能是因為目前 web server 是用 `select` 做輪詢 ## IO multiplexing 常見的 select 及 epoll 都是屬於 IO multiplexing 機制,此種機制可以讓 process 同時監視多個 file descriptor,當某個 fd 有資料準備好,就會通知 process 做 IO 操作。 ### select 目前 `select` 這樣的方式雖然可以同時監控 1024 個 fd,但在返回的時候,process 需要去 traverse 整個 fd set ,找出那些準備好的 fd ,fd 的數量越多,性能就越差。 ```c int select(int nfds, fd_set *readset, fd_set *writeset,fd_set* exceptset, struct timeval *timeout); ``` * nfds: 需要檢查的 fd 個數,也就是檢查到 fd set 的第幾位,這個數值會 比後三個參數 fd_set 中所含的最大 fd 值更大,一般為最大 fd 值 + 1。 * readset: 一組用來檢查是否可以讀取的 fd set。 * writeset: 一組用來檢查是否可以寫入的 fd set。 * exceptset: 一組用來檢查是否有異常條件 (不包含錯誤) 出現的 fd set。 在 `facebooc` 專案中 `src/server.c` ```c=236 int sock = makeSocket(server->port); int newSock; int nfds = sock + 1; struct sockaddr_in addr; socklen_t size = sizeof(addr); fd_set activeFDs; fd_set readFDs; FD_ZERO(&activeFDs); FD_SET(sock, &activeFDs); ``` * `makeSocket` * 根據輸入的 port 建立一個 socket,並且設定為可以接受連接狀態 * `FD_ZERO(&active fd setFDs), FD_SET(sock, &activeFDs)` * 初始化 active fd set,將 set 清為 0 ,使得 set 中不含有任何 fd,而後將剛剛的 sock 加入到 active fd set `serverServe` 函式主要會去一直重複的檢查哪個 fd 已經準備好可以被讀取 `FD_ISSET(fd, &readFDs)` 的作用就是會去檢查 fd 是不是在可以讀取的 set 中。 ```c=229 void serverServe(Server *server) { #ifdef _WIN32 WSADATA wsaData; WSAStartup(2 , &wsaData); #endif int sock = makeSocket(server->port); int newSock; int nfds = sock + 1; struct sockaddr_in addr; socklen_t size = sizeof(addr); fd_set activeFDs; fd_set readFDs; FD_ZERO(&activeFDs); FD_SET(sock, &activeFDs); fprintf(stdout, "Listening on port %d.\n\n", server->port); for (;;) { readFDs = activeFDs; if (select(nfds, &readFDs, NULL, NULL, NULL) < 0) { fprintf(stderr, "error: failed to select\n"); exit(1); } if (FD_ISSET(sock, &readFDs)) { newSock = accept(sock, (struct sockaddr *) &addr, &size); if (newSock < 0) { fprintf(stderr, "error: failed to accept connection\n"); exit(1); } if (newSock >= nfds) nfds = newSock + 1; FD_SET(newSock, &activeFDs); } for (int fd = sock + 1; fd < nfds; ++fd) { if (FD_ISSET(fd, &readFDs)) handle(server, fd, &activeFDs, &addr); } } } ``` ### epoll 使用 `select` 的時候需要去一直訪問所有的 fd,且每當新監聽一個新的 socket 時,需要把它加入至 active fd set 後,再次呼叫 `select`。因此我將嘗試使用 epoll 來取代 select。 使用 `epoll` 的優點如下: * 處於 wailting 狀態的時候,也可以新增或刪除 fd * `epoll_wait` 只會回傳準備好的 fds * `epoll` 較 `select` 有效率 - 時間複雜度 $O(1)$ 但是不可跨平台, `epoll` 只在 linux 上使用,BSD 用 [kqueue](https://www.freebsd.org/cgi/man.cgi?kqueue),Windows 用 [IOCP](https://docs.microsoft.com/zh-tw/windows/win32/fileio/i-o-completion-ports?redirectedfrom=MSDN)。 常用的 `epoll` api: * `int epoll_create(int size)` * 產生 epoll 專用的 file discriptor,有自己的 interest list * `int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)` * epoll file descriptor 的控制介面 * 參數 `epfd` 為 `epoll_create` return 的值 * `op` 為可以做的操作 * EPOLL_CTL_ADD:將 fd 新增至 `epfd` 的 list * EPOLL_CTL_MOD:修改在 list 中的 fd * EPOLL_CTL_DEL:從 list 中刪除 fd * `event` * EPOLLIN * EPOLLOUT * EPOLLRDHUP * EPOLLET * EPOLLONESHOT * EPOLLWAKEUP * EPOLLEXCLUSIVE * 操作成功回傳 0 ,發生錯誤回傳 -1 * `int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout)` * 等待事件到來。如果有事件,就將所有已經就緒的事件從 kernel 複製到 events,回傳值為準備好的 fd 數量。 `epoll` 對 fd 的操作有兩種模式: LT(Level Trigger) 及 ET(Edge Trigger) * LT:當 epoll_wait 偵測到 fd 事件發生,將該事件通知 process, process 可不立刻處理該 event,當下次呼叫 epoll_wait 時,會再次通知 process 這個事件。 * ET:當 epollwait 偵測到 fd 事件發生,將該事件通知 process,該 process 必須立刻處理該 event,如果沒有處理,當下次呼叫 epoll_wait 時,不會再次通知 process 這個事件 在 `select` 中, process 必須呼叫 funtion , kernel 才會對該 fd 進行監聽,且需要 traverse 整個 fd set。 而 epoll 是先利用 `epoll_ctl` 新增 fd 至 epfd 的 interest list 後,當某個 fd 準備好後,當 process 呼叫 epoll_wait 後就會的到 ready fds 。 ## 修改 在 Server struct 中新增變數 `epollfd` 用來保存 `epoll_create1(0)` 產生 epoll file discriptor 所回傳的值‧ ```c typedef struct Server { unsigned int port; + int epollfd; ListCell *handlers; } Server; ``` ```c Server *serverNew(unsigned int port) { Server *server = malloc(sizeof(Server)); server->port = port; + server->epollfd = epoll_create1(0); server->handlers = NULL; return server; } ``` `makeSocket()` 會在指定的 port 建立 socket,並回傳新 socket 的 fd。此 socket 是為了之新的請求所設計的。 ` int sock = socket(PF_INET, SOCK_STREAM, 0);` 將產生的 socket fd 加入至 server epollfd 的 interest list。 ```c int sock = makeSocket(server->port); int newSock, nfds, tmpfd; struct sockaddr_in addr; struct epoll_event* events = (struct epoll_event*)malloc(sizeof(struct epoll_event) * 64); struct epoll_event event; socklen_t size; serverAddFd(server->epollfd, sock, 1,0); ``` 之後進入迴圈中持續 call `epoll_wait` function。如果有準備好的 fd , `nfds` > 0 進入下一個 for 迴圈去遍歷`events`(epoll_wait 會將準備好的那些 fds 複製到 `events`)。 如果 `events` 內包含了原本一開始創立的 socket fd,代表有新的連線請求,因此需要利用 `accept` 去創建專門服務的新 socket fd,隨後將它加入 epfd interest list。 至於其他不是原先創立的 socket fd ,則去利用 `handle` 函式去完成對應的請求。 ```c for (;;) { nfds = epoll_wait(server->epollfd, events, 64, -1); for (int i = 0; i < nfds; ++i) { event = events[i]; tmpfd = event.data.fd; if (tmpfd == sock) { size = sizeof(addr); while ((newSock = accept(sock, (struct sockaddr *) &addr, &size)) > 0) { serverAddFd(server->epollfd, newSock, 1, 1); } if (newSock == -1) { if (errno != EAGAIN && errno != ECONNABORTED && errno != EPROTO && errno != EINTR) { fprintf(stderr, "error: failed to accept connection\n"); exit(1); } } } else { handle(server, tmpfd, &addr); } } } ``` 在此專案實作將 fd 加入 epfd interest list ,使用 `serverAddFd` 函式。 預想一種情形,當某個執行續在處理 fd 的同時,又來了同樣的事件,但正在處理的還沒處理好,此時 process 會去指派另一個執行緒來處理這個新的且同樣的事件。為了避免這種問題,可以在 epoll 註冊 `EPOLLONESHOT` 事件。註冊後,代表這個事件只能被處理一次,下次要處理的時候需要重新加入 epoll 中。 為了在 errno 為 `EAGIAN` 時能夠將 fd 重新加回 epoll ,實作 `resetOneShot` function,使用 EPOLL_CTL_MOD 修改 fd 的 events,使之能夠重新加入 epoll list。 ```c static void resetOneShot(int epollfd, int fd) { struct epoll_event event; event.data.fd = fd; event.events = EPOLLIN | EPOLLET | EPOLLRDHUP | EPOLLONESHOT; if (epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, &event) < 0) perror("epoll_ctl"); } ``` 在每次利用 `serverAddFd` 函式,可將 fd 加入 epfd interest list 並且同時會將 fd 設定為 `non-blocking` 使用 `fcntl` 及 `F_GETFL` ,先取得目標 fd 的 flags ,將 flag `O_NONBLOCK` 加入 flags , 隨後同樣的也是用 `fcntl` 及 `F_SETFL` 將新的 flags 設定到該 fd。 ```c if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) < 0) perror("fcntl"); ``` 修改後,重新用 [上一篇的方式](https://hackmd.io/-ZxS0h-dRS6tYEV6gYFj_g#%E6%80%A7%E8%83%BD%E6%B8%AC%E8%A9%A6) 來實驗 在短時間送出多次請求,模擬 100 人同時進行 request = 100 ```shell This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 140.116.82.6 (be patient).....done Server Software: Server Hostname: 140.116.82.6 Server Port: 8080 Document Path: / Document Length: 3658 bytes Concurrency Level: 100 Time taken for tests: 0.045 seconds Complete requests: 100 Failed requests: 0 Total transferred: 367700 bytes HTML transferred: 365800 bytes Requests per second: 2209.94 [#/sec] (mean) Time per request: 45.250 [ms] (mean) Time per request: 0.453 [ms] (mean, across all concurrent requests) Transfer rate: 7935.51 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 8 1.8 8 11 Processing: 5 15 7.6 15 29 Waiting: 0 15 7.8 15 29 Total: 16 23 6.0 23 34 Percentage of the requests served within a certain time (ms) 50% 23 66% 26 75% 28 80% 30 90% 32 95% 33 98% 34 99% 34 100% 34 (longest request) ``` request = 1000 ```shell This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 140.116.82.6 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: Server Hostname: 140.116.82.6 Server Port: 8080 Document Path: / Document Length: 3658 bytes Concurrency Level: 100 Time taken for tests: 0.376 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 3677000 bytes HTML transferred: 3658000 bytes Requests per second: 2658.91 [#/sec] (mean) Time per request: 37.609 [ms] (mean) Time per request: 0.376 [ms] (mean, across all concurrent requests) Transfer rate: 9547.67 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 2.4 0 11 Processing: 0 2 5.1 1 29 Waiting: 0 2 5.1 1 29 Total: 1 3 7.1 1 35 Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 1 90% 16 95% 23 98% 30 99% 32 100% 35 (longest request) ``` request = 10000 ```shell This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 140.116.82.6 (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: Server Hostname: 140.116.82.6 Server Port: 8080 Document Path: / Document Length: 3658 bytes Concurrency Level: 100 Time taken for tests: 7.686 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 36770000 bytes HTML transferred: 36580000 bytes Requests per second: 1301.09 [#/sec] (mean) Time per request: 76.858 [ms] (mean) Time per request: 0.769 [ms] (mean, across all concurrent requests) Transfer rate: 4672.00 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 25 253.1 0 3049 Processing: 0 9 126.4 1 6656 Waiting: 0 9 126.4 1 6656 Total: 0 34 330.9 1 7663 Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 1 90% 1 95% 1 98% 20 99% 1025 100% 7663 (longest request) ``` 統整實驗數據繪製成下列的圖表,可以發現修改成 epoll 方法,在 request 設定為 10000 次的時候,相較於 select ,測試時化費的時間更少,每秒處理的 requests 數目更多。 ![](https://i.imgur.com/UIB4jfv.png) ![](https://i.imgur.com/d1CXXLE.png) ## Make it portable 目前的 Facebooc 只能在 Linux 系統上執行,其他平台不支援 `epoll`,但是有其他類似的 function 可以使用,例如在 BSD 或 macOS 上的 [kqueue api](https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2)。 ### kqueue() `kqueue()` 的 功能如同 `epoll_create()`,創立一個空的 event queue,用來擺放監聽的事件,返回一個 file discriptor。 直接呼叫即可 ```c k = kqueue(); ``` ### kevent `kevent` 資料結構 ``` struct kevent { uintptr_t ident; /* 監聽事件的標籤*/ short filter; /* 監聽事件型別*/ u_short flags; /* 事件操作型別*/ u_int fflags; /* filter flag value */ int64_t data; /* filter data value */ void *udata; /* 額外攜帶的使用者資料*/ uint64_t ext[4]; /* extensions */ }; ``` `kevent` 是由一對 `<ident, filter>` 進行標識。 * `ident` 可以是一個 file disciptor 或是 process ID,取決於要監聽的事件。 * `filter` 是用於處理相對應的事件的 filter,有一些預先定義好的 filter 可以做使用。 * `EVFILT_READ`,當有可進行讀取操作的資料時候會被觸發 * `EVFILT_WRITE`,當有可進行寫入操作的資料時候會被觸發 設計好一個 `kevent` 後,該怎麼加入剛剛生成的 event queue? 可以透過 `EV_SET` 來對 `kevent` 做對應的初始化設定,如下: * 設定 `event.ident` 為 目標 fd * 設定等等呼叫 `kevent` function 對目標 fd 做的操作 ```c struct kevent event; event.ident = fd; //設定目標 fd event.flags = EV_ADD | EV_ENABLE | EV_CLEAR; EV_SET(&event, fd, EVFILT_READ, event.flags, 0, 0, NULL); ``` 設計好一個 `kevent` 後,需要把他加進去到 `kqueue` 中, 這時需要呼叫 `kevent()` function。 ```c int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); ``` * kq: kqueue() 返回值 * changelist: 會發生任何改變的 event ,比如剛剛設定過 `EV_ADD` event * nchanges: change events 的數量 * eventlist: kevent 完成後所存放的 changed list * nevents: changed list 數量 * timeout: 設為 NULL 會一直等待 ```c if(kevent(epollfd, &event, 1, NULL, 0, NULL) < 0) { perror("kevent"); } ``` `kevent()` 成功設定會回傳 0,失敗回傳 -1。 由上述可以得知: * `int kqueue(void)` 的功能與 `int epoll_create(int size)` 相同。 * `int kevent(...)` 可以做到 `int epoll_ctl(...)` 與 `int epoll_wait(...)` 相同的處理 `kqueue` 可以做到和 `epoll` 相同的事。 ### 條件編譯 如果要讓 web server 要可以同時在多個系統上跑的話,可以使用條件編譯 透過巨集 (macro),使用條件編譯可以用來偵測編譯程式時的系統環境,來篩選程式碼。 ```c #if defined(__linux__) #elif defined(__APPLE_) /* macOS */ #endif ``` 條件編譯對於跨平台程式碼相當重要。因為不同系統的 C API 等內容不會相等。我們可以用條件編譯的方式,針對不同平台撰寫不同的程式碼,滿足跨平台的需求。 :::success 點選 [這裡](https://sourceforge.net/p/predef/wiki/OperatingSystems/) 可以看到更多的作業系統列表。 ::: 舉例來說, `epoll` 只能支援 linux 系統,而 `kqueue` 只能支援 BSD 或是 macOS。 如果想要在兩個平台上都可編譯並且可以執行可以透過下面的操作解決。以下的程式碼所做的事情是一樣的。 ```c #if defined(__linux__) struct epoll_event* events = (struct epoll_event*)malloc(sizeof(struct epoll_event) * 64); struct epoll_event event; #elif defined(__APPLE__) struct kevent* events = (struct kevent*)malloc(sizeof(struct kevent) * 64); struct kevent event; #endif ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully