libcuckoo Documentation
repository·master·Indexed 23 days ago
https://github.com/efficient/libcuckooA high-performance, compact, and concurrent header-only C++ hash table library designed for multiple simultaneous reader and writer threads. Includes a C wrapper, GDB pretty-printer configuration, and CMake build instructions for installing headers and running benchmarks.
What's inside libcuckoo
- libcuckoo provides a C wrapper around the hash table. This allows you to leverage the high-performance concurrent hash table within C programs. The interface uses a template header and implementation file to generate instances for different key-value types.
Use libcuckoo in your C++ project
masterlibcuckoo is a header-only library. To use it, add the
libcuckoosubdirectory to your project's include path.Important: You must enable C++11 features in your compiler.
- For
g++: use-std=c++11 - For
clang++: use-std=c++11 -stdlib=libc++
Once the include path is configured, you can include the main header:
#include <libcuckoo/cuckoohash_map.hh>- For
Configure GDB pretty-printers for libcuckoo
masterTo enable pretty-printing for
cuckoohashmaps within GDB, you must register the libcuckoo Python module in your GDB initialization file (~/.gdbinit).- Locate the absolute path to the
libcuckoo-gdb-printersdirectory in your local repository. - Add a Python block to your
~/.gdbinitthat inserts this path intosys.pathand callsregister_libcuckoo_printers(None).
import sys sys.path.insert(0, '/path/to/libcuckoo/libcuckoo-gdb-printers') from libcuckoo.printers import register_libcuckoo_printers register_libcuckoo_printers (None)- Locate the absolute path to the
Install libcuckoo to a specific location
masterTo install the libcuckoo header files to a specific directory on your system, follow these steps using CMake:
- Create and enter a
builddirectory. - Run
cmakewith the-DCMAKE_INSTALL_PREFIXflag set to your desired path. - Build and install using
make.
Example for installing to a local
../installdirectory:mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=../install -DBUILD_EXAMPLES=1 -DBUILD_TESTS=1 .. make all make install$ mkdir build $ cd build $ cmake -DCMAKE_INSTALL_PREFIX=../install -DBUILD_EXAMPLES=1 -DBUILD_TESTS=1 .. $ make all $ make install- Create and enter a
Configure CMake build flags for libcuckoo
masterWhen building libcuckoo from the
builddirectory, you can use the following CMake flags to control the build output:Flag Description -DCMAKE_INSTALL_PREFIX=<path>Set the location where the libcuckoo header files are installed -DCMAKE_BUILD_TYPE=<type>Enable different types of build flags (e.g., Debug, Release) -DBUILD_EXAMPLES=1Build the examplesdirectory-DBUILD_TESTS=1Build all tests in the testsdirectory-DBUILD_STRESS_TESTS=1Build all tests in the tests/stress-testsdirectory-DBUILD_UNIT_TESTS=1Build all tests in the tests/unit-testsdirectory-DBUILD_UNIVERSAL_BENCHMARK=1Build the universal benchmark in tests/universal-benchmarkNote: The universal benchmark allows testing various operations at arbitrary percentages with specific keys and values.