libcuckoo Documentation

repository·master·Indexed 23 days ago

https://github.com/efficient/libcuckoo

A 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.

Tokens
752
Snippets
2
Records
5
Agent score
33%

What's inside libcuckoo

  1. Use libcuckoo in C programs

    master
    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.
  2. Use libcuckoo in your C++ project

    master

    libcuckoo is a header-only library. To use it, add the libcuckoo subdirectory 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>
  3. Configure GDB pretty-printers for libcuckoo

    master

    To enable pretty-printing for cuckoohash maps within GDB, you must register the libcuckoo Python module in your GDB initialization file (~/.gdbinit).

    1. Locate the absolute path to the libcuckoo-gdb-printers directory in your local repository.
    2. Add a Python block to your ~/.gdbinit that inserts this path into sys.path and calls register_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)
  4. Install libcuckoo to a specific location

    master

    To install the libcuckoo header files to a specific directory on your system, follow these steps using CMake:

    1. Create and enter a build directory.
    2. Run cmake with the -DCMAKE_INSTALL_PREFIX flag set to your desired path.
    3. Build and install using make.

    Example for installing to a local ../install directory:

    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
  5. Configure CMake build flags for libcuckoo

    master

    When building libcuckoo from the build directory, you can use the following CMake flags to control the build output:

    FlagDescription
    -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 examples directory
    -DBUILD_TESTS=1Build all tests in the tests directory
    -DBUILD_STRESS_TESTS=1Build all tests in the tests/stress-tests directory
    -DBUILD_UNIT_TESTS=1Build all tests in the tests/unit-tests directory
    -DBUILD_UNIVERSAL_BENCHMARK=1Build the universal benchmark in tests/universal-benchmark

    Note: The universal benchmark allows testing various operations at arbitrary percentages with specific keys and values.