Skip to content

ColumnString improve performance(26%) by avoiding vector reallocate #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2022
Merged

ColumnString improve performance(26%) by avoiding vector reallocate #249

merged 2 commits into from
Nov 23, 2022

Conversation

1261385937
Copy link
Contributor

@1261385937 1261385937 commented Nov 19, 2022

By estimating the total element count, code like this:

constexpr size_t total = 100000;
for (int i = 0; i < 10; i++) {
    clickhouse::Block block;
    auto a_ptr = std::make_shared<clickhouse::ColumnInt32>();
    auto b_ptr = std::make_shared<clickhouse::ColumnUInt64>();
    auto c_ptr = std::make_shared<clickhouse::ColumnString>(total);
    auto d_ptr = std::make_shared<clickhouse::ColumnArray>(std::make_shared<clickhouse::ColumnString>(total * 3));
    auto e_ptr = std::make_shared<clickhouse::ColumnArray>(
                         std::make_shared<clickhouse::ColumnArray>(
                         std::make_shared<clickhouse::ColumnString>(total * 3 * 4)));
...

Before estimating, total time(18720), network time(7353), other time(18720-7353=11367), top hot:

6ebcdc78d97e6d82d517696842bcf0d

After estimating, total time(15728), network time(7317) same as above(7353), other time(15728-7317=8411), top hot:

5461431e29c7ec072527b01c980033b

improve performance: (11367-8411)/11367 = 26%

1261385937 and others added 2 commits November 19, 2022 21:06
- `ColumnString` c-tor: assuming that there are about ~100 rows in each `ColumnString::Block`, rather than 2.
- `ColumnString::Slice`: only reserving for exact number of elements in `items_`.
- `ColumnString::Append` less code duplication
- minor style fixes
@Enmk Enmk merged commit 4a186a8 into ClickHouse:master Nov 23, 2022
@1261385937 1261385937 deleted the performance_improve branch November 23, 2022 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants