-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not check schema compatibility for same hashed schemas
To speedup inserts commit_hash:b2de3895cbe08fa9087e3893ce9c5a5ad280afa0
- Loading branch information
1 parent
716aef6
commit e646c61
Showing
7 changed files
with
252 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
pkg/providers/yt/sink/bechmarks/sorted_table_bench_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
package bechmarks | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/doublecloud/transfer/internal/logger" | ||
"github.com/doublecloud/transfer/internal/metrics" | ||
"github.com/doublecloud/transfer/library/go/core/xerrors" | ||
"github.com/doublecloud/transfer/pkg/abstract" | ||
client2 "github.com/doublecloud/transfer/pkg/abstract/coordinator" | ||
yt2 "github.com/doublecloud/transfer/pkg/providers/yt" | ||
"github.com/doublecloud/transfer/pkg/providers/yt/sink" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zapcore" | ||
"go.ytsaurus.tech/yt/go/schema" | ||
"go.ytsaurus.tech/yt/go/ypath" | ||
"go.ytsaurus.tech/yt/go/yt" | ||
) | ||
|
||
type overrideable interface { | ||
OverrideClient(client yt.Client) | ||
} | ||
|
||
type fakeYTTX struct { | ||
yt.TabletTx | ||
} | ||
|
||
func (fakeYTTX) InsertRows( | ||
ctx context.Context, | ||
path ypath.Path, | ||
rows []any, | ||
options *yt.InsertRowsOptions, | ||
) (err error) { | ||
return nil | ||
} | ||
|
||
func (fakeYTTX) Abort() error { | ||
return nil | ||
} | ||
|
||
func (fakeYTTX) Commit() error { | ||
return nil | ||
} | ||
|
||
type fakeYT struct { | ||
yt.Client | ||
cols []schema.Column | ||
} | ||
|
||
func (fakeYT) NodeExists( | ||
ctx context.Context, | ||
path ypath.YPath, | ||
options *yt.NodeExistsOptions, | ||
) (ok bool, err error) { | ||
return true, nil | ||
} | ||
|
||
func (fakeYT) BeginTabletTx(ctx context.Context, options *yt.StartTabletTxOptions) (tx yt.TabletTx, err error) { | ||
return &fakeYTTX{}, nil | ||
} | ||
|
||
func (f fakeYT) GetNode( | ||
ctx context.Context, | ||
path ypath.YPath, | ||
result any, | ||
options *yt.GetNodeOptions, | ||
) (err error) { | ||
resPtr, ok := result.(*struct { | ||
Schema schema.Schema `yson:"schema"` | ||
TabletState string `yson:"expected_tablet_state"` | ||
}) | ||
if !ok { | ||
return xerrors.Errorf("result must be a pointer to the expected struct") | ||
} | ||
|
||
resPtr.TabletState = yt.TabletMounted | ||
resPtr.Schema = schema.Schema{ | ||
Strict: aws.Bool(true), | ||
UniqueKeys: true, | ||
Columns: f.cols, | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func BenchmarkSinkWrite(b *testing.B) { | ||
scenario := func(b *testing.B, table abstract.Sinker, size int, ci abstract.ChangeItem) { | ||
var data []abstract.ChangeItem | ||
for range size { | ||
data = append(data, ci) | ||
} | ||
err := table.Push(data) | ||
b.SetBytes(int64(ci.Size.Values) * int64(size)) | ||
require.NoError(b, err) | ||
} | ||
|
||
b.Run("simple", func(b *testing.B) { | ||
schema_ := abstract.NewTableSchema([]abstract.ColSchema{ | ||
{ | ||
DataType: "double", | ||
ColumnName: "test", | ||
PrimaryKey: true, | ||
}, | ||
{ | ||
DataType: "datetime", | ||
ColumnName: "_timestamp", | ||
PrimaryKey: true, | ||
}, | ||
}) | ||
row := abstract.ChangeItem{ | ||
TableSchema: schema_, | ||
Table: "test", | ||
Kind: "insert", | ||
ColumnNames: []string{"test", "_timestamp"}, | ||
ColumnValues: []interface{}{3.99, time.Now()}, | ||
} | ||
b.Run("dt_hack", func(b *testing.B) { | ||
cfg := yt2.NewYtDestinationV1(yt2.YtDestination{ | ||
CellBundle: "default", | ||
PrimaryMedium: "default", | ||
DisableDatetimeHack: false, | ||
CanAlter: true, | ||
}) | ||
cfg.WithDefaults() | ||
table, err := sink.NewSinker(cfg, "some_uniq_transfer_id", 0, logger.LoggerWithLevel(zapcore.WarnLevel), metrics.NewRegistry(), client2.NewFakeClient(), nil) | ||
require.NoError(b, err) | ||
if o, ok := table.(overrideable); ok { | ||
o.OverrideClient(&fakeYT{cols: []schema.Column{{ | ||
Name: "test", | ||
Type: "double", | ||
SortOrder: "ascending", | ||
}, { | ||
Name: "_timestamp", | ||
Type: "int64", | ||
SortOrder: "ascending", | ||
}, { | ||
Name: "__dummy", | ||
Type: "any", | ||
}}}) | ||
} | ||
b.Run("10_000", func(b *testing.B) { | ||
b.ResetTimer() | ||
for n := 0; n < b.N; n++ { | ||
scenario(b, table, 10_000, row) | ||
} | ||
b.ReportAllocs() | ||
}) | ||
}) | ||
b.Run("no_dt_hack", func(b *testing.B) { | ||
cfg := yt2.NewYtDestinationV1(yt2.YtDestination{ | ||
CellBundle: "default", | ||
PrimaryMedium: "default", | ||
DisableDatetimeHack: true, | ||
CanAlter: true, | ||
}) | ||
cfg.WithDefaults() | ||
table, err := sink.NewSinker(cfg, "some_uniq_transfer_id", 0, logger.LoggerWithLevel(zapcore.WarnLevel), metrics.NewRegistry(), client2.NewFakeClient(), nil) | ||
require.NoError(b, err) | ||
if o, ok := table.(overrideable); ok { | ||
o.OverrideClient(&fakeYT{cols: []schema.Column{{ | ||
Name: "test", | ||
Type: "double", | ||
SortOrder: "ascending", | ||
}, { | ||
Name: "_timestamp", | ||
Type: "datetime", | ||
SortOrder: "ascending", | ||
}, { | ||
Name: "__dummy", | ||
Type: "any", | ||
}}}) | ||
} | ||
b.Run("10_000", func(b *testing.B) { | ||
b.ResetTimer() | ||
for n := 0; n < b.N; n++ { | ||
scenario(b, table, 10_000, row) | ||
} | ||
b.ReportAllocs() | ||
}) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters