Skip to content

Commit e53b595

Browse files
Merge pull request #10 from filipecosta90/no-locking
Removed all locking on stats updates and introduce 32-bit ARM packed bin
2 parents 1ca8830 + 43425f8 commit e53b595

File tree

4 files changed

+45
-25
lines changed

4 files changed

+45
-25
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
uses: actions/setup-go@v2
2020
with:
2121
go-version: ${{ matrix.go-version }}
22-
- name: Make all
23-
run: make all
22+
- name: Make Release
23+
run: make release
2424
- name: Upload release binaries
2525
uses: alexellis/[email protected]
2626
env:

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Go parameters
22
GOCMD=GO111MODULE=on go
33
GOBUILD=$(GOCMD) build
4+
GOBUILDRACE=$(GOCMD) build -race
45
GOINSTALL=$(GOCMD) install
56
GOCLEAN=$(GOCMD) clean
67
GOTEST=$(GOCMD) test
78
GOGET=$(GOCMD) get
89
GOMOD=$(GOCMD) mod
910
GOFMT=$(GOCMD) fmt
1011
DISTDIR = ./dist
11-
OS_ARCHs = "linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
12+
OS_ARCHs = "linux/amd64 linux/arm64 linux/arm windows/amd64 darwin/amd64 darwin/arm64"
1213

1314
# Build-time GIT variables
1415
ifeq ($(GIT_SHA),)
@@ -20,12 +21,16 @@ GIT_DIRTY:=$(shell git diff --no-ext-diff 2> /dev/null | wc -l)
2021
endif
2122

2223
.PHONY: all test coverage
23-
all: test build release
24+
all: test build
2425

2526
build:
2627
$(GOBUILD) \
2728
-ldflags="-X 'main.GitSHA1=$(GIT_SHA)' -X 'main.GitDirty=$(GIT_DIRTY)'" .
2829

30+
build-race:
31+
$(GOBUILDRACE) \
32+
-ldflags="-X 'main.GitSHA1=$(GIT_SHA)' -X 'main.GitDirty=$(GIT_DIRTY)'" .
33+
2934
checkfmt:
3035
@echo 'Checking gofmt';\
3136
bash -c "diff -u <(echo -n) <(gofmt -d .)";\

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ If you don't have go on your machine and just want to use the produced binaries
1111

1212
| OS | Arch | Link |
1313
| :--- | :---: | ---: |
14-
| Windows | amd64 | [redis-benchmark-go_windows_amd64.exe](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_windows_amd64.exe) |
15-
| Linux | amd64 | [redis-benchmark-go_linux_amd64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_linux_amd64) |
16-
| Linux | arm64 | [redis-benchmark-go_linux_arm64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_linux_arm64) |
17-
| Darwin | amd64 | [redis-benchmark-go_darwin_amd64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_darwin_amd64) |
18-
| Darwin | arm64 | [redis-benchmark-go_darwin_arm64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_darwin_arm64) |
14+
| Windows | amd64 (64-bit X86) | [redis-benchmark-go_windows_amd64.exe](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_windows_amd64.exe) |
15+
| Linux | amd64 (64-bit X86) | [redis-benchmark-go_linux_amd64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_linux_amd64) |
16+
| Linux | arm64 (64-bit ARM) | [redis-benchmark-go_linux_arm64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_linux_arm64) |
17+
| Linux | arm (32-bit ARM) | [redis-benchmark-go_linux_arm](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_linux_arm) |
18+
| Darwin | amd64 (64-bit X86) | [redis-benchmark-go_darwin_amd64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_darwin_amd64) |
19+
| Darwin | arm64 (64-bit ARM) | [redis-benchmark-go_darwin_arm64](https://s3.amazonaws.com/benchmarks.redislabs/tools/redis-benchmark-go/redis-benchmark-go_darwin_arm64) |
1920

2021

2122

redis-bechmark-go.go

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"os"
1313
"os/signal"
1414
"sync"
15-
"sync/atomic"
1615
"time"
1716
)
1817

@@ -23,6 +22,11 @@ var latencies *hdrhistogram.Histogram
2322
const Inf = rate.Limit(math.MaxFloat64)
2423
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
2524

25+
type datapoint struct {
26+
success bool
27+
duration_ms int64
28+
}
29+
2630
func stringWithCharset(length int, charset string) string {
2731

2832
b := make([]byte, length)
@@ -32,11 +36,11 @@ func stringWithCharset(length int, charset string) string {
3236
return string(b)
3337
}
3438

35-
func ingestionRoutine(conn radix.Client, enableMultiExec, continueOnError bool, cmdS []string, keyspacelen, datasize, number_samples uint64, loop bool, debug_level int, wg *sync.WaitGroup, keyplace, dataplace int, useLimiter bool, rateLimiter *rate.Limiter) {
39+
func ingestionRoutine(conn radix.Client, enableMultiExec bool, datapointsChan chan datapoint, continueOnError bool, cmdS []string, keyspacelen, datasize, number_samples uint64, loop bool, debug_level int, wg *sync.WaitGroup, keyplace, dataplace int, useLimiter bool, rateLimiter *rate.Limiter) {
3640
defer wg.Done()
3741
for i := 0; uint64(i) < number_samples || loop; i++ {
3842
rawCurrentCmd, _, _ := keyBuildLogic(keyplace, dataplace, datasize, keyspacelen, cmdS)
39-
sendCmdLogic(conn, rawCurrentCmd, enableMultiExec, continueOnError, debug_level, useLimiter, rateLimiter)
43+
sendCmdLogic(conn, rawCurrentCmd, enableMultiExec, datapointsChan, continueOnError, debug_level, useLimiter, rateLimiter)
4044
}
4145
}
4246

@@ -53,7 +57,7 @@ func keyBuildLogic(keyPos int, dataPos int, datasize, keyspacelen uint64, cmdS [
5357
return rawCmd, key, radix.ClusterSlot([]byte(newCmdS[1]))
5458
}
5559

56-
func sendCmdLogic(conn radix.Client, cmd radix.CmdAction, enableMultiExec bool, continueOnError bool, debug_level int, useRateLimiter bool, rateLimiter *rate.Limiter) {
60+
func sendCmdLogic(conn radix.Client, cmd radix.CmdAction, enableMultiExec bool, datapointsChan chan datapoint, continueOnError bool, debug_level int, useRateLimiter bool, rateLimiter *rate.Limiter) {
5761
if useRateLimiter {
5862
r := rateLimiter.ReserveN(time.Now(), int(1))
5963
time.Sleep(r.Delay())
@@ -98,7 +102,6 @@ func sendCmdLogic(conn radix.Client, cmd radix.CmdAction, enableMultiExec bool,
98102
endT := time.Now()
99103
if err != nil {
100104
if continueOnError {
101-
atomic.AddUint64(&totalErrors, uint64(1))
102105
if debug_level > 0 {
103106
log.Println(fmt.Sprintf("Received an error with the following command(s): %v, error: %v", cmd, err))
104107
}
@@ -107,11 +110,7 @@ func sendCmdLogic(conn radix.Client, cmd radix.CmdAction, enableMultiExec bool,
107110
}
108111
}
109112
duration := endT.Sub(startT)
110-
err = latencies.RecordValue(duration.Microseconds())
111-
if err != nil {
112-
log.Fatalf("Received an error while recording latencies: %v", err)
113-
}
114-
atomic.AddUint64(&totalCommands, uint64(1))
113+
datapointsChan <- datapoint{!(err != nil), duration.Microseconds()}
115114
}
116115

117116
func main() {
@@ -190,17 +189,18 @@ func main() {
190189
} else {
191190
standalone = getStandaloneConn(connectionStr, opts, *clients)
192191
}
192+
datapointsChan := make(chan datapoint, *numberRequests)
193193
for channel_id := 1; uint64(channel_id) <= *clients; channel_id++ {
194194
wg.Add(1)
195195
cmd := make([]string, len(args))
196196
copy(cmd, args)
197197
if *clusterMode {
198-
go ingestionRoutine(cluster, *multi, true, cmd, *keyspacelen, *datasize, samplesPerClient, *loop, int(*debug), &wg, keyPlaceOlderPos, dataPlaceOlderPos, useRateLimiter, rateLimiter)
198+
go ingestionRoutine(cluster, *multi, datapointsChan, true, cmd, *keyspacelen, *datasize, samplesPerClient, *loop, int(*debug), &wg, keyPlaceOlderPos, dataPlaceOlderPos, useRateLimiter, rateLimiter)
199199
} else {
200200
if *multi {
201-
go ingestionRoutine(getStandaloneConn(connectionStr, opts, 1), *multi, true, cmd, *keyspacelen, *datasize, samplesPerClient, *loop, int(*debug), &wg, keyPlaceOlderPos, dataPlaceOlderPos, useRateLimiter, rateLimiter)
201+
go ingestionRoutine(getStandaloneConn(connectionStr, opts, 1), *multi, datapointsChan, true, cmd, *keyspacelen, *datasize, samplesPerClient, *loop, int(*debug), &wg, keyPlaceOlderPos, dataPlaceOlderPos, useRateLimiter, rateLimiter)
202202
} else {
203-
go ingestionRoutine(standalone, *multi, true, cmd, *keyspacelen, *datasize, samplesPerClient, *loop, int(*debug), &wg, keyPlaceOlderPos, dataPlaceOlderPos, useRateLimiter, rateLimiter)
203+
go ingestionRoutine(standalone, *multi, datapointsChan, true, cmd, *keyspacelen, *datasize, samplesPerClient, *loop, int(*debug), &wg, keyPlaceOlderPos, dataPlaceOlderPos, useRateLimiter, rateLimiter)
204204
}
205205
}
206206
}
@@ -210,7 +210,7 @@ func main() {
210210
signal.Notify(c, os.Interrupt)
211211

212212
tick := time.NewTicker(time.Duration(client_update_tick) * time.Second)
213-
closed, _, duration, totalMessages, _ := updateCLI(tick, c, *numberRequests, *loop)
213+
closed, _, duration, totalMessages, _ := updateCLI(tick, c, *numberRequests, *loop, datapointsChan)
214214
messageRate := float64(totalMessages) / float64(duration.Seconds())
215215
p50IngestionMs := float64(latencies.ValueAtQuantile(50.0)) / 1000.0
216216
p95IngestionMs := float64(latencies.ValueAtQuantile(95.0)) / 1000.0
@@ -235,17 +235,31 @@ func main() {
235235
wg.Wait()
236236
}
237237

238-
func updateCLI(tick *time.Ticker, c chan os.Signal, message_limit uint64, loop bool) (bool, time.Time, time.Duration, uint64, []float64) {
239-
238+
func updateCLI(tick *time.Ticker, c chan os.Signal, message_limit uint64, loop bool, datapointsChan chan datapoint) (bool, time.Time, time.Duration, uint64, []float64) {
239+
var currentErr uint64 = 0
240+
var currentCount uint64 = 0
240241
start := time.Now()
241242
prevTime := time.Now()
242243
prevMessageCount := uint64(0)
243244
messageRateTs := []float64{}
245+
var dp datapoint
244246
fmt.Printf("%26s %7s %25s %25s %7s %25s %25s\n", "Test time", " ", "Total Commands", "Total Errors", "", "Command Rate", "p50 lat. (msec)")
245247
for {
246248
select {
249+
case dp = <-datapointsChan:
250+
{
251+
latencies.RecordValue(dp.duration_ms)
252+
if !dp.success {
253+
currentErr++
254+
}
255+
currentCount++
256+
}
247257
case <-tick.C:
248258
{
259+
totalCommands += currentCount
260+
totalErrors += currentErr
261+
currentErr = 0
262+
currentCount = 0
249263
now := time.Now()
250264
took := now.Sub(prevTime)
251265
messageRate := float64(totalCommands-prevMessageCount) / float64(took.Seconds())

0 commit comments

Comments
 (0)