flode / artsynchronized Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
The provided example uses keys that are integers. The associated loadKey
function is:
void loadKey(TID tid, Key &key) {
// Store the key of the tuple into the key vector
// Implementation is database specific
key.setKeyLen(sizeof(tid));
reinterpret_cast<uint64_t *>(&key[0])[0] = __builtin_bswap64(tid);
}
And insertion goes like:
Key key;
loadKey(tid, key);
tree.insert(key, tid, t);
However, it's unclear to me how I can use strings as the keys in the tree, because I need to load the key from a TID
, which is just an integer. I've read the companion paper and I think I understand how TID
can be used as a tagged pointer, but I don't see how that helps me much. Any guidance would be highly appreciated.
Hi!
I find in some case, art insert API may be crashed. In the following example, I insert two keys and the program will abort
#include "ART/Tree.h"
#include <vector>
#include <string>
std::vector<std::string > dict{
"art",
"artist",
};
void loadKey(TID tid, Key &key) {
key.set((const char*)dict[tid].data(), dict[tid].size());
}
void singlethreaded() {
ART_unsynchronized::Tree tree(loadKey);
std::vector<TID> keys = {0 , 1};
for (uint64_t i = 0; i != keys.size(); i++) {
Key key;
loadKey(keys[i], key);
tree.insert(key, keys[i]);
}
}
int main(){
singlethreaded();
}
I find if we insert a key whose prefix is a inserted key, the Tree.cpp:123 may have some trouble
n4->insert(k[level + prefixLength], N::setLeaf(tid));
n4->insert(key[level + prefixLength], nextNode);
The level + prefixLength is out of range and will case Key operator[] raising error.
Hi, I found an issue with getChillren()
function in line 103
of Tree.cpp
inside lookupRange()
of ARTOLC implementation.
Node4, Node16, Node48, Node256
, it checks if it needs to restart upon read-write conflicts.
When conflict is detected, it restarts locally, but this can cause an infinite loop when running with write operations.
The dynamic node adjustment replaces a node with a larger/smaller node, which marks the original obsolete and reclaimed. However, when running concurrent queries of range lookups with a mixture of write operations such as insert and remove, threads executing range queries keep trying locally to collect child pointers due to obsoleteness detection which will never succeed.
I think the getChildren()
in each node type should either
Hi,
this art tree is used for in-memory, it seems hard to persistent the total tree to a file(there still many concurrency write when execute persistent ) and do quickly recovery to memory.
Hi,
I'm trying to compile your very interesting software (given the papers) on an Ubuntu 16.04 system.
It fails, as follows. Any ideas?
`-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No build type selected, default to Release
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: src/c/ARTSynchronized/build
$ make
Scanning dependencies of target ARTSynchronized
[ 16%] Building CXX object CMakeFiles/ARTSynchronized.dir/OptimisticLockCoupling/Tree.cpp.o
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp: In member function ‘bool ART_OLC::Tree::lookupRange(const Key&, const Key&, Key&, TID*, std::size_t, std::size_t&, ART::ThreadInfo&) const’:
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:91:14: error: ‘function’ is not a member of ‘std’
std::function<void(const N *)> copy = [&result, &resultSize, &resultsFound, &toContinue, ©](const N *node) {
^~~~~~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:91:14: note: suggested alternative: ‘is_function’
std::function<void(const N *)> copy = [&result, &resultSize, &resultsFound, &toContinue, ©](const N *node) {
^~~~~~~~
is_function
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:91:23: error: expected primary-expression before ‘void’
std::function<void(const N *)> copy = [&result, &resultSize, &resultsFound, &toContinue, ©](const N *node) {
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:112:14: error: ‘function’ is not a member of ‘std’
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findStart = [©, &start, &findStart, &toContinue, this](
^~~~~~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:112:14: note: suggested alternative: ‘is_function’
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findStart = [©, &start, &findStart, &toContinue, this](
^~~~~~~~
is_function
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:112:71: error: expression list treated as compound expression in functional cast [-fpermissive]
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findStart = [©, &start, &findStart, &toContinue, this](
^
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:112:23: error: expected primary-expression before ‘void’
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findStart = [©, &start, &findStart, &toContinue, this](
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:181:14: error: ‘function’ is not a member of ‘std’
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findEnd = [©, &end, &toContinue, &findEnd, this](
^~~~~~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:181:14: note: suggested alternative: ‘is_function’
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findEnd = [©, &end, &toContinue, &findEnd, this](
^~~~~~~~
is_function
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:181:71: error: expression list treated as compound expression in functional cast [-fpermissive]
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findEnd = [©, &end, &toContinue, &findEnd, this](
^
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:181:23: error: expected primary-expression before ‘void’
std::function<void(N *, uint8_t, uint32_t, const N *, uint64_t)> findEnd = [©, &end, &toContinue, &findEnd, this](
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:280:21: error: ‘copy’ was not declared in this scope
copy(node);
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:280:21: note: suggested alternative:
In file included from /usr/include/c++/7/bits/locale_facets.h:48:0,
from /usr/include/c++/7/bits/basic_ios.h:37,
from /usr/include/c++/7/ios:44,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iterator:64,
from /usr/include/tbb/concurrent_vector.h:42,
from /usr/include/tbb/enumerable_thread_specific.h:25,
from src/c/ARTSynchronized/OptimisticLockCoupling/../Epoche.h:6,
from src/c/ARTSynchronized/OptimisticLockCoupling/N.h:13,
from src/c/ARTSynchronized/OptimisticLockCoupling/Tree.h:7,
from src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:3:
/usr/include/c++/7/bits/streambuf_iterator.h:293:5: note: ‘std::copy’
copy(istreambuf_iterator<_CharT> __first,
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:294:33: error: ‘findStart’ was not declared in this scope
findStart(n, k, level + 1, node, v);
^~~~~~~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:296:33: error: ‘copy’ was not declared in this scope
copy(n);
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:296:33: note: suggested alternative:
In file included from /usr/include/c++/7/bits/locale_facets.h:48:0,
from /usr/include/c++/7/bits/basic_ios.h:37,
from /usr/include/c++/7/ios:44,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iterator:64,
from /usr/include/tbb/concurrent_vector.h:42,
from /usr/include/tbb/enumerable_thread_specific.h:25,
from src/c/ARTSynchronized/OptimisticLockCoupling/../Epoche.h:6,
from src/c/ARTSynchronized/OptimisticLockCoupling/N.h:13,
from src/c/ARTSynchronized/OptimisticLockCoupling/Tree.h:7,
from src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:3:
/usr/include/c++/7/bits/streambuf_iterator.h:293:5: note: ‘std::copy’
copy(istreambuf_iterator<_CharT> __first,
^~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:298:33: error: ‘findEnd’ was not declared in this scope
findEnd(n, k, level + 1, node, v);
^~~~~~~
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:79:91: warning: unused parameter ‘result’ [-Wunused-parameter]
bool Tree::lookupRange(const Key &start, const Key &end, Key &continueKey, TID result[],
^
src/c/ARTSynchronized/OptimisticLockCoupling/Tree.cpp:80:45: warning: unused parameter ‘resultSize’ [-Wunused-parameter]
std::size_t resultSize, std::size_t &resultsFound, ThreadInfo &threadEpocheInfo) const {
^~~~~~~~~~
CMakeFiles/ARTSynchronized.dir/build.make:62: recipe for target 'CMakeFiles/ARTSynchronized.dir/OptimisticLockCoupling/Tree.cpp.o' failed
make[2]: *** [CMakeFiles/ARTSynchronized.dir/OptimisticLockCoupling/Tree.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ARTSynchronized.dir/all' failed
make[1]: *** [CMakeFiles/ARTSynchronized.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
`
When running your ART source code on FB dataset, we found a potential bug of ART that it could not search some keys which have been inserted.
The code below is used to reproduce the case. Data could be fetched from https://drive.google.com/file/d/1NDvJ5fIvNkMLRbiHPHzIEEirfL3wMsU0/view?usp=sharing.
Would you mind taking a look and fix it?
Thank you very much in advance.
Regards,
Zhicong
#include"./ART/Tree.h"
#include"./ART/Tree.cpp"
#include <iostream>
#include <chrono>
#include "tbb/tbb.h"
#include <cstdio>
#include <random>
#include <fstream>
using namespace ART_unsynchronized;
void loadKey(TID tid, Key &key) {
// Store the key of the tuple into the key vector
// Implementation is database specific
key.setKeyLen(sizeof(tid));
reinterpret_cast<uint64_t *>(&key[0])[0] = __builtin_bswap64(tid);
}
template<class T>
bool load_binary_data(T data[], int length, const std::string &file_path) {
std::ifstream is(file_path.c_str(), std::ios::binary | std::ios::in);
if (!is.is_open()) {
return false;
}
is.read(reinterpret_cast<char *>(data), std::streamsize(length * sizeof(T)));
is.close();
return true;
}
int main() {
ART_unsynchronized::Tree idx(loadKey);
size_t data_size = 200000000;
// Load data from file
uint64_t *keys = new uint64_t[data_size];
std::cout << "Loading data" << std::endl;
load_binary_data(keys, data_size,"./fb_200M_uint64");
// Make data Unique
std::cout << "Make data Unique" << std::endl;
std::sort(keys, keys + data_size);
auto tail = std::unique(keys, keys + data_size);
data_size = tail - keys;
// Shuffle all data
std::random_shuffle(keys, keys + data_size);
printf("unique key size is %d\n", data_size);
// print first 20 keys
for (auto i = 0; i < data_size; i++) {
printf("%llu ", keys[i]);
if (i >= 20) break;
}
printf("\n");
// Insert
printf("Inserting\n");
for (int i = 0; i < data_size; i++) {
Key key;
loadKey(keys[i], key);
idx.insert(key, keys[i]);
auto val = idx.lookup(key);
if (val != keys[i]) {
std::cout << "Position " << i << ", Insert error, wrong key read: " << val << " expected:" << keys[i]
<< std::endl;
throw;
}
}
// Searching
printf("Searching\n");
for (uint64_t i = 0; i < data_size; i++) {
Key key;
loadKey(keys[i], key);
auto val = idx.lookup(key);
if (val != keys[i]) {
std::cout << "Position " << i << ", Insert error, wrong key read: " << val << " expected:" << keys[i]
<< std::endl;
throw;
}
}
std::cout << "Pass test" << std::endl;
return 0;
}
The output is as follow
Loading data
Make data Unique
unique key size is 200000000
4060157729 5065591993 58797781080 73649762378 14811202877 26396414685 52284035418 35497117877 61610484743 40478218422 4174327440 32246990818 69960350543 2586919880 74534544755 60312685616 43819963826 9641372789 40302608760 36968601931 35444885175
Inserting
Position 38002711, Insert error, wrong key read: 0 expected:12298204682441981952
terminate called without an active exception
Aborted (core dumped)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.