Skip to content

Commit

Permalink
feat(insert): increase max size of frames
Browse files Browse the repository at this point in the history
Relates to #130
  • Loading branch information
loyd committed Aug 18, 2024
1 parent 3c6a6a9 commit 1d63a7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- next-header -->

## [Unreleased] - ReleaseDate
### Changed
- insert: increase max size of frames to improve throughput ([#130]).

[#130]: https://github.com/ClickHouse/clickhouse-rs/issues/130

## [0.12.1] - 2024-08-07
### Added
Expand Down
10 changes: 8 additions & 2 deletions src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bytes::{Bytes, BytesMut};
use hyper::{self, Request};
use replace_with::replace_with_or_abort;
use serde::Serialize;
use static_assertions::const_assert;
use tokio::{
task::JoinHandle,
time::{Instant, Sleep},
Expand All @@ -18,8 +19,13 @@ use crate::{
rowbinary, Client, Compression,
};

const BUFFER_SIZE: usize = 128 * 1024;
const MIN_CHUNK_SIZE: usize = BUFFER_SIZE - 1024; // slightly less to avoid extra reallocations
// The desired max frame size.
const BUFFER_SIZE: usize = 256 * 1024;
// Threshold to send a chunk. Should be slightly less than `BUFFER_SIZE`
// to avoid extra reallocations in case of a big last row.
const MIN_CHUNK_SIZE: usize = BUFFER_SIZE - 2048;

const_assert!(BUFFER_SIZE.is_power_of_two()); // to use the whole buffer's capacity

/// Performs one `INSERT`.
///
Expand Down

0 comments on commit 1d63a7d

Please sign in to comment.