Skip to content

duongtt1/hpl

HPL - High Performance Lock-free Library

A small experimental C++ library of high-performance / lock-free data structures.

Status

This is a toy project generated using AI.

The goal is to:

  • Learn AI-assisted development
  • Experiment with concurrent data structures
  • Explore performance-oriented C++ design

The code is not deeply reviewed and not production-ready. Expect bugs, incorrect memory ordering, and rough edges.


What's Included

  • Queues: SPSC, MPSC, MPMC, Disruptor-style ring buffer
  • Stacks: Treiber, elimination-backoff
  • Maps/Sets: skip list, read-mostly hash map
  • Memory: arena, pool, slab, epoch, hazard pointers
  • Sync: seqlock, MCS/CLH, ticket lock, RW spinlock, futex wrapper
  • Utilities: timer wheel, sharded counter, latency histogram, work-stealing deque
  • Specialized: order book, shared-memory ring buffer, zero-copy buffer
  • SoC layer: basic ARM-oriented atomics, barriers, cache helpers

Design Goals (Exploratory)

  • Header-only
  • Minimal allocations on hot paths
  • Cache-aware layout
  • Bounded structures where possible
  • Explicit memory ordering (for learning purposes)

Quick Start

#include <hpl.hpp>
#include <cstdint>
#include <iostream>

int main() {
    hpl::queue::spsc_queue<std::uint64_t, 1024> q;

    q.push(42);

    std::uint64_t v = 0;
    if (q.pop(v)) {
        std::cout << v << "\n";
    }
}

Build

cmake -S . -B build
cmake --build build
ctest --test-dir build

Notes on the Code

Some headers include short tags:

  • [ALGO] — algorithm idea / invariant
  • [MO] — memory ordering reasoning
  • [HOT PATH] — performance-sensitive code
  • [AI-REVIEW] — likely needs human review

These are mainly there to help reading and learning.


Repository Layout

lib/                 headers
test/                tests (unit / stress / bench)
examples/            usage examples
docs/                notes
scripts/             helper scripts

Disclaimer

This repository exists for learning and experimentation only.

Do NOT use it in production systems.


License

MIT

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors