-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from lysevi/dev
release v0.0.3 * page is chunk container * more tests * Chunk pool * speed up
- Loading branch information
Showing
83 changed files
with
4,358 additions
and
1,252 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 |
---|---|---|
@@ -1,30 +1,18 @@ | ||
build_image: shippableimages/ubuntu1404_python | ||
sudo: required | ||
dist: trusty | ||
language: cpp | ||
compiler: | ||
- clang | ||
- gcc | ||
|
||
before_install: | ||
#- pip install --user cpp-coveralls | ||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test | ||
- sudo add-apt-repository -y ppa:apokluda/boost1.53 | ||
- sudo apt-get update -qq | ||
- sudo apt-get update | ||
- sudo apt-get install libboost1.53-all-dev | ||
- sudo apt-get install -y cmake | ||
- sudo apt-get install -y libboost-dev libboost-filesystem-dev libboost-test-dev cmake | ||
|
||
install: | ||
- sudo apt-get install -qq g++-4.8 | ||
- export CXX="g++-4.8" | ||
- cd ${TRAVIS_BUILD_DIR} | ||
- gcc --version | ||
|
||
before_script: | ||
- cmake . | ||
|
||
script: | ||
- make -j2 | ||
#&& ctest . | ||
|
||
#after_success: | ||
# - coveralls --exclude libmemseries --exclude tests --gcov-options '\-lp' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include <dariadb.h> | ||
#include <atomic> | ||
|
||
namespace dariadb_bench | ||
{ | ||
//TODO use cmd line params | ||
const size_t total_threads_count = 5; | ||
const size_t iteration_count = 3000000; | ||
|
||
void thread_writer_rnd_stor( | ||
dariadb::Id id, | ||
dariadb::Time sleep_time, | ||
std::atomic_long *append_count, | ||
dariadb::storage::BaseStorage_ptr ms) | ||
{ | ||
auto m = dariadb::Meas::empty(); | ||
m.time = dariadb::timeutil::current_time(); | ||
for (size_t i = 0; i < dariadb_bench::iteration_count; i++) { | ||
|
||
m.id = id; | ||
m.flag = dariadb::Flag(id); | ||
m.src = dariadb::Flag(id); | ||
m.time += sleep_time; | ||
m.value = dariadb::Value(i); | ||
ms->append(m); | ||
(*append_count)++; | ||
//std::this_thread::sleep_for(sleep_duration); | ||
} | ||
} | ||
} |
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,175 @@ | ||
#include <ctime> | ||
#include <iostream> | ||
#include <cstdlib> | ||
#include <iterator> | ||
|
||
#include <dariadb.h> | ||
#include <utils/fs.h> | ||
#include <storage/memstorage.h> | ||
#include <storage/capacitor.h> | ||
#include <ctime> | ||
#include <limits> | ||
#include <cmath> | ||
#include <chrono> | ||
#include <thread> | ||
#include <atomic> | ||
#include "bench_common.h" | ||
|
||
class BenchCallback :public dariadb::storage::ReaderClb { | ||
public: | ||
void call(const dariadb::Meas&) { | ||
count++; | ||
} | ||
size_t count; | ||
}; | ||
|
||
std::atomic_long append_count{ 0 }, read_all_times{ 0 }; | ||
bool stop_info = false; | ||
|
||
|
||
bool stop_read_all{ false }; | ||
|
||
void thread_read_all( | ||
dariadb::Time from, | ||
dariadb::Time to, | ||
dariadb::storage::BaseStorage_ptr ms) | ||
{ | ||
auto clb = std::make_shared<BenchCallback>(); | ||
while (!stop_read_all) { | ||
auto rdr = ms->readInterval(from, to); | ||
rdr->readAll(clb.get()); | ||
read_all_times++; | ||
} | ||
} | ||
|
||
void show_info() { | ||
clock_t t0 = clock(); | ||
auto all_writes = dariadb_bench::total_threads_count*dariadb_bench::iteration_count; | ||
while (true) { | ||
std::this_thread::sleep_for(std::chrono::milliseconds(300)); | ||
|
||
clock_t t1 = clock(); | ||
auto writes_per_sec = append_count.load() / double((t1 - t0) / CLOCKS_PER_SEC); | ||
//auto read_per_sec = read_all_times.load() / double((t1 - t0) / CLOCKS_PER_SEC); | ||
std::cout << "\rwrites: " << writes_per_sec | ||
<< "/sec progress:" << (100 * append_count) / all_writes | ||
<< "% "; | ||
/*if (!stop_read_all) { | ||
std::cout << " read_all_times: " << read_per_sec <<"/sec "; | ||
}*/ | ||
std::cout.flush(); | ||
if (stop_info) { | ||
/*std::cout << "\rwrites: " << writes_per_sec | ||
<< "/sec progress:" << (100 * append_count) / all_writes | ||
<< "% "; | ||
if (!stop_read_all) { | ||
std::cout << " read_all_times: " << read_per_sec << "/sec "; | ||
}*/ | ||
std::cout.flush(); | ||
break; | ||
} | ||
} | ||
std::cout << "\n"; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
(void)argc; | ||
(void)argv; | ||
{ | ||
std::cout << "MemStorage" << std::endl; | ||
dariadb::storage::BaseStorage_ptr ms{ new dariadb::storage::MemoryStorage{ 2000000 } }; | ||
std::thread info_thread(show_info); | ||
std::vector<std::thread> writers(dariadb_bench::total_threads_count); | ||
size_t pos = 0; | ||
for (size_t i = 0; i < dariadb_bench::total_threads_count; i++) { | ||
std::thread t{ dariadb_bench::thread_writer_rnd_stor, i,dariadb::Time(i+1),&append_count, ms }; | ||
writers[pos++] = std::move(t); | ||
} | ||
//std::thread read_all_t{ thread_read_all, 0, dariadb::Time(iteration_count), ms }; | ||
|
||
pos = 0; | ||
for (size_t i = 0; i < dariadb_bench::total_threads_count; i++) { | ||
std::thread t = std::move(writers[pos++]); | ||
t.join(); | ||
} | ||
stop_info = true; | ||
stop_read_all = true; | ||
info_thread.join(); | ||
//read_all_t.join(); | ||
} | ||
{ | ||
std::cout << "Capacitor" << std::endl; | ||
dariadb::storage::BaseStorage_ptr ms{ new dariadb::storage::MemoryStorage{ 2000000 } }; | ||
std::unique_ptr<dariadb::storage::Capacitor> cp{ | ||
new dariadb::storage::Capacitor(ms, dariadb::storage::Capacitor::Params(1000,1000)) | ||
}; | ||
|
||
append_count = 0; | ||
stop_info = false; | ||
|
||
std::thread info_thread(show_info); | ||
std::vector<std::thread> writers(dariadb_bench::total_threads_count); | ||
size_t pos = 0; | ||
for (size_t i = 0; i < dariadb_bench::total_threads_count; i++) { | ||
std::thread t{ dariadb_bench::thread_writer_rnd_stor, i,dariadb::Time(i),&append_count, ms }; | ||
writers[pos++] = std::move(t); | ||
} | ||
|
||
pos = 0; | ||
for (size_t i = 0; i < dariadb_bench::total_threads_count; i++) { | ||
std::thread t = std::move(writers[pos++]); | ||
t.join(); | ||
} | ||
stop_info = true; | ||
info_thread.join(); | ||
cp->flush(); | ||
} | ||
{ | ||
std::cout << "Union" << std::endl; | ||
const std::string storage_path = "testStorage"; | ||
const size_t chunk_per_storage = 1024; | ||
const size_t chunk_size = 512; | ||
const size_t cap_max_size = 10000; | ||
const dariadb::Time write_window_deep = 2000; | ||
const dariadb::Time old_mem_chunks = 0; | ||
const size_t max_mem_chunks = 0; | ||
|
||
if (dariadb::utils::fs::path_exists(storage_path)) { | ||
dariadb::utils::fs::rm(storage_path); | ||
} | ||
|
||
dariadb::storage::BaseStorage_ptr ms{ | ||
new dariadb::storage::UnionStorage( | ||
dariadb::storage::PageManager::Params(storage_path, dariadb::storage::MODE::SINGLE, chunk_per_storage, chunk_size), | ||
dariadb::storage::Capacitor::Params(cap_max_size,write_window_deep), | ||
dariadb::storage::UnionStorage::Limits(max_mem_chunks, old_mem_chunks)) }; | ||
|
||
append_count = 0; | ||
stop_info = false; | ||
stop_read_all = false; | ||
|
||
std::thread info_thread(show_info); | ||
std::vector<std::thread> writers(dariadb_bench::total_threads_count); | ||
|
||
size_t pos = 0; | ||
for (size_t i = 0; i < dariadb_bench::total_threads_count; i++) { | ||
std::thread t{ dariadb_bench::thread_writer_rnd_stor, i,dariadb::Time(i),&append_count, ms }; | ||
writers[pos++] = std::move(t); | ||
} | ||
//std::thread read_all_t{ thread_read_all, 0, dariadb::Time(iteration_count), ms }; | ||
|
||
pos = 0; | ||
for (size_t i = 0; i < dariadb_bench::total_threads_count; i++) { | ||
std::thread t = std::move(writers[pos++]); | ||
t.join(); | ||
} | ||
stop_info = true; | ||
stop_read_all = true; | ||
info_thread.join(); | ||
//read_all_t.join(); | ||
ms = nullptr; | ||
if (dariadb::utils::fs::path_exists(storage_path)) { | ||
dariadb::utils::fs::rm(storage_path); | ||
} | ||
} | ||
} |
Oops, something went wrong.