Skip to content

Commit

Permalink
chore: use writev by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Aug 11, 2024
1 parent 07e382f commit 2b53bde
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
8 changes: 1 addition & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,6 @@ type Options struct {
ProtocolVersion int // force protocol version, optional
HandshakeTimeout time.Duration // longer lasting handshake is a case for ClickHouse cloud idle instances, defaults to 5m

// UseWritev whether to use `writev` syscall to write data.
//
// May significantly reduce memory footprint for bulk inserts of uncompressed data.
UseWritev bool

// Additional OpenTelemetry instrumentation that will capture query body
// and other parameters.
//
Expand Down Expand Up @@ -507,8 +502,7 @@ func Connect(ctx context.Context, conn net.Conn, opt Options) (*Client, error) {
c.compression = proto.CompressionDisabled
}
if _, ok := conn.(*net.TCPConn); writevAvailable && // writev available only on Unix platforms.
ok && c.compression == proto.CompressionDisabled && // Could not be used with TLS and compression.
opt.UseWritev { // Requires explicit user option.
ok && c.compression == proto.CompressionDisabled { // Could not be used with TLS and compression.
c.useWritev = true
c.vec = make(net.Buffers, 0, 16)
}
Expand Down
2 changes: 0 additions & 2 deletions insert_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch
import (
"context"
"fmt"
"os"
"testing"

"github.com/go-faster/errors"
Expand All @@ -22,7 +21,6 @@ func BenchmarkInsert(b *testing.B) {
c, err := Dial(ctx, Options{
Address: srv.TCP,
Compression: CompressionDisabled,
UseWritev: os.Getenv("CH_BENCH_USE_WRITEV") == "true",
})
if err != nil {
b.Fatal(errors.Wrap(err, "dial"))
Expand Down

0 comments on commit 2b53bde

Please sign in to comment.