Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ option(JOIN_ENABLE_CRYPTO "Enable crypto." ON)
option(JOIN_ENABLE_DATA "Enable data." ON)
option(JOIN_ENABLE_FABRIC "Enable fabric." ON)
option(JOIN_ENABLE_SERVICES "Enable services." ON)
option(JOIN_ENABLE_IO_URING "Enable io_uring backend." OFF)
option(JOIN_ENABLE_NUMA "Enable NUMA support." OFF)
option(JOIN_ENABLE_SAMPLES "Build samples" OFF)
option(JOIN_ENABLE_TESTS "Enable tests." OFF)
Expand Down
8 changes: 5 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"binaryDir": "${sourceDir}/build/gcc/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"JOIN_ENABLE_COVERAGE": "ON"
"JOIN_ENABLE_COVERAGE": "ON",
"JOIN_ENABLE_IO_URING": "ON"
}
},
{
Expand All @@ -58,7 +59,8 @@
"binaryDir": "${sourceDir}/build/clang/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"JOIN_ENABLE_COVERAGE": "ON"
"JOIN_ENABLE_COVERAGE": "ON",
"JOIN_ENABLE_IO_URING": "ON"
}
},
{
Expand Down Expand Up @@ -120,4 +122,4 @@
}
}
]
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ sudo apt install pkg-config libssl-dev zlib1g-dev libgtest-dev libgmock-dev

| Option | Library | Default | Description |
| :--- | :--- | :---: | :--- |
| `JOIN_ENABLE_IO_URING` | `liburing-dev` | `OFF` | Enables the io_uring based proactor backend for async I/O. |
| `JOIN_ENABLE_NUMA` | `libnuma-dev` | `OFF` | Enables NUMA aware memory binding for `LocalMem` and `ShmMem`. |

Install as needed:
```bash
sudo apt install liburing-dev # for JOIN_ENABLE_IO_URING
sudo apt install libnuma-dev # for JOIN_ENABLE_NUMA
```

Expand All @@ -108,6 +110,7 @@ cmake --build build
With optional backends:
```bash
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DJOIN_ENABLE_IO_URING=ON \
-DJOIN_ENABLE_NUMA=ON \
-DJOIN_ENABLE_TESTS=ON
cmake --build build
Expand All @@ -122,6 +125,7 @@ cmake --build build
| `JOIN_ENABLE_DATA` | `ON` | Build the data module. |
| `JOIN_ENABLE_FABRIC` | `ON` | Build the fabric module. |
| `JOIN_ENABLE_SERVICES` | `ON` | Build the services module (requires crypto, data, fabric). |
| `JOIN_ENABLE_IO_URING` | `OFF` | Enable io_uring based proactor backend (requires `liburing-dev`). |
| `JOIN_ENABLE_NUMA` | `OFF` | Enable NUMA support (requires `libnuma-dev`). |
| `JOIN_ENABLE_SAMPLES` | `OFF` | Build sample programs. |
| `JOIN_ENABLE_TESTS` | `OFF` | Build the test suite. |
Expand Down
19 changes: 18 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.22.1)

if(JOIN_ENABLE_IO_URING)
pkg_check_modules(LIBURING REQUIRED liburing)
endif()

if(JOIN_ENABLE_NUMA)
pkg_check_modules(NUMA REQUIRED numa)
endif()
Expand All @@ -12,6 +16,7 @@ set(PUBLIC_HEADERS
include/join/traits.hpp
include/join/variant.hpp
include/join/reactor.hpp
include/join/io_operation.hpp
include/join/proactor.hpp
include/join/memory.hpp
include/join/allocator.hpp
Expand All @@ -38,10 +43,16 @@ set(PUBLIC_HEADERS
include/join/statistics.hpp
)

if(JOIN_ENABLE_IO_URING)
list(APPEND PUBLIC_HEADERS include/join/io_policy.hpp include/join/proactor_uring_impl.hpp)
else()
list(APPEND PUBLIC_HEADERS include/join/proactor_epoll_impl.hpp)
endif()

set(SOURCES
src/error.cpp
src/reactor.cpp
src/proactor.cpp
src/io_operation.cpp
src/mutex.cpp
src/condition.cpp
src/semaphore.cpp
Expand All @@ -67,6 +78,7 @@ target_include_directories(${JOIN_CORE}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<$<BOOL:${JOIN_ENABLE_IO_URING}>:${LIBURING_INCLUDE_DIRS}>
$<$<BOOL:${JOIN_ENABLE_NUMA}>:${NUMA_INCLUDE_DIRS}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
Expand All @@ -77,9 +89,14 @@ target_link_libraries(${JOIN_CORE}
OpenSSL::SSL
OpenSSL::Crypto
Threads::Threads
$<$<BOOL:${JOIN_ENABLE_IO_URING}>:${LIBURING_LIBRARIES}>
$<$<BOOL:${JOIN_ENABLE_NUMA}>:${NUMA_LIBRARIES}>
)

if(JOIN_ENABLE_IO_URING)
target_compile_definitions(${JOIN_CORE} PUBLIC JOIN_HAS_IO_URING)
endif()

if(JOIN_ENABLE_NUMA)
target_compile_definitions(${JOIN_CORE} PUBLIC JOIN_HAS_NUMA)
endif()
Expand Down
20 changes: 20 additions & 0 deletions core/include/join/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,26 @@ namespace join
return ((ptr >= base) && (ptr < end));
}

/**
* @brief get the index of a chunk in the pool.
* @param p pointer to the chunk (must be owned by this pool).
* @return index of the chunk.
*/
uint32_t getIndex (void* p) const noexcept
{
return static_cast<uint32_t> (reinterpret_cast<Chunk*> (p) - _segment->_chunks);
}

/**
* @brief get the pointer to a chunk by index.
* @param idx index of the chunk (must be in range).
* @return pointer to the chunk.
*/
void* getPtr (uint32_t idx) const noexcept
{
return &_segment->_chunks[idx];
}

/// pointer into the mapped region.
Segment* _segment = nullptr;
};
Expand Down
Loading
Loading