SlideShare a Scribd company logo
1 of 32
Twitter: @prateekgogia
Github: @prateekgogia
Docker daemon
eth0 Linux machine
Docker
Daemon
Docker runtime adopted Go
• Promoted wider adoption of Go as a systems language
• Bug fixes in Docker produced more Go programmers
• Identifying systems level problem in Go runtime related to syscalls / threads
Isolation in Docker container: namespaces
• Process trees (PID Namespace)
• Mounts (MNT namespace)
• Network (Net namespace)
• Users / UIDs (User Namespace)
• Hostnames (UTS Namespace)
• Inter Process Communication (IPC Namespace)
Lets see this in action
Running a Go Process on Linux machine
eth0 Linux machine
Go Process
OS thread
Goroutine
Add new Network Namespace with lo
(loopback) only interface
eth0
net namespaces n
Linux machine
Go Process
OS thread
Goroutine
Adding worker goroutines to new network
namespaces
eth0
Worker
goroutines
net namespaces n
Linux machine
Go Process
OS thread
Goroutine
runtime.LockOSThread()
Adding worker goroutines to host network
namespace
eth0
Worker
goroutines
net namespaces n
Linux machine
Go Process
OS thread
Goroutine
runtime.LockOSThread()
Adding worker goroutines to host network
namespace
eth0
more
Worker
goroutines
net namespaces n
Linux machine Go Process
OS thread
Goroutine
runtime.LockOSThread()
Incorrect interfaces detected by goroutines
eth0
more
Worker
goroutines
net namespaces n
Linux machine Go Process
goroutine
with wrong
interface info
Go runtime scheduler
M P G G G G
M P G
M
P
G
OS thread
Processor (Logical)
Goroutine
Go runtime scheduler
M P G G G G
M P G G G
Global queue
M
P
G
OS thread
Processor (Logical)
Goroutine
Go runtime Scheduler
M P G G G G
M P G G G
M P G G G
M P G G G G G G
Global queue
M
P
G
OS thread
Processor (Logical)
Goroutine
Go runtime Scheduler
M P G G G G
M P G G G
M P G G G
M P G G G G G G
Global queue
New threads inherit
state from already
running threads
Go runtime model
eth0
more
Worker
goroutines
net namespaces n
Linux machine Go Process
OS thread
Goroutine
runtime.LockOSThread()
Go runtime model
eth0
more
Worker
goroutines
net namespaces n
Linux machine Go Process
How Go 1.10 Fixed it
Go runtime scheduler
M P G G G G
M P G
M
P
G
OS thread
Processor (Logical)
Goroutine
Go runtime scheduler
M P G
M P G
M
P
G
OS thread
Processor
(Logical)
Goroutine
runtime.LockOSThread()
Go runtime scheduler in go 1.10
M P G
M P G
startTemplateThread()
M
P
G
OS thread
Processor
(Logical)
Goroutine
runtime.LockOSThread()
LockOSThread() in go 1.10
M P G
M P G
Template thread
M
P
G
OS thread
Processor (Logical)
Goroutine
runtime.LockOSThread()
Go runtime scheduler in 1.10
M P G
M P G
Template thread
M
P
G
OS thread
Processor (Logical)
Goroutine
runtime.LockOSThread()
M P G
M P G
Template thread creation in Go Process
eth0
net namespaces n
Linux machine
Go Process
Template
thread
Adding worker goroutines to host network
namespace
eth0
net namespaces n
Linux machine
Go Process
Template
thread
Summary
• If creating / managing Linux network namespaces using Go, use Go
version >= 1.10
Thank You!!!
runtime.LockOSThread()
M P G
M P G
M P G G G
M P G G G G G G
Global queue
Goroutine called
LockOSThread()
M
P
G
OS thread
Processor
(Logical)
Goroutine
runtime.LockOSThread()
Docker runtime adopted Go ??
• Static compilation
• Asynchronous primitives
• Multi-arch builds
• Faster development
• Awesome Documentations
How to manage network namespaces
with Go 1.10 and beyond
ns := createNetNamespace()
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ns.Do(func(_ ns.NetNS) error {
runtime.LockOSThread()
cb()
}
If the goroutine here changes the state of the
thread, let the thread exit with goroutine
Bonus feature
• OS thread terminates if goroutine exits
• runtime.LockOSThread() is nested.
• UnlockOSThread must be called the same number of times in order to unlock the thread.

More Related Content

What's hot

Learn Git Fundamentals
Learn Git FundamentalsLearn Git Fundamentals
Learn Git FundamentalsJatin Sharma
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internallySeongJae Park
 
Dive into Pinkoi 2013
Dive into Pinkoi 2013Dive into Pinkoi 2013
Dive into Pinkoi 2013Mosky Liu
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHubviet nghiem
 
Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...
Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...
Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...David Dias
 
Concurrency
ConcurrencyConcurrency
Concurrencyehuard
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemTommaso Visconti
 
Reversing the dropbox client on windows
Reversing the dropbox client on windowsReversing the dropbox client on windows
Reversing the dropbox client on windowsextremecoders
 
PuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, Puppet
PuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, PuppetPuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, Puppet
PuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, PuppetPuppet
 
Dev8d 2011-pipe2 py
Dev8d 2011-pipe2 pyDev8d 2011-pipe2 py
Dev8d 2011-pipe2 pyTony Hirst
 
PuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, Puppet
PuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, PuppetPuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, Puppet
PuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, PuppetPuppet
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyAerospike
 
Taming Rich GML with Stetl - FOSS4G 2013 Nottingham
Taming Rich GML with Stetl - FOSS4G 2013 NottinghamTaming Rich GML with Stetl - FOSS4G 2013 Nottingham
Taming Rich GML with Stetl - FOSS4G 2013 NottinghamJust van den Broecke
 

What's hot (20)

Learn Git Fundamentals
Learn Git FundamentalsLearn Git Fundamentals
Learn Git Fundamentals
 
Deep dark-side of git: How git works internally
Deep dark-side of git: How git works internallyDeep dark-side of git: How git works internally
Deep dark-side of git: How git works internally
 
Dive into Pinkoi 2013
Dive into Pinkoi 2013Dive into Pinkoi 2013
Dive into Pinkoi 2013
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHub
 
Linux comands for Hadoop
Linux comands for HadoopLinux comands for Hadoop
Linux comands for Hadoop
 
Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...
Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...
Resource Discovery for the Web Platform using a P2P Overlay Network with WebR...
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
 
Reversing the dropbox client on windows
Reversing the dropbox client on windowsReversing the dropbox client on windows
Reversing the dropbox client on windows
 
PuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, Puppet
PuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, PuppetPuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, Puppet
PuppetConf 2017: How People Actually Write Puppet- Gareth Rushgrove, Puppet
 
Git basic
Git basicGit basic
Git basic
 
Dev8d 2011-pipe2 py
Dev8d 2011-pipe2 pyDev8d 2011-pipe2 py
Dev8d 2011-pipe2 py
 
PuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, Puppet
PuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, PuppetPuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, Puppet
PuppetConf 2017: Puppet Platform: A Path Forward- Eric Sorenson, Puppet
 
Scapy
ScapyScapy
Scapy
 
Rpm Introduction
Rpm IntroductionRpm Introduction
Rpm Introduction
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war story
 
Knolx master-slides
Knolx master-slidesKnolx master-slides
Knolx master-slides
 
Taming Rich GML with Stetl - FOSS4G 2013 Nottingham
Taming Rich GML with Stetl - FOSS4G 2013 NottinghamTaming Rich GML with Stetl - FOSS4G 2013 Nottingham
Taming Rich GML with Stetl - FOSS4G 2013 Nottingham
 

Similar to GopherCon Denver LT 2018

Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Schedulermatthewrdale
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Giulio Vian
 
Git 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizationsGit 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizationsIan Walls
 
Jordan Hubbard Talk @ LISA
Jordan Hubbard Talk @ LISAJordan Hubbard Talk @ LISA
Jordan Hubbard Talk @ LISAguest4c923d
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionJuraj Michálek
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Henry Schreiner
 
Terraform GitOps on Codefresh
Terraform GitOps on CodefreshTerraform GitOps on Codefresh
Terraform GitOps on CodefreshCodefresh
 
"Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko
"Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko "Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko
"Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko Fwdays
 
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroductionCodemotion
 
1032 cs208 g operation system ip camera case share.v0.2
1032 cs208 g operation system ip camera case share.v0.21032 cs208 g operation system ip camera case share.v0.2
1032 cs208 g operation system ip camera case share.v0.2Stanley Ho
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesJérôme Petazzoni
 
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroductionBruno Bossola
 
Javascript in Linux Desktop
Javascript in Linux DesktopJavascript in Linux Desktop
Javascript in Linux DesktopYuren Ju
 
Pharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alphaPharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alphaPharo
 
Docker architecture rework case study
Docker  architecture rework case studyDocker  architecture rework case study
Docker architecture rework case studydchaffiol
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingHenry Schreiner
 
Linux containers_Docker
Linux containers_DockerLinux containers_Docker
Linux containers_DockerDmitry Fedorov
 

Similar to GopherCon Denver LT 2018 (20)

Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Scheduler
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
 
Git 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizationsGit 101, or, how to sanely manage your Koha customizations
Git 101, or, how to sanely manage your Koha customizations
 
Ontopia tutorial
Ontopia tutorialOntopia tutorial
Ontopia tutorial
 
Jordan Hubbard Talk @ LISA
Jordan Hubbard Talk @ LISAJordan Hubbard Talk @ LISA
Jordan Hubbard Talk @ LISA
 
Startup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django sessionStartup Camp - Git, Python, Django session
Startup Camp - Git, Python, Django session
 
Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024Software Quality Assurance Tooling - Wintersession 2024
Software Quality Assurance Tooling - Wintersession 2024
 
Terraform GitOps on Codefresh
Terraform GitOps on CodefreshTerraform GitOps on Codefresh
Terraform GitOps on Codefresh
 
"Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko
"Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko "Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko
"Modern DevOps & Real Life Applications. 3.0.0-devops+20230318", Igor Fesenko
 
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroduction
 
1032 cs208 g operation system ip camera case share.v0.2
1032 cs208 g operation system ip camera case share.v0.21032 cs208 g operation system ip camera case share.v0.2
1032 cs208 g operation system ip camera case share.v0.2
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
 
What's New in Groovy 1.6?
What's New in Groovy 1.6?What's New in Groovy 1.6?
What's New in Groovy 1.6?
 
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroduction
 
Javascript in Linux Desktop
Javascript in Linux DesktopJavascript in Linux Desktop
Javascript in Linux Desktop
 
Pharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alphaPharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alpha
 
Docker architecture rework case study
Docker  architecture rework case studyDocker  architecture rework case study
Docker architecture rework case study
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meeting
 
Linux containers_Docker
Linux containers_DockerLinux containers_Docker
Linux containers_Docker
 

Recently uploaded

Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxchumtiyababu
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 

Recently uploaded (20)

Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

GopherCon Denver LT 2018

  • 2. Docker daemon eth0 Linux machine Docker Daemon
  • 3. Docker runtime adopted Go • Promoted wider adoption of Go as a systems language • Bug fixes in Docker produced more Go programmers • Identifying systems level problem in Go runtime related to syscalls / threads
  • 4. Isolation in Docker container: namespaces • Process trees (PID Namespace) • Mounts (MNT namespace) • Network (Net namespace) • Users / UIDs (User Namespace) • Hostnames (UTS Namespace) • Inter Process Communication (IPC Namespace)
  • 5. Lets see this in action
  • 6. Running a Go Process on Linux machine eth0 Linux machine Go Process OS thread Goroutine
  • 7. Add new Network Namespace with lo (loopback) only interface eth0 net namespaces n Linux machine Go Process OS thread Goroutine
  • 8. Adding worker goroutines to new network namespaces eth0 Worker goroutines net namespaces n Linux machine Go Process OS thread Goroutine runtime.LockOSThread()
  • 9. Adding worker goroutines to host network namespace eth0 Worker goroutines net namespaces n Linux machine Go Process OS thread Goroutine runtime.LockOSThread()
  • 10. Adding worker goroutines to host network namespace eth0 more Worker goroutines net namespaces n Linux machine Go Process OS thread Goroutine runtime.LockOSThread()
  • 11. Incorrect interfaces detected by goroutines eth0 more Worker goroutines net namespaces n Linux machine Go Process goroutine with wrong interface info
  • 12. Go runtime scheduler M P G G G G M P G M P G OS thread Processor (Logical) Goroutine
  • 13. Go runtime scheduler M P G G G G M P G G G Global queue M P G OS thread Processor (Logical) Goroutine
  • 14. Go runtime Scheduler M P G G G G M P G G G M P G G G M P G G G G G G Global queue M P G OS thread Processor (Logical) Goroutine
  • 15. Go runtime Scheduler M P G G G G M P G G G M P G G G M P G G G G G G Global queue New threads inherit state from already running threads
  • 16. Go runtime model eth0 more Worker goroutines net namespaces n Linux machine Go Process OS thread Goroutine runtime.LockOSThread()
  • 17. Go runtime model eth0 more Worker goroutines net namespaces n Linux machine Go Process
  • 18. How Go 1.10 Fixed it
  • 19. Go runtime scheduler M P G G G G M P G M P G OS thread Processor (Logical) Goroutine
  • 20. Go runtime scheduler M P G M P G M P G OS thread Processor (Logical) Goroutine runtime.LockOSThread()
  • 21. Go runtime scheduler in go 1.10 M P G M P G startTemplateThread() M P G OS thread Processor (Logical) Goroutine runtime.LockOSThread()
  • 22. LockOSThread() in go 1.10 M P G M P G Template thread M P G OS thread Processor (Logical) Goroutine runtime.LockOSThread()
  • 23. Go runtime scheduler in 1.10 M P G M P G Template thread M P G OS thread Processor (Logical) Goroutine runtime.LockOSThread() M P G M P G
  • 24. Template thread creation in Go Process eth0 net namespaces n Linux machine Go Process Template thread
  • 25. Adding worker goroutines to host network namespace eth0 net namespaces n Linux machine Go Process Template thread
  • 26. Summary • If creating / managing Linux network namespaces using Go, use Go version >= 1.10
  • 28. runtime.LockOSThread() M P G M P G M P G G G M P G G G G G G Global queue Goroutine called LockOSThread() M P G OS thread Processor (Logical) Goroutine runtime.LockOSThread()
  • 29. Docker runtime adopted Go ?? • Static compilation • Asynchronous primitives • Multi-arch builds • Faster development • Awesome Documentations
  • 30.
  • 31. How to manage network namespaces with Go 1.10 and beyond ns := createNetNamespace() runtime.LockOSThread() defer runtime.UnlockOSThread() ns.Do(func(_ ns.NetNS) error { runtime.LockOSThread() cb() } If the goroutine here changes the state of the thread, let the thread exit with goroutine
  • 32. Bonus feature • OS thread terminates if goroutine exits • runtime.LockOSThread() is nested. • UnlockOSThread must be called the same number of times in order to unlock the thread.

Editor's Notes

  1. How Goroutines, threads, processors work in Go
  2. How Goroutines, threads, processors work in Go
  3. How Goroutines, threads, processors work in Go
  4. How Goroutines, threads, processors work in Go
  5. How Goroutines, threads, processors work in Go
  6. How Goroutines, threads, processors work in Go
  7. How Goroutines, threads, processors work in Go
  8. How Goroutines, threads, processors work in Go
  9. How Goroutines, threads, processors work in Go
  10. How Goroutines, threads, processors work in Go
  11. How Goroutines, threads, processors work in Go