This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple benchmark for tuple_access_strategy (#37)
Added basic benchmark for tuple_access_strategy. Not sure it's a valid benchmark, but I wanted a microbenchmark in order to test the framework and demonstrate how to write future microbenchmarks.
- Loading branch information
1 parent
5146e56
commit 015c2b1
Showing
10 changed files
with
176 additions
and
87 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,11 @@ | ||
file(GLOB_RECURSE BENCHMARK_HDRS ${PROJECT_SOURCE_DIR}/benchmark/include/*.h) | ||
file(GLOB_RECURSE BENCHMARK_UTIL_SRCS ${PROJECT_SOURCE_DIR}/benchmark/util/*.cpp) | ||
list(APPEND BENCHMARK_UTIL_SRCS ${BENCHMARK_HDRS}) | ||
|
||
############################################### | ||
# Benchmark library | ||
############################################### | ||
add_library(benchmark_shared SHARED ${BENCHMARK_UTIL_SRCS}) | ||
target_link_libraries(benchmark_shared benchmark) | ||
|
||
add_subdirectory(storage) |
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 @@ | ||
ADD_TERRIER_BENCHMARKS() |
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,60 @@ | ||
#include "benchmark/benchmark.h" | ||
#include "common/test_util.h" | ||
#include "storage/tuple_access_strategy_test_util.h" | ||
|
||
namespace terrier { | ||
|
||
// Roughly corresponds to TEST_F(TupleAccessStrategyTests, SimpleInsertTest) | ||
static void BM_SimpleInsert(benchmark::State &state) { | ||
|
||
// Get a BlockStore and then RawBlock to use for inserting into | ||
storage::RawBlock *raw_block_ = nullptr; | ||
storage::BlockStore block_store_{1}; | ||
|
||
// Number of times to repeat the Initialize and Insert loop | ||
const uint32_t repeat = 3; | ||
std::default_random_engine generator; | ||
|
||
// Tuple layout | ||
uint16_t num_columns = 8; | ||
uint8_t column_size = 8; | ||
storage::BlockLayout layout(num_columns, | ||
{column_size, column_size, column_size, column_size, column_size, column_size, | ||
column_size, column_size}); | ||
storage::TupleAccessStrategy tested(layout); | ||
std::unordered_map<storage::TupleSlot, testutil::FakeRawTuple> tuples; | ||
|
||
while (state.KeepRunning()) { | ||
|
||
for (uint32_t i = 0; i < repeat; i++) { | ||
// Get the Block, zero it, and initialize | ||
raw_block_ = block_store_.Get(); | ||
PELOTON_MEMSET(raw_block_, 0, sizeof(storage::RawBlock)); | ||
storage::InitializeRawBlock(raw_block_, layout, 0); | ||
|
||
// Insert the maximum number of tuples into this Block | ||
for (uint32_t j = 0; j < layout.num_slots_; j++) | ||
testutil::TryInsertFakeTuple(layout, | ||
tested, | ||
raw_block_, | ||
tuples, | ||
generator); | ||
|
||
tuples.clear(); | ||
block_store_.Release(raw_block_); | ||
|
||
} | ||
|
||
} | ||
|
||
// We want to approximate the amount of data processed so Google Benchmark can print stats for us | ||
// We'll say it 2x RawBlock because we zero it, and then populate it. This is likely an underestimation | ||
size_t bytes_per_repeat = 2 * sizeof(storage::RawBlock); | ||
state.SetBytesProcessed(state.iterations() * repeat * bytes_per_repeat); | ||
} | ||
|
||
BENCHMARK(BM_SimpleInsert) | ||
->Repetitions(3)-> | ||
Unit(benchmark::kMillisecond); | ||
|
||
} |
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,26 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// Modified from the Apache Arrow project for the Terrier project. | ||
|
||
#include "benchmark/benchmark.h" | ||
|
||
int main(int argc, char** argv) { | ||
benchmark::Initialize(&argc, argv); | ||
benchmark::RunSpecifiedBenchmarks(); | ||
return 0; | ||
} |
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
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.