Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Parallel Computing in Go
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Fabian Becker
November 17, 2012
Technology
2
230
Parallel Computing in Go
Fabian Becker
November 17, 2012
Tweet
Share
Other Decks in Technology
See All in Technology
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
880
配列に見る bash と zsh の違い
kazzpapa3
1
110
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
0
330
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
120
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
410
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.5k
Agile Leadership Summit Keynote 2026
m_seki
1
520
モダンUIでフルサーバーレスなAIエージェントをAmplifyとCDKでサクッとデプロイしよう
minorun365
4
150
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
1
350
データの整合性を保ちたいだけなんだ
shoheimitani
8
3k
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.2k
Featured
See All Featured
Music & Morning Musume
bryan
47
7.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Exploring anti-patterns in Rails
aemeredith
2
250
The Pragmatic Product Professional
lauravandoore
37
7.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
A Modern Web Designer's Workflow
chriscoyier
698
190k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
Transcript
Parallel Computation in Go Fabian Becker @geekproject
/me Open Source /me Piwik geekmonkey.org Ruby Evolutionary Algorithms Go
Why Go? • Why not? • C/C++ sucks • Distributed
systems • Multicore hardware
What does it offer? • lightweight syntax • statically typed
• garbage-collected (yay!) • concurrent • compiles to machine code
Anything else? • free and open source • enforced code
style • duck typing (type inference) • static typing • fast
Example import ( “fmt” ”http” ) func handler(c *http.Conn, r
*http.Request) { fmt.Fprintf(c, “Hello, %s\n”, r.URL.Path[1:]) } func main() { http.ListenAndServe(“:8080”, http.HandlerFunc(handler)) }
Concurrency • Communicating Sequential Processes – Hoare, 1978 • Goroutines
– Lighter than Threads – 100.000s – Channels • “Don't communicate by sharing memory; share memory by communicating.”
Example #1 var a string func f() { a =
“Hello World” } func main() { go f() println(a) }
Example #2 var c = make(chan int, 1) var a
string func f() { a = "hello, world" c < 0 } func main() { go f() <c print(a) }
Goroutines • Run on a set of threads • Ordinary
functions (coroutines) – “go” keyword • Blocking – System calls block – Handled by the scheduler – Non-blocked routines moved to another thread • Memory efficient!
Channels • Typed • “<-” operator channel := make(chan string)
• Worker function declaration: func worker(input string, results chan< string) { // do work results < result }
Channels #2 // A typed queue c := make(chan int)
// Buffered vs. unbuffered unbuf := make(chan int) buf := make(chan int, 100) // Send to a channel c < 10 // Receive from a channel i := <c
Testing • Go comes with a lightweight test suite –
“go test” • Automated tests are great! func TestFoo(t *testing.T) { ... }
Benchmarking • Benchmark all the things! func BenchmarkHello(b *testing.B) {
for i := 0; i < b.N; i++ { fmt.Sprintf("hello") } } • Nice for optimizing critical sections of your code
Who uses Go? • Google (No shit Sherlock!) • CloudFlare
• Heroku • SoundCloud • Novartis • ...
Thanks for attending! Questions?
Resources • http://godashboard.appspot.com/ • https://gobyexample.com/ • http://golang.org • http://areyoufuckingcoding.me/topic/golang •
http://geekmonkey.org/articles/20- comparison-of-ides-for-google-go