Skip to content

Commit 5667f5b

Browse files
authored
Benchmark profiling instructions and commands (#214)
* DummySegment and DummySubSegment creation * Revert "DummySegment and DummySubSegment creation" This reverts commit 4edb4b5. * Revert "Revert "DummySegment and DummySubSegment creation"" This reverts commit 0442d84. * ran gofmt command to remove golint warnings * remove redundent declaration * Added Dummysegment creation logic * Added reviewdog suggestions * modified code based on feedback * Benchmark instructions and makefile * Remove unnecessary logs
1 parent c6b0644 commit 5667f5b

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

benchmark/READEME.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Benchmark Instructions for AWS X-Ray Go SDK
2+
AWS X-Ray Go SDK introduced benchmarks to identify performance bottlenecks of AWS X-Ray Go SDK codebase. Moreover, benchmarks can be used to identify data races and locking issues. Below are the instructions on how to run AWS X-Ray Go SDK benchmarks using Go commands and makefile.
3+
4+
## Run all the benchmarks using Go Command
5+
```
6+
go test -benchmem -run=^$$ -bench=. ./...
7+
```
8+
9+
## Run all the benchmark using makefile
10+
Running below command will generate benchmark_sdk.md for analysis. To avoid excessive logging change the loglevel to LogLevelError.
11+
```
12+
make benchmark_sdk
13+
```
14+
## Run memory profiling of xray package using makefile
15+
Running below command will generate benchmark_xray_mem.md for analysis.
16+
```
17+
make benchmark_xray_mem
18+
```
19+
## Run cpu profiling of xray package using makefile
20+
Running below command will generate benchmark_xray_cpu.md for analysis.
21+
```
22+
make benchmark_xray_cpu
23+
```
24+

makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,44 @@ fmt:
2222

2323
golangci-lint:
2424
golangci-lint run
25+
26+
# run all the benchmarks of X-Ray SDK (to minimize logging set loglevel to LogLevelError)
27+
benchmark_sdk:
28+
echo "\`\`\`" > benchmark/benchmark_sdk.md
29+
go test -v -benchmem -run=^$$ -bench=. ./... >> benchmark/benchmark_sdk.md
30+
echo >> benchmark/benchmark_sdk.md
31+
echo "\`\`\`" >> benchmark/benchmark_sdk.md
32+
33+
# Profiling memory (xray package only and to minimize logging set loglevel to LogLevelError)
34+
benchmark_xray_mem:
35+
go test -benchmem -run=^$$ -bench=. ./xray -memprofile=benchmark/benchmark_xray_mem.profile
36+
37+
echo "\`\`\`go" > benchmark/benchmark_xray_mem.md
38+
echo >> benchmark/benchmark_xray_mem.md
39+
echo "top" | go tool pprof -sample_index=alloc_objects xray.test benchmark/benchmark_xray_mem.profile >> benchmark/benchmark_xray_mem.md
40+
echo >> benchmark/benchmark_xray_mem.md
41+
echo "top -cum" | go tool pprof -sample_index=alloc_objects xray.test benchmark/benchmark_xray_mem.profile >> benchmark/benchmark_xray_mem.md
42+
echo >> benchmark/benchmark_xray_mem.md
43+
echo "list xray" | go tool pprof -sample_index=alloc_objects xray.test benchmark/benchmark_xray_mem.profile >> benchmark/benchmark_xray_mem.md
44+
echo >> Benchmark/benchmark_xray_mem.md
45+
echo "\`\`\`" >> benchmark/benchmark_xray_mem.md
46+
47+
rm xray.test
48+
rm benchmark/benchmark_xray_mem.profile
49+
50+
# profiling cpu (xray package only and to minimize logging set loglevel to LogLevelError)
51+
benchmark_xray_cpu:
52+
go test -benchmem -run=^$$ -bench=. ./xray -cpuprofile=benchmark/benchmark_xray_cpu.profile
53+
54+
echo "\`\`\`go" > benchmark/benchmark_xray_cpu.md
55+
echo >> benchmark/benchmark_xray_cpu.md
56+
echo "top" | go tool pprof xray.test benchmark/benchmark_xray_cpu.profile >> benchmark/benchmark_xray_cpu.md
57+
echo >> benchmark/benchmark_xray_cpu.md
58+
echo "top -cum" | go tool pprof xray.test benchmark/benchmark_xray_cpu.profile >> benchmark/benchmark_xray_cpu.md
59+
echo >> benchmark/benchmark_xray_cpu.md
60+
echo "list xray" | go tool pprof xray.test benchmark/benchmark_xray_cpu.profile >> benchmark/benchmark_xray_cpu.md
61+
echo >> benchmark/benchmark_xray_cpu.md
62+
echo "\`\`\`" >> benchmark/benchmark_xray_cpu.md
63+
64+
rm xray.test
65+
rm benchmark/benchmark_xray_cpu.profile

xray/config_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ func TestSelectiveConfigWithContext(t *testing.T) {
261261

262262
// Benchmarks
263263
func BenchmarkConfigure(b *testing.B) {
264-
daemonAddr := "127.0.0.1:3000"
265264
logLevel := "error"
266265
logFormat := "[%Level] %Msg%n"
267266
serviceVersion := "TestVersion"
@@ -272,7 +271,6 @@ func BenchmarkConfigure(b *testing.B) {
272271
cms := &TestContextMissingStrategy{}
273272

274273
configure := Config{
275-
DaemonAddr: daemonAddr,
276274
ServiceVersion: serviceVersion,
277275
SamplingStrategy: ss,
278276
ExceptionFormattingStrategy: efs,

0 commit comments

Comments
 (0)