Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

[Join] InitHashTable optimisation #663

Merged
merged 1 commit into from
Sep 19, 2023
Merged

Conversation

Devjiu
Copy link
Contributor

@Devjiu Devjiu commented Sep 11, 2023

This commit reworks fill_hash_join_buff_bucketized_cpu to use tbb and utilize cpu properly.

Partially resolves: #574

@Devjiu Devjiu force-pushed the dmitriim/init_hash_table_cpu_opt branch from 164d7d5 to c6c7e7a Compare September 11, 2023 13:20
@@ -146,8 +146,8 @@ JoinColumn ColumnFetcher::makeJoinColumn(
data_provider,
column_cache);
if (col_buff != nullptr) {
join_chunk_array[num_chunks] = JoinChunk{col_buff, elem_count, num_elems};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we force to initialize all fields with constructor?

@Devjiu Devjiu force-pushed the dmitriim/init_hash_table_cpu_opt branch 2 times, most recently from 74c47ff to ac76362 Compare September 13, 2023 11:58
@Devjiu Devjiu marked this pull request as ready for review September 13, 2023 12:52
Copy link
Contributor

@ienkovich ienkovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch looks good! There are a few minors to fix though.

@@ -34,6 +34,7 @@
#include "../../DecodersImpl.h"
#else
#include "../../RuntimeFunctions.h"
#include "HashJoinRuntimeCpu.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header doesn't seem to be used in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

namespace {

template <ColumnType T>
inline int64_t getElem(const int8_t* chunk_mem_ptr, size_t elem_size, size_t elem_ind) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You better get an error on compile time rather than runtime by using

template <ColumnType T>
inline int64_t getElem(const int8_t* chunk_mem_ptr, size_t elem_size, size_t elem_ind) = delete;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, done

@@ -0,0 +1,261 @@
#include "HashJoinRuntimeCpu.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The license header is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,71 @@
#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The license header is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


#include "../../../Shared/sqltypes.h"

namespace cpu_utils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace name is too common and kind of misleading. I'd say we don't use any namespace here at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed namespace

const int64_t max_elem,
const void* sd_inner_proxy,
const void* sd_outer_proxy) {
CHECK(sd_outer_proxy);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECK macro is not defined in this header, so header usage becomes dependent on headers including order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const auto sd_inner_dict_proxy =
static_cast<const StringDictionaryProxy*>(sd_inner_proxy);
const auto sd_outer_dict_proxy =
static_cast<const StringDictionaryProxy*>(sd_outer_proxy);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringDictionaryProxy class is not declared in this header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const auto elem_str = sd_inner_dict_proxy->getString(elem);
const auto outer_id = sd_outer_dict_proxy->getIdOfString(elem_str);
if (outer_id > max_elem || outer_id < min_elem) {
return StringDictionary::INVALID_STR_ID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another reference to undeclared class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Devjiu Devjiu force-pushed the dmitriim/init_hash_table_cpu_opt branch 2 times, most recently from 2c10582 to aca3b31 Compare September 18, 2023 12:43
This commit reworks `fill_hash_join_buff_bucketized_cpu` to use tbb and
utilize cpu properly.

Partially resolves: #574

Signed-off-by: Dmitrii Makarenko <[email protected]>
@Devjiu Devjiu force-pushed the dmitriim/init_hash_table_cpu_opt branch from aca3b31 to 3c9ee01 Compare September 18, 2023 12:46
@Devjiu Devjiu merged commit 6cb14ee into main Sep 19, 2023
@Devjiu Devjiu deleted the dmitriim/init_hash_table_cpu_opt branch September 19, 2023 15:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Perf][Bench] Join is slow on big tables.
2 participants