forked from oceanbase/miniob
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unimplement pax storage and vectorized execution (oceanbase#425)
### What problem were solved in this pull request? Issue Number: close oceanbase#409 close oceanbase#410 close oceanbase#411 Problem: pax storage and vectorized execution. for vldb summer school 2024. ### What is changed and how it works? first we implement the pax storage, batch iterator, aggregator, group by and some simd functions , and then remove some key functions. We use unittest and some test cases to check players' code.
- Loading branch information
Showing
296 changed files
with
11,028 additions
and
3,490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. | ||
miniob is licensed under Mulan PSL v2. | ||
You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
You may obtain a copy of Mulan PSL v2 at: | ||
http://license.coscl.org.cn/MulanPSL2 | ||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
See the Mulan PSL v2 for more details. */ | ||
|
||
#include <benchmark/benchmark.h> | ||
|
||
#include "common/lang/memory.h" | ||
#include "common/lang/vector.h" | ||
#include "sql/expr/aggregate_hash_table.h" | ||
|
||
class AggregateHashTableBenchmark : public benchmark::Fixture | ||
{ | ||
public: | ||
void SetUp(const ::benchmark::State &state) override | ||
{ | ||
unique_ptr<Column> column1 = make_unique<Column>(AttrType::INTS, 4); | ||
unique_ptr<Column> column2 = make_unique<Column>(AttrType::INTS, 4); | ||
for (int i = 0; i < state.range(0); i++) { | ||
int key = i % 8; | ||
column1->append_one((char *)&key); | ||
column2->append_one((char *)&i); | ||
} | ||
group_chunk_.add_column(std::move(column1), 0); | ||
aggr_chunk_.add_column(std::move(column2), 0); | ||
} | ||
|
||
void TearDown(const ::benchmark::State &state) override | ||
{ | ||
group_chunk_.reset(); | ||
aggr_chunk_.reset(); | ||
} | ||
|
||
protected: | ||
Chunk group_chunk_; | ||
Chunk aggr_chunk_; | ||
}; | ||
|
||
class DISABLED_StandardAggregateHashTableBenchmark : public AggregateHashTableBenchmark | ||
{ | ||
public: | ||
void SetUp(const ::benchmark::State &state) override | ||
{ | ||
|
||
AggregateHashTableBenchmark::SetUp(state); | ||
AggregateExpr aggregate_expr(AggregateExpr::Type::SUM, nullptr); | ||
vector<Expression *> aggregate_exprs; | ||
aggregate_exprs.push_back(&aggregate_expr); | ||
standard_hash_table_ = make_unique<StandardAggregateHashTable>(aggregate_exprs); | ||
} | ||
|
||
protected: | ||
unique_ptr<AggregateHashTable> standard_hash_table_; | ||
}; | ||
|
||
BENCHMARK_DEFINE_F(DISABLED_StandardAggregateHashTableBenchmark, Aggregate)(benchmark::State &state) | ||
{ | ||
for (auto _ : state) { | ||
standard_hash_table_->add_chunk(group_chunk_, aggr_chunk_); | ||
} | ||
} | ||
|
||
BENCHMARK_REGISTER_F(DISABLED_StandardAggregateHashTableBenchmark, Aggregate)->Arg(16)->Arg(1024)->Arg(8192); | ||
|
||
#ifdef USE_SIMD | ||
class DISABLED_LinearProbingAggregateHashTableBenchmark : public AggregateHashTableBenchmark | ||
{ | ||
public: | ||
void SetUp(const ::benchmark::State &state) override | ||
{ | ||
|
||
AggregateHashTableBenchmark::SetUp(state); | ||
linear_probing_hash_table_ = make_unique<LinearProbingAggregateHashTable<int>>(AggregateExpr::Type::SUM); | ||
} | ||
|
||
protected: | ||
unique_ptr<AggregateHashTable> linear_probing_hash_table_; | ||
}; | ||
|
||
BENCHMARK_DEFINE_F(DISABLED_LinearProbingAggregateHashTableBenchmark, Aggregate)(benchmark::State &state) | ||
{ | ||
for (auto _ : state) { | ||
linear_probing_hash_table_->add_chunk(group_chunk_, aggr_chunk_); | ||
} | ||
} | ||
|
||
BENCHMARK_REGISTER_F(DISABLED_LinearProbingAggregateHashTableBenchmark, Aggregate)->Arg(16)->Arg(1024)->Arg(8192); | ||
#endif | ||
|
||
BENCHMARK_MAIN(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved. | ||
miniob is licensed under Mulan PSL v2. | ||
You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
You may obtain a copy of Mulan PSL v2 at: | ||
http://license.coscl.org.cn/MulanPSL2 | ||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
See the Mulan PSL v2 for more details. */ | ||
|
||
#include <benchmark/benchmark.h> | ||
|
||
#include "sql/expr/arithmetic_operator.hpp" | ||
|
||
class DISABLED_ArithmeticBenchmark : public benchmark::Fixture | ||
{ | ||
public: | ||
void SetUp(const ::benchmark::State &state) override | ||
{ | ||
int size = state.range(0); | ||
left_ = (float *)malloc(size * sizeof(float)); | ||
right_ = (float *)malloc(size * sizeof(float)); | ||
result_ = (float *)malloc(size * sizeof(float)); | ||
|
||
for (int i = 0; i < size; ++i) { | ||
left_[i] = 1.0f; | ||
right_[i] = 0.5f; | ||
result_[i] = 0.0f; | ||
} | ||
} | ||
|
||
void TearDown(const ::benchmark::State &state) override | ||
{ | ||
free(left_); | ||
left_ = nullptr; | ||
free(right_); | ||
right_ = nullptr; | ||
free(result_); | ||
result_ = nullptr; | ||
} | ||
|
||
protected: | ||
float *left_ = nullptr; | ||
float *right_ = nullptr; | ||
float *result_ = nullptr; | ||
}; | ||
|
||
BENCHMARK_DEFINE_F(DISABLED_ArithmeticBenchmark, Add)(benchmark::State &state) | ||
{ | ||
for (auto _ : state) { | ||
binary_operator<false, false, float, AddOperator>(left_, right_, result_, state.range(0)); | ||
} | ||
} | ||
|
||
BENCHMARK_REGISTER_F(DISABLED_ArithmeticBenchmark, Add)->Arg(10)->Arg(1000)->Arg(10000); | ||
|
||
BENCHMARK_DEFINE_F(DISABLED_ArithmeticBenchmark, Sub)(benchmark::State &state) | ||
{ | ||
for (auto _ : state) { | ||
binary_operator<false, false, float, SubtractOperator>(left_, right_, result_, state.range(0)); | ||
} | ||
} | ||
|
||
BENCHMARK_REGISTER_F(DISABLED_ArithmeticBenchmark, Sub)->Arg(10)->Arg(1000)->Arg(10000); | ||
|
||
#ifdef USE_SIMD | ||
static void DISABLED_benchmark_sum_simd(benchmark::State &state) | ||
{ | ||
int size = state.range(0); | ||
std::vector<int> data(state.range(0), 1); | ||
for (auto _ : state) { | ||
mm256_sum_epi32(data.data(), size); | ||
} | ||
} | ||
|
||
BENCHMARK(DISABLED_benchmark_sum_simd)->RangeMultiplier(2)->Range(1 << 10, 1 << 12); | ||
#endif | ||
|
||
static int sum_scalar(const int *data, int size) | ||
{ | ||
int sum = 0; | ||
for (int i = 0; i < size; i++) { | ||
sum += data[i]; | ||
} | ||
return sum; | ||
} | ||
|
||
static void DISABLED_benchmark_sum_scalar(benchmark::State &state) | ||
{ | ||
int size = state.range(0); | ||
std::vector<int> data(size, 1); | ||
for (auto _ : state) { | ||
int res = sum_scalar(data.data(), size); | ||
benchmark::DoNotOptimize(res); | ||
} | ||
} | ||
|
||
BENCHMARK(DISABLED_benchmark_sum_scalar)->RangeMultiplier(2)->Range(1 << 10, 1 << 12); | ||
|
||
BENCHMARK_MAIN(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.