Skip to content

Commit

Permalink
Add some more datastructure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
durner committed Jul 31, 2023
1 parent d1aecf5 commit 86f5ea2
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ In this repository, we present AnyBlob.
AnyBlob is a universal download manager that allows to retrieve and upload objects to different cloud object stores.
Our download manager uses less CPU resources than cloud-vendor provided libraries while retaining maximum throughput performance.
AnyBlob leverages IO\_uring for superior performance per core.
For experimental results, please visit our research paper at [].
For experimental results, please visit our research paper at [PVLDB 16](https://www.vldb.org/pvldb/vol16/p2734-durner.pdf).

## Building AnyBlob

Expand Down Expand Up @@ -42,9 +42,10 @@ For coverage testing you can simply `make coverage` and open the coverage report

## Cite this work

If you are using AnyBlob in our scientific work, please cite:
If you are using AnyBlob in your scientific work, please cite:

```
Exploiting Cloud Object Storage for High-Performance Analytics
Dominik Durner, Viktor Leis, and Thomas Neumann
PVLDB 16, 11 (2023), 49th International Conference on Very Large Data Bases
```
67 changes: 67 additions & 0 deletions test/unit/utils/ring_buffer_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "utils/ring_buffer.hpp"
#include "catch2/single_include/catch2/catch.hpp"
#include <thread>
//---------------------------------------------------------------------------
// AnyBlob - Universal Cloud Object Storage Library
// Dominik Durner, 2022
Expand Down Expand Up @@ -27,6 +28,72 @@ TEST_CASE("ring_buffer") {
REQUIRE(rb.empty());
}
//---------------------------------------------------------------------------
TEST_CASE("single_threaded_insert_multi_threaded_consume") {
RingBuffer<uint64_t> rb(1000);
for (int i = 0; i < 1000; i++) {
REQUIRE(rb.insert<true>(i) != ~0ull);
}
std::vector<std::thread> threads;
for (int i = 0; i < 10; i++) {
threads.push_back(std::thread([&] {
for (int j = 0; j < 100; j++) {
REQUIRE(rb.consume<true>().value() < 1000ul);
}
}));
}
for (auto& th : threads) {
th.join();
}
REQUIRE(!rb.consume().has_value());
}
//---------------------------------------------------------------------------
TEST_CASE("multi_threaded_ring_buffer") {
RingBuffer<uint64_t> rb(1000);
std::vector<std::thread> threads;
for (int i = 0; i < 10; i++) {
threads.push_back(std::thread([&] {
for (int j = 0; j < 100; j++) {
REQUIRE(rb.insert<true>(j) != ~0ull);
}
}));
}
for (auto& th : threads) {
th.join();
}
for (int i = 0; i < 1000; i++) {
REQUIRE(rb.consume().value() < 100ul);
}
REQUIRE(!rb.consume().has_value());
}
//---------------------------------------------------------------------------
TEST_CASE("multi_threaded_ring_buffer_multi_threaded_consume") {
RingBuffer<uint64_t> rb(1000);
std::vector<std::thread> threads;
for (int i = 0; i < 10; i++) {
threads.push_back(std::thread([&] {
for (int j = 0; j < 100; j++) {
REQUIRE(rb.insert<true>(j) != ~0ull);
}
}));
}
for (auto& th : threads) {
th.join();
}
// Consume multi-threaded
threads.clear();
for (int i = 0; i < 10; i++) {
threads.push_back(std::thread([&] {
for (int j = 0; j < 100; j++) {
REQUIRE(rb.consume<true>().value() < 100ul);
}
}));
}
for (auto& th : threads) {
th.join();
}
REQUIRE(!rb.consume().has_value());
}
//---------------------------------------------------------------------------
} // namespace test
} // namespace utils
} // namespace anyblob
55 changes: 55 additions & 0 deletions test/unit/utils/unordered_map_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "utils/unordered_map.hpp"
#include "catch2/single_include/catch2/catch.hpp"
#include <thread>
//---------------------------------------------------------------------------
// AnyBlob - Universal Cloud Object Storage Library
// Dominik Durner, 2022
Expand Down Expand Up @@ -28,6 +29,60 @@ TEST_CASE("unordered_map") {
REQUIRE(ht.size() == 1);
}
//---------------------------------------------------------------------------
TEST_CASE("unordered_map_multi_threaded") {
// Insert 1000 elements in 10 threads
UnorderedMap<int, int> ht(128);
std::thread t[10];
for (int i = 0; i < 10; i++) {
t[i] = std::thread([&ht, i]() {
for (int j = 0; j < 10; j++) {
std::ignore = ht.insert(i * 10 + j, i * 10 + j);
}
});
}
for (int i = 0; i < 10; i++) {
t[i].join();
}
// Find the elements multu-threaded
for (int i = 0; i < 10; i++) {
t[i] = std::thread([&ht, i]() {
for (int j = 0; j < 10; j++) {
REQUIRE(ht.find(i * 10 + j) != ht.end());
}
});
}
for (int i = 0; i < 10; i++) {
t[i].join();
}
}
//---------------------------------------------------------------------------
TEST_CASE("unordered_map_multi_threaded_delete") {
UnorderedMap<int, int> ht(128);
// Insert 1000 elements in 10 threads
std::thread t[10];
for (int i = 0; i < 10; i++) {
t[i] = std::thread([&ht, i]() {
for (int j = 0; j < 10; j++) {
std::ignore = ht.insert(i * 10 + j, i * 10 + j);
}
});
}
for (int i = 0; i < 10; i++) {
t[i].join();
}
// Delete the elements multi-threaded
for (int i = 0; i < 10; i++) {
t[i] = std::thread([&ht, i]() {
for (int j = 0; j < 10; j++) {
REQUIRE(ht.erase(i * 10 + j));
}
});
}
for (int i = 0; i < 10; i++) {
t[i].join();
}
}
//---------------------------------------------------------------------------
} // namespace test
} // namespace utils
} // namespace anyblob

0 comments on commit 86f5ea2

Please sign in to comment.