Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Parallel Computing in Go
Search
Fabian Becker
November 17, 2012
Technology
240
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Parallel Computing in Go
Fabian Becker
November 17, 2012
Transcript
17 slides
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
Other Decks in Technology
See All in Technology
Kiro のリモートワークスペース: IDE は手元のままで、ワークスペースをクラウド、コンテナ、自前のマシンに置く
inariku
PRO
1
200
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
20
29k
コーディングできない僕にBobが舞い降りた
shumpei3
0
210
実測データからサービスの成長余力を測る。負荷シナリオ・テストデータ・限界値の設計
kazatohiei
1
180
メルカリの小規模チーム「Pod」で、 エンジニアがデータアナリストなしで、 AIを使ってデータ分析の自走を目指す取り組み
jackojacko_
1
360
AWS DevOps Agentの構造から読み解く運用 AI エージェントの設計原則/aws-devops-agent-design-principles
tomoki10
0
290
AIエージェントのアーキテクチャ設計
nsatoh
0
550
Amazon EFS のマルウェアスキャンをClamAV で自前実装したら苦労した話
mtmtfactory01
0
120
[DBRE Summit 26] DBRE はデータベース運用をどう変えたのか
_awache
0
130
Taking back control of your AI development
inesmontani
PRO
0
310
Metadata - Section 4 : MODS (Metadata Object Description Schema )
mohab1
0
120
プラガブルで宣言的なソフトウェアファクトリーを支えるTypeScript
timakin
4
1.1k
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
540
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
630
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
How to Think Like a Performance Engineer
csswizardry
28
3k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
Producing Creativity
orderedlist
PRO
348
41k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
What's in a price? How to price your products and services
michaelherold
247
13k
Optimizing for Happiness
mojombo
378
72k