profiling go code a beginners tutorial

20
Profiling Go code A beginners tutorial Go Stockholm Meetup #7 “High Performance Go” Dec 5th 2013 Samuel Lampa @smllmp +samuellampa saml.rilspace.org Developer at www.uppmax.uu.se, www.farmbio.uu.se, rilpartner.se

Upload: samuel-lampa

Post on 14-May-2015

822 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Profiling go code   a beginners tutorial

Profiling Go codeA beginners tutorial

Go Stockholm Meetup #7 “High Performance Go”Dec 5th 2013

Samuel Lampa@smllmp

+samuellampasaml.rilspace.org

Developer atwww.uppmax.uu.se, www.farmbio.uu.se, rilpartner.se

Page 2: Profiling go code   a beginners tutorial

Enable profiling: Standard way

Not terribly user friendly :/

Page 3: Profiling go code   a beginners tutorial

… especially compared to python:

Page 4: Profiling go code   a beginners tutorial

But, thanks to this Guy at Canonical(Dave Cheney) ...

● dave.cheney.net● twitter.com/davecheney

Page 5: Profiling go code   a beginners tutorial

… we can now enable profiling in a much easier way:

Page 6: Profiling go code   a beginners tutorial

How to run it

Page 7: Profiling go code   a beginners tutorial

How to run it

Page 8: Profiling go code   a beginners tutorial

How to run it

Page 9: Profiling go code   a beginners tutorial

Call graph as PDF, weighted by execution time

Page 10: Profiling go code   a beginners tutorial

A few more options ...

Page 11: Profiling go code   a beginners tutorial

Zoomable / Scrollable SVG in browser

Page 12: Profiling go code   a beginners tutorial

A few performance tricks for string processing...

Page 13: Profiling go code   a beginners tutorial

Version 1

Page 14: Profiling go code   a beginners tutorial

Version 2 – Table optimization

Page 15: Profiling go code   a beginners tutorial

Version 3 – Using bufio Scanner(), new in Go 1.2

Page 16: Profiling go code   a beginners tutorial

Version 4 – Using pointers for counters

Page 17: Profiling go code   a beginners tutorial

Performance improvement, version 1-4

Page 18: Profiling go code   a beginners tutorial

Creds goes to ...

● Roger Peppe, also at Canonical, for help with the optimizations, and the final optimized version!

● twitter.com/rogpeppe

Page 19: Profiling go code   a beginners tutorial

Learn more

● blog.golang.org/profiling-go-programs● tinyurl.com/go-pprof-win (Using pprof on Windows)● blog.cloudflare.com/recycling-memory-buffers-in-go● saml.rilspace.org/moar-languagez-gc-content-in-pytho

n-d-fpc-c-and-c

Also, don't miss● gplus.to/golangplus● golangweekly.com

Page 20: Profiling go code   a beginners tutorial

Thank you!