Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/docker/alpine-3.18.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin authored Oct 4, 2023
2 parents 363e393 + 9e0d021 commit f6bf7fd
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ updates:
groups:
otel:
patterns:
- "^go.opentelemetry.io/otel*"
- "go.opentelemetry.io/otel*"
- package-ecosystem: docker
directory: "/"
schedule:
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tendermint/tendermint v0.34.28
go.opentelemetry.io/contrib/instrumentation/runtime v0.44.0
go.opentelemetry.io/otel v1.18.0
go.opentelemetry.io/otel v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.41.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.18.0
go.opentelemetry.io/otel/metric v1.18.0
go.opentelemetry.io/otel/sdk v1.18.0
go.opentelemetry.io/otel/metric v1.19.0
go.opentelemetry.io/otel/sdk v1.19.0
go.opentelemetry.io/otel/sdk/metric v0.41.0
go.opentelemetry.io/otel/trace v1.18.0
go.opentelemetry.io/otel/trace v1.19.0
go.opentelemetry.io/proto/otlp v1.0.0
go.uber.org/fx v1.20.0
go.uber.org/zap v1.26.0
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2382,33 +2382,33 @@ go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzox
go.opentelemetry.io/otel v1.4.1/go.mod h1:StM6F/0fSwpd8dKWDCdRr7uRvEPYdW0hBSlbdTiUde4=
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
go.opentelemetry.io/otel v1.13.0/go.mod h1:FH3RtdZCzRkJYFTCsAKDy9l/XYjMdNv6QrkFFB8DvVg=
go.opentelemetry.io/otel v1.18.0 h1:TgVozPGZ01nHyDZxK5WGPFB9QexeTMXEH7+tIClWfzs=
go.opentelemetry.io/otel v1.18.0/go.mod h1:9lWqYO0Db579XzVuCKFNPDl4s73Voa+zEck3wHaAYQI=
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.41.0 h1:k0k7hFNDd8K4iOMJXj7s8sHaC4mhTlAeppRmZXLgZ6k=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.41.0/go.mod h1:hG4Fj/y8TR/tlEDREo8tWstl9fO9gcFkn4xrx0Io8xU=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.41.0 h1:iV3BOgW4fry1Riw9dwypigqlIYWXvSRVT2RJmblzo40=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.41.0/go.mod h1:7PGzqlKrxIRmbj5tlNW0nTkYZ5fHXDgk6Fy8/KjR0CI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0 h1:IAtl+7gua134xcV3NieDhJHjjOVeJhXAnYf/0hswjUY=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0/go.mod h1:w+pXobnBzh95MNIkeIuAKcHe/Uu/CX2PKIvBP6ipKRA=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.18.0 h1:6pu8ttx76BxHf+xz/H77AUZkPF3cwWzXqAUsXhVKI18=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.18.0/go.mod h1:IOmXxPrxoxFMXdNy7lfDmE8MzE61YPcurbUm0SMjerI=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.1 h1:2PunuO5SbkN5MhCbuHCd3tC6qrcaj+uDAkX/qBU5BAs=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.1/go.mod h1:q8+Tha+5LThjeSU8BW93uUC5w5/+DnYHMKBMpRCsui0=
go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU=
go.opentelemetry.io/otel/metric v1.18.0 h1:JwVzw94UYmbx3ej++CwLUQZxEODDj/pOuTCvzhtRrSQ=
go.opentelemetry.io/otel/metric v1.18.0/go.mod h1:nNSpsVDjWGfb7chbRLUNW+PBNdcSTHD4Uu5pfFMOI0k=
go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8=
go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw=
go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc=
go.opentelemetry.io/otel/sdk v1.18.0 h1:e3bAB0wB3MljH38sHzpV/qWrOTCFrdZF2ct9F8rBkcY=
go.opentelemetry.io/otel/sdk v1.18.0/go.mod h1:1RCygWV7plY2KmdskZEDDBs4tJeHG92MdHZIluiYs/M=
go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A=
go.opentelemetry.io/otel/sdk/metric v0.41.0 h1:c3sAt9/pQ5fSIUfl0gPtClV3HhE18DCVzByD33R/zsk=
go.opentelemetry.io/otel/sdk/metric v0.41.0/go.mod h1:PmOmSt+iOklKtIg5O4Vz9H/ttcRFSNTgii+E1KGyn1w=
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
go.opentelemetry.io/otel/trace v1.4.1/go.mod h1:iYEVbroFCNut9QkwEczV9vMRPHNKSSwYZjulEtsmhFc=
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
go.opentelemetry.io/otel/trace v1.13.0/go.mod h1:muCvmmO9KKpvuXSf3KKAXXB2ygNYHQ+ZfI5X08d3tds=
go.opentelemetry.io/otel/trace v1.18.0 h1:NY+czwbHbmndxojTEKiSMHkG2ClNH2PwmcHrdo0JY10=
go.opentelemetry.io/otel/trace v1.18.0/go.mod h1:T2+SGJGuYZY3bjj5rgh/hN7KIrlpWC5nS8Mjvzckz+0=
go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
Expand Down
58 changes: 58 additions & 0 deletions share/eds/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import (
"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-app/pkg/da"
dsbadger "github.com/celestiaorg/go-ds-badger4"
"github.com/celestiaorg/rsmt2d"

"github.com/celestiaorg/celestia-node/share"
"github.com/celestiaorg/celestia-node/share/eds/cache"
"github.com/celestiaorg/celestia-node/share/eds/edstest"
"github.com/celestiaorg/celestia-node/share/ipld"
)

func TestEDSStore(t *testing.T) {
Expand Down Expand Up @@ -465,6 +467,62 @@ func BenchmarkStore(b *testing.B) {
})
}

// BenchmarkCacheEviction benchmarks the time it takes to load a block to the cache, when the
// cache size is set to 1. This forces cache eviction on every read.
// BenchmarkCacheEviction-10/128 384 3533586 ns/op (~3ms)
func BenchmarkCacheEviction(b *testing.B) {
const (
blocks = 4
size = 128
)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
b.Cleanup(cancel)

dir := b.TempDir()
ds, err := dsbadger.NewDatastore(dir, &dsbadger.DefaultOptions)
require.NoError(b, err)

newStore := func(params *Parameters) *Store {
edsStore, err := NewStore(params, dir, ds)
require.NoError(b, err)
err = edsStore.Start(ctx)
require.NoError(b, err)
return edsStore
}
edsStore := newStore(DefaultParameters())

// generate EDSs and store them
cids := make([]cid.Cid, blocks)
for i := range cids {
eds := edstest.RandEDS(b, size)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(b, err)
err = edsStore.Put(ctx, dah.Hash(), eds)
require.NoError(b, err)

// store cids for read loop later
cids[i] = ipld.MustCidFromNamespacedSha256(dah.RowRoots[0])
}

// restart store to clear cache
require.NoError(b, edsStore.Stop(ctx))

// set BlockstoreCacheSize to 1 to force eviction on every read
params := DefaultParameters()
params.BlockstoreCacheSize = 1
bstore := newStore(params).Blockstore()

// start benchmark
b.ResetTimer()
for i := 0; i < b.N; i++ {
h := cids[i%blocks]
// every read will trigger eviction
_, err := bstore.Get(ctx, h)
require.NoError(b, err)
}
}

func newStore(t *testing.T) (*Store, error) {
t.Helper()

Expand Down
71 changes: 71 additions & 0 deletions share/getters/getter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package getters
import (
"context"
"os"
"sync"
"testing"
"time"

Expand All @@ -12,7 +13,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-app/pkg/da"
"github.com/celestiaorg/celestia-app/pkg/wrapper"
dsbadger "github.com/celestiaorg/go-ds-badger4"
"github.com/celestiaorg/rsmt2d"

"github.com/celestiaorg/celestia-node/share"
Expand Down Expand Up @@ -217,6 +220,74 @@ func TestIPLDGetter(t *testing.T) {
})
}

// BenchmarkIPLDGetterOverBusyCache benchmarks the performance of the IPLDGetter when the
// cache size of the underlying blockstore is less than the number of blocks being requested in
// parallel. This is to ensure performance doesn't degrade when the cache is being frequently
// evicted.
// BenchmarkIPLDGetterOverBusyCache-10/128 1 12460428417 ns/op (~12s)
func BenchmarkIPLDGetterOverBusyCache(b *testing.B) {
const (
blocks = 10
size = 128
)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
b.Cleanup(cancel)

dir := b.TempDir()
ds, err := dsbadger.NewDatastore(dir, &dsbadger.DefaultOptions)
require.NoError(b, err)

newStore := func(params *eds.Parameters) *eds.Store {
edsStore, err := eds.NewStore(params, dir, ds)
require.NoError(b, err)
err = edsStore.Start(ctx)
require.NoError(b, err)
return edsStore
}
edsStore := newStore(eds.DefaultParameters())

// generate EDSs and store them
hashes := make([]da.DataAvailabilityHeader, blocks)
for i := range hashes {
eds := edstest.RandEDS(b, size)
dah, err := da.NewDataAvailabilityHeader(eds)
require.NoError(b, err)
err = edsStore.Put(ctx, dah.Hash(), eds)
require.NoError(b, err)

// store cids for read loop later
hashes[i] = dah
}

// restart store to clear cache
require.NoError(b, edsStore.Stop(ctx))

// set BlockstoreCacheSize to 1 to force eviction on every read
params := eds.DefaultParameters()
params.BlockstoreCacheSize = 1
edsStore = newStore(params)
bstore := edsStore.Blockstore()
bserv := ipld.NewBlockservice(bstore, offline.Exchange(bstore))

// start client
getter := NewIPLDGetter(bserv)

// request blocks in parallel
b.ResetTimer()
g := sync.WaitGroup{}
g.Add(blocks)
for _, h := range hashes {
h := h
go func() {
defer g.Done()
_, err := getter.GetEDS(ctx, &h)
require.NoError(b, err)
}()
}
g.Wait()
}

func randomEDS(t *testing.T) (*rsmt2d.ExtendedDataSquare, *share.Root) {
eds := edstest.RandEDS(t, 4)
dah, err := share.NewRoot(eds)
Expand Down

0 comments on commit f6bf7fd

Please sign in to comment.