-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from tdakkota/perf/use-writev
feat(ch): use `writev` when possible
- Loading branch information
Showing
135 changed files
with
1,147 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package ch | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/go-faster/errors" | ||
|
||
"github.com/ClickHouse/ch-go/cht" | ||
"github.com/ClickHouse/ch-go/proto" | ||
) | ||
|
||
func BenchmarkInsert(b *testing.B) { | ||
cht.Skip(b) | ||
srv := cht.New(b) | ||
|
||
bench := func(rows int) func(b *testing.B) { | ||
return func(b *testing.B) { | ||
ctx := context.Background() | ||
c, err := Dial(ctx, Options{ | ||
Address: srv.TCP, | ||
Compression: CompressionDisabled, | ||
}) | ||
if err != nil { | ||
b.Fatal(errors.Wrap(err, "dial")) | ||
} | ||
defer func() { _ = c.Close() }() | ||
|
||
if err := c.Do(ctx, Query{ | ||
Body: "CREATE TABLE IF NOT EXISTS test_table (id Int64) ENGINE = Null", | ||
}); err != nil { | ||
b.Fatal(err) | ||
} | ||
|
||
var id proto.ColInt64 | ||
for i := 0; i < rows; i++ { | ||
id = append(id, 1) | ||
} | ||
|
||
b.SetBytes(int64(rows) * 8) | ||
b.ResetTimer() | ||
b.ReportAllocs() | ||
|
||
for i := 0; i < b.N; i++ { | ||
if err := c.Do(ctx, Query{ | ||
Body: "INSERT INTO test_table VALUES", | ||
Input: []proto.InputColumn{ | ||
{Name: "id", Data: id}, | ||
}, | ||
}); err != nil { | ||
b.Fatal() | ||
} | ||
} | ||
} | ||
} | ||
for _, rows := range []int{ | ||
10_000, | ||
100_000, | ||
1_000_000, | ||
10_000_000, | ||
100_000_000, | ||
} { | ||
b.Run(fmt.Sprintf("Rows%d", rows), bench(rows)) | ||
} | ||
} |
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.