Skip to content

Commit b2352eb

Browse files
committed
More improvements
1 parent d8508d4 commit b2352eb

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

perf.slide

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,38 +151,53 @@ Demo: fib
151151
# don't run any tests, target individual benchmarks
152152
# -lines -pdf -nodecount=10 -focus=fib
153153
# be careful about hiding things!
154+
# mention:
155+
# can set CPU profiling rate
154156

155157

156-
* CPU profiling
158+
* Memory profiling
157159

158160
Demo: ascii
159161

160-
# mention:
161-
# can set CPU profiling rate
162+
# start with load
163+
# discover syscalls
164+
# remove syscalls
165+
166+
# discover malloc
167+
# add ReportAllocs
168+
# do mem profiling
169+
# need -l
170+
# need -alloc_objects, discuss alternatives
171+
# discuss -memprofilerate
172+
173+
# move on to encode
174+
# discover malloc
175+
# add ReportAllocs
176+
# mem profiling
177+
# need -l? nope.
178+
# need -runtime flag to pprof
179+
# aha! string concatenation. Use a bytes.Buffer. Will discuss more later. common problem.
180+
181+
# syscall: look at syscalls. malloc: look at allocation. mutex/futex/channel-y things? look at blocking. We'll get to that.
162182

163183

184+
* Profiling gotchas
185+
186+
- Don't run multiple profilers at once.
187+
- Don't run tests when profiling.
188+
- If the output doesn't make sense, poke around or ask for help.
189+
190+
# pprof has a crappy UI
191+
192+
193+
* Block profiling
194+
195+
Demo: ngram
196+
164197
* END OF DEVELOPED SLIDES
165198

166199
* More content...
167200

168-
03. Profiling
169-
0302 CPU profiling a benchmark
170-
preventing inlining, setting cpu profiling rate
171-
Cues that other kinds of profiling are helpful:
172-
Lots of time spent in GC, channel/sync ops, syscalls.
173-
Don't use multiple profilers at once.
174-
Don't run tests when profiling, because the whole
175-
execution is profiled (example: strconv package).
176-
0303 Tour of pprof
177-
Command line interface, pdf/image generation, web
178-
Interpreting the numbers
179-
-cum, -nodefraction, -nodecount
180-
-focus and -ignore
181-
-functions/-files/-lines/-addresses
182-
Lots more: go tool pprof -h
183-
0304 Memory profiling a benchmark
184-
-memprofile, -memprofilerate
185-
-alloc_space/-alloc_objects/-inuse_space/-inuse_objects
186201
0305 Whole program profiling
187202
runtime package profiling hooks, ReadMemStats
188203
net/http/pprof, expvar packages.
@@ -322,6 +337,7 @@ Demo: ascii
322337

323338
# Buffer i/o. Pass giant values using pointers.
324339
# Read the docs, pay attention to loops, use the most recent version of Go.
340+
# stream instead of buffering
325341

326342

327343
* Good habits, part 1

0 commit comments

Comments
 (0)