Skip to content

Commit

Permalink
Benchmark profiling instructions and commands (#214)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bhautikpip committed Apr 6, 2020
1 parent c6b0644 commit 5667f5b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
24 changes: 24 additions & 0 deletions benchmark/READEME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Benchmark Instructions for AWS X-Ray Go SDK
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.

## Run all the benchmarks using Go Command
```
go test -benchmem -run=^$$ -bench=. ./...
```

## Run all the benchmark using makefile
Running below command will generate benchmark_sdk.md for analysis. To avoid excessive logging change the loglevel to LogLevelError.
```
make benchmark_sdk
```
## Run memory profiling of xray package using makefile
Running below command will generate benchmark_xray_mem.md for analysis.
```
make benchmark_xray_mem
```
## Run cpu profiling of xray package using makefile
Running below command will generate benchmark_xray_cpu.md for analysis.
```
make benchmark_xray_cpu
```

41 changes: 41 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,44 @@ fmt:

golangci-lint:
golangci-lint run

# run all the benchmarks of X-Ray SDK (to minimize logging set loglevel to LogLevelError)
benchmark_sdk:
echo "\`\`\`" > benchmark/benchmark_sdk.md
go test -v -benchmem -run=^$$ -bench=. ./... >> benchmark/benchmark_sdk.md
echo >> benchmark/benchmark_sdk.md
echo "\`\`\`" >> benchmark/benchmark_sdk.md

# Profiling memory (xray package only and to minimize logging set loglevel to LogLevelError)
benchmark_xray_mem:
go test -benchmem -run=^$$ -bench=. ./xray -memprofile=benchmark/benchmark_xray_mem.profile

echo "\`\`\`go" > benchmark/benchmark_xray_mem.md
echo >> benchmark/benchmark_xray_mem.md
echo "top" | go tool pprof -sample_index=alloc_objects xray.test benchmark/benchmark_xray_mem.profile >> benchmark/benchmark_xray_mem.md
echo >> benchmark/benchmark_xray_mem.md
echo "top -cum" | go tool pprof -sample_index=alloc_objects xray.test benchmark/benchmark_xray_mem.profile >> benchmark/benchmark_xray_mem.md
echo >> benchmark/benchmark_xray_mem.md
echo "list xray" | go tool pprof -sample_index=alloc_objects xray.test benchmark/benchmark_xray_mem.profile >> benchmark/benchmark_xray_mem.md
echo >> Benchmark/benchmark_xray_mem.md
echo "\`\`\`" >> benchmark/benchmark_xray_mem.md

rm xray.test
rm benchmark/benchmark_xray_mem.profile

# profiling cpu (xray package only and to minimize logging set loglevel to LogLevelError)
benchmark_xray_cpu:
go test -benchmem -run=^$$ -bench=. ./xray -cpuprofile=benchmark/benchmark_xray_cpu.profile

echo "\`\`\`go" > benchmark/benchmark_xray_cpu.md
echo >> benchmark/benchmark_xray_cpu.md
echo "top" | go tool pprof xray.test benchmark/benchmark_xray_cpu.profile >> benchmark/benchmark_xray_cpu.md
echo >> benchmark/benchmark_xray_cpu.md
echo "top -cum" | go tool pprof xray.test benchmark/benchmark_xray_cpu.profile >> benchmark/benchmark_xray_cpu.md
echo >> benchmark/benchmark_xray_cpu.md
echo "list xray" | go tool pprof xray.test benchmark/benchmark_xray_cpu.profile >> benchmark/benchmark_xray_cpu.md
echo >> benchmark/benchmark_xray_cpu.md
echo "\`\`\`" >> benchmark/benchmark_xray_cpu.md

rm xray.test
rm benchmark/benchmark_xray_cpu.profile
2 changes: 0 additions & 2 deletions xray/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func TestSelectiveConfigWithContext(t *testing.T) {

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

configure := Config{
DaemonAddr: daemonAddr,
ServiceVersion: serviceVersion,
SamplingStrategy: ss,
ExceptionFormattingStrategy: efs,
Expand Down

0 comments on commit 5667f5b

Please sign in to comment.