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
Fabian Becker
November 17, 2012
Technology
230
2
Share
Parallel Computing in Go
Fabian Becker
November 17, 2012
Other Decks in Technology
See All in Technology
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
No Types Needed, Just Callable Method Check
dak2
1
860
AgentCore×VPCでの設計パターンn選と勘所
har1101
3
270
自分のハンドルは自分で握れ! ― 自分のケイパビリティを増やし、メンバーのケイパビリティ獲得を支援する ― / Take the wheel yourself
takaking22
1
880
Revisiting [CLS] and Patch Token Interaction in Vision Transformers
yu4u
0
350
ぼくがかんがえたさいきょうのあうとぷっと
yama3133
0
190
Digitization部 紹介資料
sansan33
PRO
1
7.3k
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
78k
CloudSec JP #005 後締め ~ソフトウェアサプライチェーン攻撃から開発者のシークレットを守る~
lhazy
0
230
レビューしきれない?それは「全て人力でのレビュー」だからではないでしょうか
amixedcolor
0
300
みんなの「データ活用」を支えるストレージ担当から持ち込むAWS活用/コミュニティー設計TIPS 10選~「作れる」より、「続けられる」設計へ~
yoshiki0705
0
240
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
390
Featured
See All Featured
Prompt Engineering for Job Search
mfonobong
0
270
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
380
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
WENDY [Excerpt]
tessaabrams
10
37k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
130
Into the Great Unknown - MozCon
thekraken
40
2.4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
340
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
160
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
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