or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
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.
Syncing
xxxxxxxxxx
Goroutine stack and local variable allocation in Go - Cherie Hsieh
tags:
COSCUP2020
進階
TR214
歡迎來到 https://hackmd.io/@coscup/2020 共筆
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。
Slides: Goroutine stack and local variable allocation in Go
Run time stack
以 linux 來說,有分成 kernel stack 和 user stack
之後會著重在 user stack
在執行程式時,user stack 會含有 stackframe
大概含有
User stack in C
有
heap
,stack
,data
,text
等當產生一個新的 thread 後,會在 user stack 找一塊空間當作
stack
main program 預設的 stack size 是
8K
,可修改系統設定去修改thread 是透過
clone
syscall 去設定新的 stack 空間User stack in Go
在
Processor
下有mcache
,mcache
又有stackcache
從
stackcache
去拿取新的 stack 空間stackcache
會從stack pool
(全域需加鎖) ,stack pool
又從mhead
拿System stack in Go
在 GMP model 中的每個 M 會有一個 System stack
預設大小也是
8K
stack growing mechanism
當超過常數
StackSmall = 128
byte,才會觸發 stack extension當超過常數
StackBig = 4096
byte當直接分配新空間,並複製原本的內容到新空間,會遇到一個問題
因為原本有些變數是指到舊的 stack 空間,直接複製會有問題
go 透過另外一個 map 去解決
那會不會 stack overflow
答案是: 會
當初始化 stack 時, stackframe 就超過 2K
直接失敗