Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Go memory allocation
Deepu K Sasidharan
February 14, 2020
1
1.1k
Go memory allocation
Deepu K Sasidharan
February 14, 2020
Tweet
Share
More Decks by Deepu K Sasidharan
See All by Deepu K Sasidharan
Is containerless the future of Kubernetes?
deepu105
0
130
Reactive Java Microservices on Kubernetes with Spring and JHipster
deepu105
1
220
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
360
How to Secure Your Node.js Containers on Kubernetes With Best Practices
deepu105
0
46
Let's Talk About Foreign Functions In Java
deepu105
0
170
Why Safe Programming Matters and Why Rust?
deepu105
1
110
Why did I build a Kubernetes Dashboard in Rust
deepu105
0
120
State of pattern matching in Java
deepu105
0
70
Can Rust be the language of the future?
deepu105
0
62
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
310
34k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
212
20k
GitHub's CSS Performance
jonrohan
1020
420k
Statistics for Hackers
jakevdp
782
210k
How to Ace a Technical Interview
jacobian
266
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
The Brand Is Dead. Long Live the Brand.
mthomps
46
2.7k
Product Roadmaps are Hard
iamctodd
35
6.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
27
1.6k
Code Reviewing Like a Champion
maltzj
506
37k
Learning to Love Humans: Emotional Interface Design
aarron
261
37k
10 Git Anti Patterns You Should be Aware of
lemiorhan
638
52k
Transcript
Process Virtual Memory Resident set mheap P1(Logical Processor/Hardware Thread) Goroutine
1 stack arena arena ... mcentral mcentral mcentral .. mcache mspan 8b mspan 16b mspan 32b mspan .. mspan .. mspan .. mspan .. mspan .. mspan 32768b mspan 8b (non empty) mspan 8b (empty) mspan 16b mspan 16b mspan mspan P2 G6 stack mcache .. .. .. .. Pn Gn stack mcache mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b
mspan mspan 8b 8b 8b 8b …. 8b 8b 8b
1024 objects mspan 16b 16b 16b 16b …. 16b 16b 16b 512 objects mspan 32b 32b 32b 32b …. 32b 32b 32b 256 objects mspan 48b 48b 48b 48b …. 48b 48b 48b 170 objects mspan 32768 bytes 1 object mspan .. .. .. .. …. .. .. .. ...
Go Scheduler P M G Processor Core G G P
= Logical Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) LRQ = Local Run Queue LRQ
Tiny allocation
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b 12b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b 12b No free mspan 16b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b 12b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b 12b
Tiny allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 16b (non empty) mspan 16b (empty) mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 16b mspan 8b mspan 16b mspan 16b Tiny allocation slot 12b 4b 10b 12b
Small allocation
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b 32b No free mspan 32b mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b 32b No free mspan 32b mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b 32b mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b
Small allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b mspan 32b (non empty) mspan 32b (empty) mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b mspan 32b 32b
Large allocation
Large allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b mspan 32b 32b
Large allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b mspan 32b 32b 40Kb
Large allocation P1 M G2 Processor Core P = Logical
Processor per Hardware Thread M = Machine per OS Thread G = Goroutine (Coroutine) mcache mheap arena mcentral mspan 8b (non empty) mspan 8b (empty) mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mspan 8b mcentral mspan 8b mspan 16b mspan 32b Tiny allocation slot 12b 20b mspan 32b 32b mspan 40Kb