SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
GC
golang
Tri-color garbage collection
•
•
• garbage
Tri-color garbage collection
• root scan: root ( )
push stack
• mark phase:
• stack
• stack
•
• stack (
root root )
• sweep phase heap
Tri-color garbage collection
• mark phase & sweep phase
mutator pause time
Tri-color gc
• A F push stack
root scan
• stack A F push stack
mark
• B C D stack
mark
•
sweep
mark
• mark A J
write barrier
• A I
write barrier
• sweep
write barrier
write barrier
• push stack
sweep
• < current sweep > current sweep
GOGC
GOGC
• GOGC golfing GC
• GOGC=100 heap 100%
GC GC = 200 200%
tradeoff
• tricolor GC pause time
• heap size
sweep
• throughput CPU
GC
• Spatial
Locality
GC 

example code
test code
package main
import (
"container/list"
"time"
)
func GenList() {
l := list.New()
for i := 0; i < 10000; i++ {
str := "aaaaaaaaaaaaaaaaaaa"
l.PushBack(str)
}
}
func main() {
count := 0
for {
count++
for i := 0; i < 1000; i++ {
go func() {
GenList()
}()
}
time.Sleep(500 * time.Millisecond)
if count == 360 {
time.Sleep(10000 * time.Millisecond)
count =0
}
}
}
gctrace output
• CPU 32%
GC
• GC pause time
0.18 + 0.98
ms
• heap size
625M
• htop 1313M
htop


slice List
test code
package main
import (
"time"
)
func GenSlice() {
s:= make([]string, 10000)
for i:= 0;i<10000;i++ {
str := "aaaaaaaaaaaaaaaaaaa"
s[i] = str
}
}
func main() {
count := 0
for {
count++
for i := 0; i < 1000; i++ {
go func() {
GenSlice()
}()
}
time.Sleep(500 * time.Millisecond)
if count == 360 {
time.Sleep(10000 * time.Millisecond)
count =0
}
}
}
gctrace output
• CPU 5%
GC
• GC pause time
1.1 + 2.1 ms
• heap size
156M
Real Memory size
• htop 188M

Contenu connexe

Tendances

CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
dudarev
 
Cloud flare jgc bigo meetup rolling hashes
Cloud flare jgc   bigo meetup rolling hashesCloud flare jgc   bigo meetup rolling hashes
Cloud flare jgc bigo meetup rolling hashes
Cloudflare
 
VLSI Presentation Part 2
VLSI Presentation Part 2VLSI Presentation Part 2
VLSI Presentation Part 2
Aaron Williams
 

Tendances (20)

Altitude San Francisco 2018: WebAssembly Tools & Applications
Altitude San Francisco 2018: WebAssembly Tools & ApplicationsAltitude San Francisco 2018: WebAssembly Tools & Applications
Altitude San Francisco 2018: WebAssembly Tools & Applications
 
Live in shell
Live in shellLive in shell
Live in shell
 
CL metaprogramming
CL metaprogrammingCL metaprogramming
CL metaprogramming
 
Cloud flare jgc bigo meetup rolling hashes
Cloud flare jgc   bigo meetup rolling hashesCloud flare jgc   bigo meetup rolling hashes
Cloud flare jgc bigo meetup rolling hashes
 
Python Coding Examples for Drive Time Analysis
Python Coding Examples for Drive Time AnalysisPython Coding Examples for Drive Time Analysis
Python Coding Examples for Drive Time Analysis
 
R Data Visualization-Spatial data and Maps in R: Using R as a GIS
R Data Visualization-Spatial data and Maps in R: Using R as a GISR Data Visualization-Spatial data and Maps in R: Using R as a GIS
R Data Visualization-Spatial data and Maps in R: Using R as a GIS
 
Zerograph
ZerographZerograph
Zerograph
 
Implementation of Bitcoin Miner on SW and HW
Implementation of Bitcoin Miner on SW and HWImplementation of Bitcoin Miner on SW and HW
Implementation of Bitcoin Miner on SW and HW
 
Garbage Collection
Garbage CollectionGarbage Collection
Garbage Collection
 
include
includeinclude
include
 
A* (aster) Search Algorithm
A* (aster) Search AlgorithmA* (aster) Search Algorithm
A* (aster) Search Algorithm
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)
 
Concurrency in Python4k
Concurrency in Python4kConcurrency in Python4k
Concurrency in Python4k
 
2 19-2018-mean of all runs
2 19-2018-mean of all runs2 19-2018-mean of all runs
2 19-2018-mean of all runs
 
Cristina
CristinaCristina
Cristina
 
VLSI Presentation Part 2
VLSI Presentation Part 2VLSI Presentation Part 2
VLSI Presentation Part 2
 
Parallel computing with GPars
Parallel computing with GParsParallel computing with GPars
Parallel computing with GPars
 
program on Function overloading in java
program on  Function overloading in javaprogram on  Function overloading in java
program on Function overloading in java
 
La R Users Group Survey Of R Graphics
La R Users Group Survey Of R GraphicsLa R Users Group Survey Of R Graphics
La R Users Group Survey Of R Graphics
 
Dummy log generation using poisson sampling
 Dummy log generation using poisson sampling Dummy log generation using poisson sampling
Dummy log generation using poisson sampling
 

En vedette

En vedette (20)

How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 
Docker 入門 Introduction to Docker
Docker 入門  Introduction to DockerDocker 入門  Introduction to Docker
Docker 入門 Introduction to Docker
 
團隊開發永遠的痛 談導入團隊開發的共同規範(Final)
團隊開發永遠的痛   談導入團隊開發的共同規範(Final)團隊開發永遠的痛   談導入團隊開發的共同規範(Final)
團隊開發永遠的痛 談導入團隊開發的共同規範(Final)
 
CI/CD/DevOps 使用 travis ci 服務
CI/CD/DevOps 使用 travis ci 服務CI/CD/DevOps 使用 travis ci 服務
CI/CD/DevOps 使用 travis ci 服務
 
系統配置與前端優化建議
系統配置與前端優化建議系統配置與前端優化建議
系統配置與前端優化建議
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
 
Bdd atdd sbe_tdd_ddd_published
Bdd atdd sbe_tdd_ddd_publishedBdd atdd sbe_tdd_ddd_published
Bdd atdd sbe_tdd_ddd_published
 
20170118 社團負責人課程
20170118 社團負責人課程20170118 社團負責人課程
20170118 社團負責人課程
 
Taller 4 redes II
Taller 4 redes IITaller 4 redes II
Taller 4 redes II
 
用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式
 
Introduction to Fabric Composer
Introduction to Fabric ComposerIntroduction to Fabric Composer
Introduction to Fabric Composer
 
20161024 R語言資料分析實務 (3)
20161024 R語言資料分析實務 (3)20161024 R語言資料分析實務 (3)
20161024 R語言資料分析實務 (3)
 
Quick Tour of Text Mining
Quick Tour of Text MiningQuick Tour of Text Mining
Quick Tour of Text Mining
 
Golang start and tips
Golang start and tipsGolang start and tips
Golang start and tips
 
English 12 Essay Presentation
English 12 Essay PresentationEnglish 12 Essay Presentation
English 12 Essay Presentation
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
 
Lessons Learned: Using Concourse In Production
Lessons Learned: Using Concourse In ProductionLessons Learned: Using Concourse In Production
Lessons Learned: Using Concourse In Production
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 
Comment reconnaitre un salarie heureux au travail
Comment reconnaitre un salarie heureux au travailComment reconnaitre un salarie heureux au travail
Comment reconnaitre un salarie heureux au travail
 
Vanicom 2017, Business quiz
Vanicom 2017, Business quizVanicom 2017, Business quiz
Vanicom 2017, Business quiz
 

Similaire à Gc in golang

Similaire à Gc in golang (10)

Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
 
Living With Garbage
Living With GarbageLiving With Garbage
Living With Garbage
 
Living with garbage
Living with garbageLiving with garbage
Living with garbage
 
Ruby & GCs (QConSP 2014)
Ruby & GCs (QConSP 2014)Ruby & GCs (QConSP 2014)
Ruby & GCs (QConSP 2014)
 
Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
 
PostgreSQLからMongoDBへ
PostgreSQLからMongoDBへPostgreSQLからMongoDBへ
PostgreSQLからMongoDBへ
 
ORM in Go. Internals, tips & tricks
ORM in Go. Internals, tips & tricksORM in Go. Internals, tips & tricks
ORM in Go. Internals, tips & tricks
 
A Channel Compendium
A Channel CompendiumA Channel Compendium
A Channel Compendium
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Gc in golang