Commit Graph

105280 Commits

Author SHA1 Message Date
Azat Khuzhin
925fd2c33a tests/performance: do not use scientific notation in hashed_dictionary_sharded
v2: fix few mistakes
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:26 +01:00
Azat Khuzhin
a3f189e191 Optimize sharded dictionaries with skewed distribution
In case of skewed distribution simple division by module will not give
you good distribution between shards and eventually this can lead to
performance the same as non-sharded dictionary (except for it will
occupy +1 thread for Block::scatter).

But if HashedDictionary::blockToAttributes() will not have calls to
HashedDictionary::getShard() this can be fixed by using a more complex
key-to-shard (getShard()) mapping. And actually you do not need to call
getShard() in blockToAttributes() you can simply use passed shard, and
that's it.

And by wrapping key with intHash64() in getShard() skewed distribution
can be fixed.

Note, that previously I tried similar approach but did not removed
getShard() from blockToAttributes(), that's why it failed.

And now it works almost as fast as with simple createBlockSelector(),
just 13.6% slower (18.75min vs 16.5min, with 16 threads).

Note, that I've also tried to add libdivide for this, but it does not
improves the performance.

I've also tried the approach without scatter, and it works 20% slower
then this one (22.5min VS 18.75min, with 16 threads).

v2: Use intHashCRC32() over intHash64() for HashedDictionary::getShard()
    (with intHash64() it works very slower, almost 2x slower, there was
    18min with 32 threads)

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:26 +01:00
Azat Khuzhin
655a564280 Parallel hash tables destroy for hashed dictionaries
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:26 +01:00
Azat Khuzhin
99063b152f Allow to configure queue backlog of the parallel hashed dictionary loader
v2: Decrease default parallel_queue_backlog to 10000 (same speed)
v3: Rename parallel_queue_backlog to per_shard_load_backlog
v3: Rename per_shard_load_backlog to shard_load_queue_backlog
v4: Fix documentation
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:26 +01:00
Azat Khuzhin
79ad81dfdf Implement separate queue for parallel loader of hashed dictionaries
Previous patches in this series has a bottleneck in rehash(). This is
the most slowest operation when insert lots of rows into the hashtable
and eventually all that thread pool sometimes work as the most slowest
thread since we did not have any queue of blocks.

This patch adds such queue and now it scales linearly, so initialy with
1 thread I had ~4 hours for 10e9 elements (UInt64 key, UInt16 value),
after this patch it works in 16 minutes with 16 threads (well actually I
have to use 32 threads because of distribution of data in the source
table).

And now with 16 threads it works 16 times faster.

Also this patch adds more optimal block splitting for the non-complex
dictionaries, and usual block splitting for complex dictionaries.
But anyway this moves the overhead from the loading into the hashtable
threads out to the reader thread, and this is better, since reader does
not uses that much CPU.

v2: fix use-after-free on failed load (add missing wait in dtor)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:26 +01:00
Azat Khuzhin
5d0fd3cdc4 Remove sharded overhead for non-sharded hashed dictionaries
By adding one more template parameter - HashedDictionary<sharded> (yes,
it is already too much of them, for the template class that has explicit
instantion).

Since perf tests [1] shows 20% slowdown.

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/40003/8f0cf2d6b8a7df511afe901331d5e2c7b06c0b4d/performance_comparison_[1/4]/report.html

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:26 +01:00
Azat Khuzhin
345c422e28 Add ability to load hashed dictionaries using multiple threads
Right now dictionaries (here I will talk about only
HASHED/SPARSE_HASHED/COMPLEX_KEY_HASHED/COMPLEX_KEY_SPARSE_HASHED)
can load data only in one thread, since it uses one hash table that
cannot be filled from multiple threads.

And in case you have very big dictionary (i.e. 10e9 elements), it can
take a awhile to load them, especially for SPARSE_HASHED variants (and
if you have such amount of elements there, you are likely use
SPARSE_HASHED, since it requires less memory), in my env it takes ~4
hours, which is enormous amount of time.

So this patch add support of shards for dictionaries, number of shards
determine how much hash tables will use this dictionary, also, and which
is more important, how much threads it can use to load the data.

And with 16 threads this works 2x faster, not perfect though, see the
follow up patches in this series.

v0: PARTITION BY
v1: SHARDS 1
v2: SHARDS(1)
v3: tried optimized mod - logical and, but it does not gain even 10%
v4: tried squashing more (max_block_size * shards), but it does not gain even 10% either
v5: move SHARDS into layout parameters (unknown simply ignored)
v6: tune params for perf tests (to avoid too long queries)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:25 +01:00
Azat Khuzhin
c43b1d0c41 tests: remove extra RELOAD from 01509_dictionary_preallocate
This will avoid extra messages on destroy:
- Destroying 1 non empty hash tables (using 1 threads)
- Hash tables destroyed

And actually we cannot wait them in tests, since the query does not
waits until the dictionary will be fully unloaded:

    $ pigz -cd clickhouse-server.log.gz.1 | grep 1511e339-a077-4ee7-808e-0211ece99409 -a
    2022.12.11 18:21:41.069825 [ 102234 ] {1511e339-a077-4ee7-808e-0211ece99409} <Debug> executeQuery: (from [::1]:58964) (comment: 01509_dictionary_preallocate.sh) SYSTEM RELOAD DICTIONARY dict_01509_preallocate (stage: Complete)
    ...
    2022.12.11 18:21:41.072887 [ 7291 ] {1511e339-a077-4ee7-808e-0211ece99409} <Trace> HashedDictionary: Preallocated 10000 elements
    ...
    2022.12.11 18:21:41.076531 [ 7291 ] {1511e339-a077-4ee7-808e-0211ece99409} <Trace> HashedDictionary: Destroying 1 non empty hash tables (using 1 threads)
    2022.12.11 18:21:41.076600 [ 102234 ] {1511e339-a077-4ee7-808e-0211ece99409} <Debug> MemoryTracker: Peak memory usage (for query): 3.05 MiB.
    2022.12.11 18:21:41.076618 [ 102234 ] {1511e339-a077-4ee7-808e-0211ece99409} <Debug> TCPHandler: Processed in 0.007111647 sec.
    2022.12.11 18:21:41.076697 [ 7291 ] {1511e339-a077-4ee7-808e-0211ece99409} <Trace> HashedDictionary: Hash tables destroyed

See, first the TCPHandler finished and only after HashedDictionary dtor.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-01-13 13:39:25 +01:00
Alexander Tokmakov
51d94314d6
Merge pull request #45235 from ClickHouse/more_verbose_logs_about_replication_log_entries
More verbose logs about replication log entries
2023-01-13 15:05:21 +03:00
Alexander Tokmakov
db91c4a749
Merge pull request #45168 from ClickHouse/tavplubix-patch-1
Try to fix flaky test_ttl_move_memory_usage
2023-01-13 15:01:42 +03:00
Maksim Kita
44f4184e11
Merge pull request #44540 from kitaisreal/analyzer-support-distributed
Analyzer support distributed queries processing
2023-01-13 14:45:36 +03:00
Vitaly Baranov
00908dcc6c
Fix http requests without path for AWS. (#45238) 2023-01-13 12:35:39 +01:00
Nikolai Kochetov
6e9dd2af45
Merge pull request #42889 from guowangy/logical-optimizer-lowcardinality
Enable logical optimizer for LowCardinality regardless of short chain
2023-01-13 12:28:57 +01:00
Robert Schulze
9779d034eb
Merge pull request #45144 from ClibMouse/crc-power-fix
Changes to support the CRC32 in PowerPC.
2023-01-13 11:24:18 +01:00
Alexander Gololobov
d850225f6b
Merge pull request #45229 from CurtizJ/fix-rare-logical-error
Fix rare logical error: `Too large alignment`
2023-01-13 09:48:28 +01:00
Alexey Milovidov
ab8c676ea5
Merge pull request #45013 from ClickHouse/download-script-failed
Supposedly fix the "Download script failed" error
2023-01-13 05:23:09 +03:00
Ilya Yatsishin
94e8c57d0d
Merge pull request #45094 from ClickHouse/try-fix-keeper-map
Try fixing KeeperMap tests
2023-01-13 00:46:43 +01:00
Ilya Yatsishin
ba05646dff
Merge pull request #45222 from ClickHouse/fuzz_prewhere
Fuzz PREWHERE clause
2023-01-13 00:45:21 +01:00
Ilya Yatsishin
2d3b578dd3
Merge pull request #45228 from ClickHouse/44976_Test_for_merge_join
Added a test for merge join key condition with big int & decimal
2023-01-13 00:44:14 +01:00
Raúl Marín
9f121d5d9c
Fix background_fetches_pool_size config reload (#45189) 2023-01-12 23:41:25 +01:00
Yakov Olkhovskiy
842a34666c
Merge pull request #44594 from arenadata/ADQM-634
Add keytab parameter in kerberos section of config.xml
2023-01-12 15:07:45 -05:00
Alexander Tokmakov
d9b8cf9c04 more verbose logs about replication log entries 2023-01-12 20:32:39 +01:00
Kruglov Pavel
f68ae31840
Merge pull request #45234 from ClickHouse/auto/v22.3.17.13-lts
Update version_date.tsv and changelogs after v22.3.17.13-lts
2023-01-12 20:24:32 +01:00
robot-clickhouse
82e73b583e Update version_date.tsv and changelogs after v22.3.17.13-lts 2023-01-12 19:22:22 +00:00
Nikolai Kochetov
30310df5be
Merge branch 'master' into logical-optimizer-lowcardinality 2023-01-12 18:51:05 +01:00
Nikolai Kochetov
e21fe952c6
Update test_ttl_move_memory_usage.py 2023-01-12 18:45:19 +01:00
Nikolai Kochetov
1911c25a7b
Merge branch 'master' into tavplubix-patch-1 2023-01-12 18:44:39 +01:00
MeenaRenganathan22
983cac0a64 Correcting the wrong commit for 01016_simhash_minhash.reference 2023-01-12 12:25:42 -05:00
Ilya Yatsishin
0be3dbad3c
Merge pull request #44883 from ClickHouse/ci-report-type
Rework CI reports to have a class and clarify the logic
2023-01-12 18:20:40 +01:00
MeenaRenganathan22
cb6eee6714 Introduced the new test file 01016_simhash_minhash_ppc.sql and modified the test file using Tags feature 2023-01-12 12:19:04 -05:00
Antonio Andelic
1f2ec534f4 Add EXISTS clauses 2023-01-12 15:39:04 +00:00
Maksim Kita
c6c17b9e3f Fixed tests 2023-01-12 16:33:00 +01:00
Antonio Andelic
dc4262f338 Merge branch 'master' into try-fix-keeper-map 2023-01-12 15:19:51 +00:00
Anton Popov
f119cdd5d8 fix rare logical error: 'Too large alignment' 2023-01-12 14:33:03 +00:00
Smita Kulkarni
72547d29e4 Added a test for merge join key condition with big int & decimal 02526_merge_join_int_decimal 2023-01-12 15:29:17 +01:00
Antonio Andelic
fb23a399b5
Merge pull request #45213 from ClickHouse/fix-flaky-keeper-test
Fix flaky `test_keeper_three_nodes_two_alive`
2023-01-12 14:57:40 +01:00
Sergei Trifonov
7a0c63c9c1
Merge pull request #44924 from ClickHouse/cancellable-mutex
Add fast and cancellable shared_mutex alternatives
2023-01-12 14:53:22 +01:00
Yakov Olkhovskiy
344fa16184
Merge pull request #42991 from ClickHouse/tests-connection-error
add retries on ConnectionError
2023-01-12 08:32:03 -05:00
Kseniia Sumarokova
db3e0219fc
Merge pull request #41687 from ClickHouse/40907_Parameterized_views_as_table_functions
40907 Parameterized views as table functions
2023-01-12 14:24:32 +01:00
Ilya Yatsishin
23c80d77a0
Merge pull request #45206 from ClickHouse/try-fix-overcommit-test
Disable check to make test_overcommit_tracker not flaky
2023-01-12 14:16:11 +01:00
Ilya Yatsishin
e2a42f0079
Merge pull request #45212 from ucasfl/minor
remove unused function
2023-01-12 14:12:06 +01:00
Alexander Gololobov
263a3f10c9 Also copy or move PREWHERE to WHERE 2023-01-12 14:11:30 +01:00
Alexander Tokmakov
4cbfd882c2
Merge pull request #45221 from ClickHouse/revert-44860-improve_week_day
Revert "update function DAYOFWEEK and add new function WEEKDAY for mysql/spark compatiability"
2023-01-12 15:17:50 +03:00
Alexander Gololobov
2a92ae8d8e Fuzz PREWHERE clause 2023-01-12 13:14:09 +01:00
Kseniia Sumarokova
d6289c3a0d
Merge pull request #45181 from kssenii/fix-heavy-calculation-in-system-detached-parts
Calculate only required columns in system.detached_parts
2023-01-12 13:02:56 +01:00
alesapin
df8ceeefdc
Merge pull request #45134 from ClickHouse/fix_flaky_azure_test
Fix flaky azure test
2023-01-12 13:02:34 +01:00
Alexander Tokmakov
e37f572c34
Revert "update function DAYOFWEEK and add new function WEEKDAY for mysql/spark compatiability" 2023-01-12 15:01:36 +03:00
alesapin
3245e822ef Update merge 2023-01-12 12:55:50 +01:00
Nikita Mikhaylov
62d544e742
Fix integration test test_replicated_users::test_rename_replicated (#45192)
* Done

* Update tests/integration/test_replicated_users/test.py

Co-authored-by: Sergei Trifonov <sergei@clickhouse.com>

Co-authored-by: Sergei Trifonov <sergei@clickhouse.com>
2023-01-12 12:36:36 +01:00
robot-clickhouse
d61e202416 Automatic style fix 2023-01-12 11:35:03 +00:00