Skip to content

Commit

Permalink
sn: use ordered map to manage executors (#477)
Browse files Browse the repository at this point in the history
StorageNode manages its LogStreamExecutors in order by LogStreamID. It
helps StorageNode to send reports in order by LogStreamID.

This patch contains executorsMap as an ordered map for executors.

Benchmark:

```
goos: darwin
goarch: amd64
pkg: github.daumkakao.com/varlog/varlog/internal/storagenode/executorsmap
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkExecutorsMapRange
BenchmarkExecutorsMapRange/stdmap_store
BenchmarkExecutorsMapRange/stdmap_store-16               5689405               234.8 ns/op            73 B/op          0 allocs/op
BenchmarkExecutorsMapRange/ordmap_store
BenchmarkExecutorsMapRange/ordmap_store-16               3167251               423.1 ns/op           222 B/op          0 allocs/op
BenchmarkExecutorsMapRange/stdmap_load
BenchmarkExecutorsMapRange/stdmap_load-16               29595160                40.34 ns/op            0 B/op          0 allocs/op
BenchmarkExecutorsMapRange/ordmap_load
BenchmarkExecutorsMapRange/ordmap_load-16               26325957                42.60 ns/op            0 B/op          0 allocs/op
BenchmarkExecutorsMapRange/stdmap_range
BenchmarkExecutorsMapRange/stdmap_range-16                  1146           1017351 ns/op               0 B/op          0 allocs/op
BenchmarkExecutorsMapRange/ordmap_range
BenchmarkExecutorsMapRange/ordmap_range-16                  3063            347647 ns/op               0 B/op          0 allocs/op
PASS
ok      github.daumkakao.com/varlog/varlog/internal/storagenode/executorsmap    10.485s
```

Resolves [#VARLOG-544](https://jira.daumkakao.com/browse/VARLOG-544).
  • Loading branch information
ijsong authored and GitHub Enterprise committed Jul 23, 2021
1 parent 5902ef7 commit daf9e8a
Show file tree
Hide file tree
Showing 8 changed files with 818 additions and 39 deletions.
2 changes: 2 additions & 0 deletions internal/storagenode/executor/executor.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package executor

//go:generate mockgen -build_flags -mod=vendor -self_package github.daumkakao.com/varlog/varlog/internal/storagenode/executor -package executor -destination executor_mock.go . Executor

import (
"context"
"io"
Expand Down
279 changes: 253 additions & 26 deletions internal/storagenode/executor/executor_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/storagenode/executor/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.daumkakao.com/varlog/varlog/internal/storagenode/telemetry"
)

//go:generate mockgen -build_flags -mod=vendor -self_package github.daumkakao.com/varlog/varlog/internal/storagenode/executor -package executor -destination executor_mock.go . MeasurableExecutor
//go:generate mockgen -build_flags -mod=vendor -self_package github.daumkakao.com/varlog/varlog/internal/storagenode/executor -package executor -destination telemetry_mock.go . MeasurableExecutor

type MeasurableExecutor interface {
telemetry.Measurable
Expand Down
Loading

0 comments on commit daf9e8a

Please sign in to comment.