com.xaymar.datapath 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- com_xaymar_datapath-1.0.1/.clang-format +99 -0
- com_xaymar_datapath-1.0.1/.editorconfig +10 -0
- com_xaymar_datapath-1.0.1/.gitignore +7 -0
- com_xaymar_datapath-1.0.1/.mailmap +1 -0
- com_xaymar_datapath-1.0.1/CMakeLists.txt +286 -0
- com_xaymar_datapath-1.0.1/CONTRIBUTING.md +88 -0
- com_xaymar_datapath-1.0.1/LICENSE +28 -0
- com_xaymar_datapath-1.0.1/PKG-INFO +102 -0
- com_xaymar_datapath-1.0.1/README.md +127 -0
- com_xaymar_datapath-1.0.1/bindings/node/.gitignore +6 -0
- com_xaymar_datapath-1.0.1/bindings/node/CMakeLists.txt +75 -0
- com_xaymar_datapath-1.0.1/bindings/node/README.md +73 -0
- com_xaymar_datapath-1.0.1/bindings/node/lib/index.d.ts +164 -0
- com_xaymar_datapath-1.0.1/bindings/node/lib/index.js +243 -0
- com_xaymar_datapath-1.0.1/bindings/node/package-lock.json +510 -0
- com_xaymar_datapath-1.0.1/bindings/node/package.json +78 -0
- com_xaymar_datapath-1.0.1/bindings/node/scripts/install.js +38 -0
- com_xaymar_datapath-1.0.1/bindings/node/scripts/prebuild.js +38 -0
- com_xaymar_datapath-1.0.1/bindings/node/scripts/vendor.js +39 -0
- com_xaymar_datapath-1.0.1/bindings/node/src/addon.cpp +745 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/bench.mjs +133 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/datapath.test.js +197 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/fixtures/throwing-listener.js +33 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/fixtures/unref.js +21 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/fixtures/worker.js +37 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/tsconfig.json +11 -0
- com_xaymar_datapath-1.0.1/bindings/node/test/types.test.ts +37 -0
- com_xaymar_datapath-1.0.1/bindings/rust/.gitignore +5 -0
- com_xaymar_datapath-1.0.1/bindings/rust/Cargo.lock +48 -0
- com_xaymar_datapath-1.0.1/bindings/rust/Cargo.toml +14 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/Cargo.toml +20 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/README.md +48 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/examples/echo.rs +47 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/callback.rs +98 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/context.rs +70 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/error.rs +128 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/lib.rs +66 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/options.rs +204 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/server.rs +97 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/src/socket.rs +215 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath/tests/integration.rs +262 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath-sys/Cargo.toml +24 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath-sys/README.md +14 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath-sys/build.rs +103 -0
- com_xaymar_datapath-1.0.1/bindings/rust/datapath-sys/src/lib.rs +204 -0
- com_xaymar_datapath-1.0.1/bindings/rust/package.sh +26 -0
- com_xaymar_datapath-1.0.1/cmake/datapath-config.cmake.in +23 -0
- com_xaymar_datapath-1.0.1/cmake/datapath.pc.in +12 -0
- com_xaymar_datapath-1.0.1/cmake/export.h.in +34 -0
- com_xaymar_datapath-1.0.1/cmake/toolchains/mingw-w64.cmake +18 -0
- com_xaymar_datapath-1.0.1/cmake/toolchains/wine-run.sh +7 -0
- com_xaymar_datapath-1.0.1/cmake/version.hpp.in +39 -0
- com_xaymar_datapath-1.0.1/include/datapath/context.hpp +47 -0
- com_xaymar_datapath-1.0.1/include/datapath/datapath.h +263 -0
- com_xaymar_datapath-1.0.1/include/datapath/datapath.hpp +30 -0
- com_xaymar_datapath-1.0.1/include/datapath/error.hpp +39 -0
- com_xaymar_datapath-1.0.1/include/datapath/options.hpp +122 -0
- com_xaymar_datapath-1.0.1/include/datapath/permissions.hpp +21 -0
- com_xaymar_datapath-1.0.1/include/datapath/server.hpp +45 -0
- com_xaymar_datapath-1.0.1/include/datapath/socket.hpp +66 -0
- com_xaymar_datapath-1.0.1/pyproject.toml +95 -0
- com_xaymar_datapath-1.0.1/python/CMakeLists.txt +66 -0
- com_xaymar_datapath-1.0.1/python/README.md +76 -0
- com_xaymar_datapath-1.0.1/python/benchmarks/pingpong.py +191 -0
- com_xaymar_datapath-1.0.1/python/datapath/__init__.py +63 -0
- com_xaymar_datapath-1.0.1/python/datapath/_errors.py +73 -0
- com_xaymar_datapath-1.0.1/python/src/module.cpp +1119 -0
- com_xaymar_datapath-1.0.1/python/tests/test_datapath.py +419 -0
- com_xaymar_datapath-1.0.1/source/common/api.cpp +177 -0
- com_xaymar_datapath-1.0.1/source/common/c_api.cpp +426 -0
- com_xaymar_datapath-1.0.1/source/common/compat.hpp +199 -0
- com_xaymar_datapath-1.0.1/source/common/connection_base.hpp +233 -0
- com_xaymar_datapath-1.0.1/source/common/detail.hpp +59 -0
- com_xaymar_datapath-1.0.1/source/common/endian.hpp +36 -0
- com_xaymar_datapath-1.0.1/source/common/framing.hpp +194 -0
- com_xaymar_datapath-1.0.1/source/common/handshake.hpp +112 -0
- com_xaymar_datapath-1.0.1/source/common/send_queue.cpp +211 -0
- com_xaymar_datapath-1.0.1/source/common/send_queue.hpp +74 -0
- com_xaymar_datapath-1.0.1/source/common/shm_ring.cpp +342 -0
- com_xaymar_datapath-1.0.1/source/common/shm_ring.hpp +171 -0
- com_xaymar_datapath-1.0.1/source/common/spin.hpp +51 -0
- com_xaymar_datapath-1.0.1/source/posix/event_context.cpp +530 -0
- com_xaymar_datapath-1.0.1/source/posix/event_context.hpp +146 -0
- com_xaymar_datapath-1.0.1/source/posix/event_loop_epoll.cpp +126 -0
- com_xaymar_datapath-1.0.1/source/posix/event_loop_kqueue.cpp +129 -0
- com_xaymar_datapath-1.0.1/source/posix/path.cpp +41 -0
- com_xaymar_datapath-1.0.1/source/posix/path.hpp +25 -0
- com_xaymar_datapath-1.0.1/source/posix/platform.hpp +55 -0
- com_xaymar_datapath-1.0.1/source/posix/platform_apple.cpp +111 -0
- com_xaymar_datapath-1.0.1/source/posix/platform_linux.cpp +104 -0
- com_xaymar_datapath-1.0.1/source/posix/shm.cpp +274 -0
- com_xaymar_datapath-1.0.1/source/posix/shm.hpp +98 -0
- com_xaymar_datapath-1.0.1/source/posix/uds_connection.cpp +597 -0
- com_xaymar_datapath-1.0.1/source/posix/uds_connection.hpp +119 -0
- com_xaymar_datapath-1.0.1/source/posix/uds_server.cpp +260 -0
- com_xaymar_datapath-1.0.1/source/posix/uds_server.hpp +61 -0
- com_xaymar_datapath-1.0.1/source/windows/iocp_context.cpp +748 -0
- com_xaymar_datapath-1.0.1/source/windows/iocp_context.hpp +148 -0
- com_xaymar_datapath-1.0.1/source/windows/path.cpp +33 -0
- com_xaymar_datapath-1.0.1/source/windows/path.hpp +15 -0
- com_xaymar_datapath-1.0.1/source/windows/pipe_connection.cpp +594 -0
- com_xaymar_datapath-1.0.1/source/windows/pipe_connection.hpp +134 -0
- com_xaymar_datapath-1.0.1/source/windows/pipe_server.cpp +250 -0
- com_xaymar_datapath-1.0.1/source/windows/pipe_server.hpp +67 -0
- com_xaymar_datapath-1.0.1/source/windows/security.cpp +61 -0
- com_xaymar_datapath-1.0.1/source/windows/security.hpp +20 -0
- com_xaymar_datapath-1.0.1/source/windows/shm.cpp +391 -0
- com_xaymar_datapath-1.0.1/source/windows/shm.hpp +98 -0
- com_xaymar_datapath-1.0.1/source/windows/win.hpp +45 -0
- com_xaymar_datapath-1.0.1/website/build.py +492 -0
- com_xaymar_datapath-1.0.1/website/content/index.html +128 -0
- com_xaymar_datapath-1.0.1/website/content/start.html +184 -0
- com_xaymar_datapath-1.0.1/website/requirements.txt +2 -0
- com_xaymar_datapath-1.0.1/website/static/chart.js +265 -0
- com_xaymar_datapath-1.0.1/website/static/favicon.svg +1 -0
- com_xaymar_datapath-1.0.1/website/static/site.js +64 -0
- com_xaymar_datapath-1.0.1/website/static/style.css +379 -0
- com_xaymar_datapath-1.0.1/website/templates/page.html +53 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Basic Formatting
|
|
2
|
+
TabWidth: 4
|
|
3
|
+
UseTab: ForContinuationAndIndentation
|
|
4
|
+
ColumnLimit: 120
|
|
5
|
+
|
|
6
|
+
# Language
|
|
7
|
+
Language: Cpp
|
|
8
|
+
Standard: Cpp11
|
|
9
|
+
|
|
10
|
+
# Indentation
|
|
11
|
+
AccessModifierOffset: 0
|
|
12
|
+
ConstructorInitializerIndentWidth: 4
|
|
13
|
+
ContinuationIndentWidth: 4
|
|
14
|
+
IndentCaseLabels: false
|
|
15
|
+
#IndentPPDirectives: true
|
|
16
|
+
IndentWidth: 4
|
|
17
|
+
IndentWrappedFunctionNames: true
|
|
18
|
+
NamespaceIndentation: All
|
|
19
|
+
|
|
20
|
+
# Includes
|
|
21
|
+
#IncludeBlocks: Regroup
|
|
22
|
+
IncludeCategories:
|
|
23
|
+
- Regex: '^<'
|
|
24
|
+
Priority: 1
|
|
25
|
+
- Regex: '^"'
|
|
26
|
+
Priority: 2
|
|
27
|
+
SortIncludes: true
|
|
28
|
+
|
|
29
|
+
# Alignment
|
|
30
|
+
AlignAfterOpenBracket: true
|
|
31
|
+
AlignConsecutiveAssignments: true
|
|
32
|
+
AlignConsecutiveDeclarations: true
|
|
33
|
+
AlignEscapedNewlines: Left
|
|
34
|
+
AlignOperands: true
|
|
35
|
+
AlignTrailingComments: true
|
|
36
|
+
DerivePointerAlignment: false
|
|
37
|
+
PointerAlignment: Left
|
|
38
|
+
|
|
39
|
+
# Wrapping and Breaking
|
|
40
|
+
AllowAllParametersOfDeclarationOnNextLine: true
|
|
41
|
+
AllowShortBlocksOnASingleLine: false
|
|
42
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
43
|
+
AllowShortFunctionsOnASingleLine: Empty
|
|
44
|
+
AllowShortIfStatementsOnASingleLine: false
|
|
45
|
+
AllowShortLoopsOnASingleLine: false
|
|
46
|
+
AlwaysBreakAfterReturnType: None
|
|
47
|
+
AlwaysBreakBeforeMultilineStrings: true
|
|
48
|
+
AlwaysBreakTemplateDeclarations: true
|
|
49
|
+
BraceWrapping:
|
|
50
|
+
AfterClass: false
|
|
51
|
+
AfterControlStatement: false
|
|
52
|
+
AfterEnum: false
|
|
53
|
+
# AfterExternBlock: false
|
|
54
|
+
AfterFunction: true
|
|
55
|
+
AfterNamespace: false
|
|
56
|
+
AfterStruct: false
|
|
57
|
+
AfterUnion: false
|
|
58
|
+
BeforeCatch: false
|
|
59
|
+
BeforeElse: false
|
|
60
|
+
SplitEmptyFunction: false
|
|
61
|
+
SplitEmptyRecord: false
|
|
62
|
+
SplitEmptyNamespace: false
|
|
63
|
+
BinPackArguments: true
|
|
64
|
+
BinPackParameters: true
|
|
65
|
+
BreakBeforeBinaryOperators: NonAssignment
|
|
66
|
+
BreakBeforeBraces: Custom
|
|
67
|
+
BreakBeforeTernaryOperators: true
|
|
68
|
+
BreakConstructorInitializers: BeforeColon
|
|
69
|
+
#BreakInheritanceList: BeforeColon
|
|
70
|
+
BreakStringLiterals: true
|
|
71
|
+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
|
72
|
+
Cpp11BracedListStyle: true
|
|
73
|
+
|
|
74
|
+
# Spaces
|
|
75
|
+
SpaceAfterCStyleCast: false
|
|
76
|
+
SpaceAfterTemplateKeyword: false
|
|
77
|
+
SpaceBeforeAssignmentOperators: true
|
|
78
|
+
#SpaceBeforeCpp11BracedList: false
|
|
79
|
+
#SpaceBeforeCtorInitializerColon: true
|
|
80
|
+
#SpaceBeforeInheritanceColon: true
|
|
81
|
+
SpaceBeforeParens: ControlStatements
|
|
82
|
+
#SpaceBeforeRangeBasedForLoopColon: true
|
|
83
|
+
SpaceInEmptyParentheses: false
|
|
84
|
+
SpacesBeforeTrailingComments: 1
|
|
85
|
+
SpacesInAngles: false
|
|
86
|
+
SpacesInCStyleCastParentheses: false
|
|
87
|
+
SpacesInContainerLiterals: false
|
|
88
|
+
SpacesInParentheses: false
|
|
89
|
+
SpacesInSquareBrackets: false
|
|
90
|
+
|
|
91
|
+
# Other
|
|
92
|
+
CommentPragmas: '^(!FIXME!|!TODO!|ToDo:)'
|
|
93
|
+
CompactNamespaces: true
|
|
94
|
+
DisableFormat: false
|
|
95
|
+
FixNamespaceComments: true
|
|
96
|
+
#ForEachMacros: ''
|
|
97
|
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
98
|
+
ReflowComments: false
|
|
99
|
+
SortUsingDeclarations: true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Narta Xaymar Dirks <info@xaymar.com>
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Low Latency IPC Library for high-speed traffic
|
|
2
|
+
# Copyright (C) 2019 - 2026 Narta Xaymar Dirks <info@xaymar.com>
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.16)
|
|
7
|
+
|
|
8
|
+
# Semantic Versioning (https://semver.org): bump MAJOR on any API- or
|
|
9
|
+
# ABI-incompatible change, MINOR on compatible additions, PATCH on compatible
|
|
10
|
+
# fixes. Every binding and package uses this same version.
|
|
11
|
+
set(DATAPATH_VERSION_MAJOR 1)
|
|
12
|
+
set(DATAPATH_VERSION_MINOR 0)
|
|
13
|
+
set(DATAPATH_VERSION_PATCH 1)
|
|
14
|
+
if(DATAPATH_VERSION_MAJOR GREATER 255 OR DATAPATH_VERSION_MINOR GREATER 65535 OR DATAPATH_VERSION_PATCH GREATER 255)
|
|
15
|
+
message(FATAL_ERROR "DataPath: version parts must fit (major << 24) | (minor << 8) | patch")
|
|
16
|
+
endif()
|
|
17
|
+
|
|
18
|
+
project(datapath
|
|
19
|
+
VERSION ${DATAPATH_VERSION_MAJOR}.${DATAPATH_VERSION_MINOR}.${DATAPATH_VERSION_PATCH}
|
|
20
|
+
DESCRIPTION "High performance, low latency IPC library"
|
|
21
|
+
LANGUAGES C CXX
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
if("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
|
|
25
|
+
set(DATAPATH_TOPLEVEL ON)
|
|
26
|
+
else()
|
|
27
|
+
set(DATAPATH_TOPLEVEL OFF)
|
|
28
|
+
endif()
|
|
29
|
+
|
|
30
|
+
option(DATAPATH_SHARED "Build a shared library instead of a static one." OFF)
|
|
31
|
+
option(DATAPATH_BUILD_SAMPLES "Build samples and the benchmark." ${DATAPATH_TOPLEVEL})
|
|
32
|
+
option(DATAPATH_BUILD_TESTS "Build tests." ${DATAPATH_TOPLEVEL})
|
|
33
|
+
option(DATAPATH_BUILD_PYTHON "Build the Python extension module (normally driven by pyproject.toml)." OFF)
|
|
34
|
+
|
|
35
|
+
# The library builds with C++11 or newer; newer standards let it use newer
|
|
36
|
+
# standard library facilities (see source/common/compat.hpp). An explicit
|
|
37
|
+
# CMAKE_CXX_STANDARD picks the default. Tests, samples and the Python module
|
|
38
|
+
# need C++17 and use the larger of 17 and this.
|
|
39
|
+
if(DEFINED CMAKE_CXX_STANDARD)
|
|
40
|
+
set(_datapath_default_std ${CMAKE_CXX_STANDARD})
|
|
41
|
+
else()
|
|
42
|
+
set(_datapath_default_std 17)
|
|
43
|
+
endif()
|
|
44
|
+
set(DATAPATH_CXX_STANDARD ${_datapath_default_std} CACHE STRING "C++ standard the library is built with (11 or newer).")
|
|
45
|
+
set_property(CACHE DATAPATH_CXX_STANDARD PROPERTY STRINGS 11 14 17 20 23 26)
|
|
46
|
+
if(DATAPATH_CXX_STANDARD LESS 11 OR DATAPATH_CXX_STANDARD EQUAL 98)
|
|
47
|
+
message(FATAL_ERROR "DataPath: DATAPATH_CXX_STANDARD must be 11 or newer, got ${DATAPATH_CXX_STANDARD}")
|
|
48
|
+
endif()
|
|
49
|
+
if(DATAPATH_CXX_STANDARD LESS 17)
|
|
50
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
51
|
+
else()
|
|
52
|
+
set(CMAKE_CXX_STANDARD ${DATAPATH_CXX_STANDARD})
|
|
53
|
+
endif()
|
|
54
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
55
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
56
|
+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
57
|
+
set(CMAKE_BUILD_TYPE Release)
|
|
58
|
+
endif()
|
|
59
|
+
|
|
60
|
+
configure_file(
|
|
61
|
+
"${PROJECT_SOURCE_DIR}/cmake/version.hpp.in"
|
|
62
|
+
"${PROJECT_BINARY_DIR}/generated/include/datapath/version.hpp"
|
|
63
|
+
@ONLY
|
|
64
|
+
)
|
|
65
|
+
if(DATAPATH_SHARED)
|
|
66
|
+
set(DATAPATH_BUILT_STATIC 0)
|
|
67
|
+
else()
|
|
68
|
+
set(DATAPATH_BUILT_STATIC 1)
|
|
69
|
+
endif()
|
|
70
|
+
configure_file(
|
|
71
|
+
"${PROJECT_SOURCE_DIR}/cmake/export.h.in"
|
|
72
|
+
"${PROJECT_BINARY_DIR}/generated/include/datapath/export.h"
|
|
73
|
+
@ONLY
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
set(DATAPATH_PUBLIC_HEADERS
|
|
77
|
+
"${PROJECT_BINARY_DIR}/generated/include/datapath/export.h"
|
|
78
|
+
"${PROJECT_BINARY_DIR}/generated/include/datapath/version.hpp"
|
|
79
|
+
include/datapath/context.hpp
|
|
80
|
+
include/datapath/datapath.h
|
|
81
|
+
include/datapath/datapath.hpp
|
|
82
|
+
include/datapath/error.hpp
|
|
83
|
+
include/datapath/options.hpp
|
|
84
|
+
include/datapath/permissions.hpp
|
|
85
|
+
include/datapath/server.hpp
|
|
86
|
+
include/datapath/socket.hpp
|
|
87
|
+
)
|
|
88
|
+
set(DATAPATH_SOURCES
|
|
89
|
+
source/common/api.cpp
|
|
90
|
+
source/common/c_api.cpp
|
|
91
|
+
source/common/connection_base.hpp
|
|
92
|
+
source/common/detail.hpp
|
|
93
|
+
source/common/endian.hpp
|
|
94
|
+
source/common/framing.hpp
|
|
95
|
+
source/common/handshake.hpp
|
|
96
|
+
source/common/send_queue.cpp
|
|
97
|
+
source/common/send_queue.hpp
|
|
98
|
+
source/common/shm_ring.cpp
|
|
99
|
+
source/common/shm_ring.hpp
|
|
100
|
+
source/common/spin.hpp
|
|
101
|
+
)
|
|
102
|
+
if(WIN32)
|
|
103
|
+
list(APPEND DATAPATH_SOURCES
|
|
104
|
+
source/windows/iocp_context.cpp
|
|
105
|
+
source/windows/iocp_context.hpp
|
|
106
|
+
source/windows/path.cpp
|
|
107
|
+
source/windows/path.hpp
|
|
108
|
+
source/windows/pipe_connection.cpp
|
|
109
|
+
source/windows/pipe_connection.hpp
|
|
110
|
+
source/windows/pipe_server.cpp
|
|
111
|
+
source/windows/pipe_server.hpp
|
|
112
|
+
source/windows/security.cpp
|
|
113
|
+
source/windows/security.hpp
|
|
114
|
+
source/windows/shm.cpp
|
|
115
|
+
source/windows/shm.hpp
|
|
116
|
+
source/windows/win.hpp
|
|
117
|
+
)
|
|
118
|
+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR ANDROID OR APPLE)
|
|
119
|
+
# One backend for Unix domain sockets; the poller and the OS-specific parts
|
|
120
|
+
# (sockets flags, thread priority, core count) differ.
|
|
121
|
+
list(APPEND DATAPATH_SOURCES
|
|
122
|
+
source/posix/event_context.cpp
|
|
123
|
+
source/posix/event_context.hpp
|
|
124
|
+
source/posix/path.cpp
|
|
125
|
+
source/posix/path.hpp
|
|
126
|
+
source/posix/platform.hpp
|
|
127
|
+
source/posix/shm.cpp
|
|
128
|
+
source/posix/shm.hpp
|
|
129
|
+
source/posix/uds_connection.cpp
|
|
130
|
+
source/posix/uds_connection.hpp
|
|
131
|
+
source/posix/uds_server.cpp
|
|
132
|
+
source/posix/uds_server.hpp
|
|
133
|
+
)
|
|
134
|
+
if(APPLE)
|
|
135
|
+
list(APPEND DATAPATH_SOURCES
|
|
136
|
+
source/posix/event_loop_kqueue.cpp
|
|
137
|
+
source/posix/platform_apple.cpp
|
|
138
|
+
)
|
|
139
|
+
else()
|
|
140
|
+
list(APPEND DATAPATH_SOURCES
|
|
141
|
+
source/posix/event_loop_epoll.cpp
|
|
142
|
+
source/posix/platform_linux.cpp
|
|
143
|
+
)
|
|
144
|
+
endif()
|
|
145
|
+
else()
|
|
146
|
+
message(FATAL_ERROR "DataPath: unsupported platform ${CMAKE_SYSTEM_NAME}")
|
|
147
|
+
endif()
|
|
148
|
+
|
|
149
|
+
# Everything is compiled once into datapath_objects. The library is built from
|
|
150
|
+
# those objects; so is datapath_internal, which the unit tests link to reach
|
|
151
|
+
# internals that a shared library does not export.
|
|
152
|
+
add_library(datapath_objects OBJECT ${DATAPATH_PUBLIC_HEADERS} ${DATAPATH_SOURCES})
|
|
153
|
+
target_include_directories(datapath_objects
|
|
154
|
+
PUBLIC
|
|
155
|
+
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
|
156
|
+
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/generated/include>"
|
|
157
|
+
PRIVATE
|
|
158
|
+
"${PROJECT_SOURCE_DIR}/source"
|
|
159
|
+
)
|
|
160
|
+
# Only symbols marked DATAPATH_API (include/datapath/export.h) are exported.
|
|
161
|
+
target_compile_definitions(datapath_objects PRIVATE DATAPATH_BUILDING)
|
|
162
|
+
set_target_properties(datapath_objects PROPERTIES
|
|
163
|
+
CXX_STANDARD ${DATAPATH_CXX_STANDARD}
|
|
164
|
+
CXX_VISIBILITY_PRESET hidden
|
|
165
|
+
VISIBILITY_INLINES_HIDDEN ON
|
|
166
|
+
POSITION_INDEPENDENT_CODE ON
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
if(MSVC)
|
|
170
|
+
target_compile_options(datapath_objects PRIVATE /W4 /permissive- /Zc:__cplusplus /utf-8)
|
|
171
|
+
else()
|
|
172
|
+
target_compile_options(datapath_objects PRIVATE -Wall -Wextra -Wpedantic)
|
|
173
|
+
endif()
|
|
174
|
+
|
|
175
|
+
if(WIN32)
|
|
176
|
+
target_compile_definitions(datapath_objects PRIVATE
|
|
177
|
+
WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE _WIN32_WINNT=0x0A00
|
|
178
|
+
)
|
|
179
|
+
set(DATAPATH_PLATFORM_LIBS advapi32 kernel32)
|
|
180
|
+
else()
|
|
181
|
+
find_package(Threads REQUIRED)
|
|
182
|
+
set(DATAPATH_PLATFORM_LIBS Threads::Threads)
|
|
183
|
+
endif()
|
|
184
|
+
target_link_libraries(datapath_objects PRIVATE ${DATAPATH_PLATFORM_LIBS})
|
|
185
|
+
|
|
186
|
+
if(DATAPATH_SHARED)
|
|
187
|
+
add_library(datapath SHARED $<TARGET_OBJECTS:datapath_objects>)
|
|
188
|
+
target_link_libraries(datapath PRIVATE ${DATAPATH_PLATFORM_LIBS})
|
|
189
|
+
else()
|
|
190
|
+
add_library(datapath STATIC $<TARGET_OBJECTS:datapath_objects>)
|
|
191
|
+
# A static library carries its dependencies to whoever links it.
|
|
192
|
+
target_link_libraries(datapath PUBLIC ${DATAPATH_PLATFORM_LIBS})
|
|
193
|
+
endif()
|
|
194
|
+
add_library(datapath::datapath ALIAS datapath)
|
|
195
|
+
set_target_properties(datapath PROPERTIES CXX_STANDARD ${DATAPATH_CXX_STANDARD})
|
|
196
|
+
# The public C++ headers need C++11.
|
|
197
|
+
target_compile_features(datapath INTERFACE cxx_std_11)
|
|
198
|
+
target_sources(datapath PRIVATE ${DATAPATH_PUBLIC_HEADERS})
|
|
199
|
+
|
|
200
|
+
target_include_directories(datapath
|
|
201
|
+
PUBLIC
|
|
202
|
+
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
|
203
|
+
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/generated/include>"
|
|
204
|
+
"$<INSTALL_INTERFACE:include>"
|
|
205
|
+
)
|
|
206
|
+
set_target_properties(datapath PROPERTIES
|
|
207
|
+
VERSION ${DATAPATH_VERSION_MAJOR}.${DATAPATH_VERSION_MINOR}.${DATAPATH_VERSION_PATCH}
|
|
208
|
+
SOVERSION ${DATAPATH_VERSION_MAJOR}
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
if(MINGW)
|
|
212
|
+
# Self-contained executables (no libstdc++/winpthread DLLs needed under Wine or on Windows).
|
|
213
|
+
target_link_options(datapath PUBLIC -static -static-libgcc -static-libstdc++)
|
|
214
|
+
endif()
|
|
215
|
+
|
|
216
|
+
include(GNUInstallDirs)
|
|
217
|
+
install(TARGETS datapath EXPORT datapath-targets
|
|
218
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
219
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
220
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
221
|
+
)
|
|
222
|
+
install(DIRECTORY include/datapath DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
223
|
+
install(FILES
|
|
224
|
+
"${PROJECT_BINARY_DIR}/generated/include/datapath/export.h"
|
|
225
|
+
"${PROJECT_BINARY_DIR}/generated/include/datapath/version.hpp"
|
|
226
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/datapath
|
|
227
|
+
)
|
|
228
|
+
set(DATAPATH_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/datapath")
|
|
229
|
+
install(EXPORT datapath-targets NAMESPACE datapath:: DESTINATION ${DATAPATH_CMAKE_DIR})
|
|
230
|
+
|
|
231
|
+
# find_package(datapath) support: config + version file. SameMajorVersion is
|
|
232
|
+
# SemVer: any 1.x satisfies a request for 1.y with x >= y.
|
|
233
|
+
include(CMakePackageConfigHelpers)
|
|
234
|
+
configure_package_config_file(
|
|
235
|
+
"${PROJECT_SOURCE_DIR}/cmake/datapath-config.cmake.in"
|
|
236
|
+
"${PROJECT_BINARY_DIR}/datapath-config.cmake"
|
|
237
|
+
INSTALL_DESTINATION ${DATAPATH_CMAKE_DIR}
|
|
238
|
+
)
|
|
239
|
+
write_basic_package_version_file(
|
|
240
|
+
"${PROJECT_BINARY_DIR}/datapath-config-version.cmake"
|
|
241
|
+
VERSION ${PROJECT_VERSION}
|
|
242
|
+
COMPATIBILITY SameMajorVersion
|
|
243
|
+
)
|
|
244
|
+
install(FILES
|
|
245
|
+
"${PROJECT_BINARY_DIR}/datapath-config.cmake"
|
|
246
|
+
"${PROJECT_BINARY_DIR}/datapath-config-version.cmake"
|
|
247
|
+
DESTINATION ${DATAPATH_CMAKE_DIR}
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# pkg-config, for non-CMake builds. A static library also needs the C++
|
|
251
|
+
# runtime and threads when it is linked into a C program.
|
|
252
|
+
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
|
253
|
+
set(DATAPATH_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
|
|
254
|
+
else()
|
|
255
|
+
set(DATAPATH_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
|
256
|
+
endif()
|
|
257
|
+
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
258
|
+
set(DATAPATH_PC_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
259
|
+
else()
|
|
260
|
+
set(DATAPATH_PC_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
|
261
|
+
endif()
|
|
262
|
+
set(DATAPATH_PC_LIBS_PRIVATE "")
|
|
263
|
+
if(WIN32)
|
|
264
|
+
set(DATAPATH_PC_LIBS_PRIVATE "-ladvapi32 -lkernel32")
|
|
265
|
+
else()
|
|
266
|
+
if(APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND "c++" IN_LIST CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
|
|
267
|
+
set(DATAPATH_PC_LIBS_PRIVATE "-lc++")
|
|
268
|
+
else()
|
|
269
|
+
set(DATAPATH_PC_LIBS_PRIVATE "-lstdc++")
|
|
270
|
+
endif()
|
|
271
|
+
string(APPEND DATAPATH_PC_LIBS_PRIVATE " -pthread")
|
|
272
|
+
endif()
|
|
273
|
+
configure_file("${PROJECT_SOURCE_DIR}/cmake/datapath.pc.in" "${PROJECT_BINARY_DIR}/datapath.pc" @ONLY)
|
|
274
|
+
install(FILES "${PROJECT_BINARY_DIR}/datapath.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
275
|
+
install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/datapath)
|
|
276
|
+
|
|
277
|
+
if(DATAPATH_BUILD_TESTS)
|
|
278
|
+
enable_testing()
|
|
279
|
+
add_subdirectory(tests)
|
|
280
|
+
endif()
|
|
281
|
+
if(DATAPATH_BUILD_PYTHON)
|
|
282
|
+
add_subdirectory(python)
|
|
283
|
+
endif()
|
|
284
|
+
if(DATAPATH_BUILD_SAMPLES AND EXISTS "${PROJECT_SOURCE_DIR}/samples/CMakeLists.txt")
|
|
285
|
+
add_subdirectory(samples)
|
|
286
|
+
endif()
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Contributing to DataPath
|
|
2
|
+
Thanks for helping out. This file covers building, testing and benchmarking DataPath. For what the library does and how to use it, see [README.md](README.md).
|
|
3
|
+
|
|
4
|
+
## Building
|
|
5
|
+
Requires CMake 3.16+ and a C++17 compiler (MSVC 2019+, GCC 9+, Clang 10+) for the tests and samples. The library itself builds with C++11 or newer (C++14 or newer on MSVC).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
|
9
|
+
```
|
|
10
|
+
```bash
|
|
11
|
+
cmake --build build --config Release
|
|
12
|
+
```
|
|
13
|
+
```bash
|
|
14
|
+
ctest --test-dir build -C Release --output-on-failure
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Options: `DATAPATH_SHARED` (shared library, default `OFF`), `DATAPATH_CXX_STANDARD` (standard the library is built with, default 17 or `CMAKE_CXX_STANDARD`; tests and samples use at least 17), `DATAPATH_BUILD_TESTS` and `DATAPATH_BUILD_SAMPLES` (default `ON` for top-level builds). The `datapath::datapath` target can be used through `add_subdirectory`.
|
|
18
|
+
|
|
19
|
+
Library code (`include/`, `source/`) must build as C++11. When a newer standard library facility helps, use it through `source/common/compat.hpp`, which picks it by feature-test macro (`__cpp_lib_*`) and falls back to a local equivalent; CI builds the library as C++11, C++14 (MSVC) and C++23. Tests, samples and bindings may use C++17.
|
|
20
|
+
|
|
21
|
+
The shared library exports only what public headers mark with `DATAPATH_API` (from the generated `datapath/export.h`); everything else stays hidden. Mark any new public function or class with it. Tests that reach into internals (`source/`) pass `INTERNAL` to `datapath_add_test` so they still link in a shared build.
|
|
22
|
+
|
|
23
|
+
Cross-compiling for Windows from Linux with mingw-w64 (tests run through Wine if it's installed):
|
|
24
|
+
```bash
|
|
25
|
+
cmake -S . -B build-mingw -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
Run the whole suite with `ctest` as shown above before sending a change. Unix-only and Windows-only tests (`tests/test_posix.cpp` for Linux and macOS, `tests/test_windows_security.cpp`) build only on their platforms, so a change to a platform backend should be tested on that platform. On Linux, an AddressSanitizer build catches most lifetime bugs in the handler and close paths:
|
|
30
|
+
```bash
|
|
31
|
+
cmake -S . -B build-asan -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Benchmarking
|
|
35
|
+
`datapath-benchmark local` starts an echo server in a second process and runs the client against it:
|
|
36
|
+
```bash
|
|
37
|
+
./build/samples/datapath-benchmark local
|
|
38
|
+
```
|
|
39
|
+
On Windows, run `build\samples\Release\datapath-benchmark.exe local`. Useful variations:
|
|
40
|
+
* `--spin 0` measures without busy-polling.
|
|
41
|
+
* `--load` adds a 1 MiB bulk stream on a second connection and reports its throughput.
|
|
42
|
+
* `--clients 8` runs eight concurrent ping-pong connections.
|
|
43
|
+
* `--threads 2` uses two I/O threads per process.
|
|
44
|
+
* `--threads auto` uses one I/O thread per physical core (`context_options::io_threads = 0`). Compare it with `--ideal-core off` on Windows to see what pairing threads with cores does.
|
|
45
|
+
* `--stress 0` loads every logical core from a separate process; on Linux, `--stress-nice N` runs that process at nice N to test the priority gap.
|
|
46
|
+
* `--pin C,S` pins the client process to logical CPU C and the server process to S. Use it with `--stress`: without it, each invocation's latency depends on where the scheduler happens to put the two I/O threads (on Irkela, 16 KiB p99.9 was 15 µs with both on the two hyper-threads of one core, ~200 µs on separate cores, and ~1.1 ms when one of them was on core 0), for DataPath and libuv alike. Each run prints which CPUs handled the messages (`cpus` lines).
|
|
47
|
+
* `--sizes 8,64,4096` picks the message sizes. The default is 8 B to 64 KiB; add `1048576,16777216` to measure bulk-sized messages.
|
|
48
|
+
|
|
49
|
+
You can also run `server <name>` and `client <name>` separately, in two terminals.
|
|
50
|
+
|
|
51
|
+
Single runs are noisy at microsecond resolution. `--runs 5` repeats every size five times and reports the median, plus the lowest and highest p99.9 of any run. `samples\benchmark\matrix.cmd` (Windows) and `samples/benchmark/matrix.sh` (Linux) run every option combination that way and collect the output in `benchmark-results.txt`.
|
|
52
|
+
|
|
53
|
+
`datapath-benchmark-c` is the same harness over the C API (`datapath.h`) instead of the C++ API. It accepts the same options and the matrix scripts include it when it exists. A core that only exports the C API can be compared against these runs.
|
|
54
|
+
|
|
55
|
+
For stable numbers on Windows, use the High Performance power plan. Run from a foreground console and close CPU-heavy applications.
|
|
56
|
+
|
|
57
|
+
### Comparing with libuv, cpp-ipc and Boost.Interprocess
|
|
58
|
+
Configure with `-DDATAPATH_BUILD_COMPARE=ON` to also build `libuv-benchmark`; CMake downloads libuv 1.52.1. It runs the same harness over libuv named pipes / Unix sockets: same framing, clock, sizes, `--runs`, `--stress`. It also uses the same `--spin`, `--priority` and `--mmcss` policy on its loop thread, so both libraries can be compared with identical settings. libuv itself has none of these, so use `--spin 0 --no-mmcss --priority 0` to measure libuv as it ships. The matrix scripts include libuv runs when the executable exists.
|
|
59
|
+
|
|
60
|
+
The same option also builds `cppipc-benchmark` ([cpp-ipc](https://github.com/mutouyun/cpp-ipc), pinned commit) and `boost-benchmark` (Boost.Interprocess `message_queue`; an installed Boost 1.80+ is used if CMake finds one, otherwise Boost 1.92 is downloaded). On Windows, `boost-native-benchmark` is the same with `BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION`, Windows kernel primitives instead of Boost's default spin-lock emulation. They take the same options; `--spin 0 --no-mmcss --priority 0` measures each library's own waiting, the defaults add DataPath's spin and priority to the receive thread. cpp-ipc and Boost keep named shared-memory objects (`/dev/shm` on Linux, `C:\ProgramData\boost_interprocess` for Boost on Windows); the benchmarks remove theirs on exit, but a killed run leaves them behind.
|
|
61
|
+
|
|
62
|
+
When you report numbers, lead with p99.9, say which machine, OS and power plan they came from, and give the flags. A p50 improvement that costs tail latency is a regression for this project. Published numbers use worst-case placement: `--pin` the client and server to different physical cores, on different CCDs and NUMA nodes where the machine has them ([methodology](docs/comparisons/README.md#methodology)).
|
|
63
|
+
|
|
64
|
+
## Python bindings
|
|
65
|
+
The bindings live in `python/` (nanobind, built by scikit-build-core from `pyproject.toml` in the repository root). Build and test them with:
|
|
66
|
+
```bash
|
|
67
|
+
pip install . pytest
|
|
68
|
+
```
|
|
69
|
+
```bash
|
|
70
|
+
pytest python/tests
|
|
71
|
+
```
|
|
72
|
+
For quicker iteration, configure CMake with `-DDATAPATH_BUILD_PYTHON=ON`; the build tree then has an importable package in `build/python/package`, so `PYTHONPATH=build/python/package pytest python/tests` tests it without installing. Release wheels are built by `.github/workflows/python.yml` with cibuildwheel (settings in `pyproject.toml`); uploads happen in `release.yml` (see Releasing).
|
|
73
|
+
|
|
74
|
+
`python/benchmarks/pingpong.py local` measures Python round trips; add `--cpp-server build/samples/datapath-benchmark` to echo from the C++ server, and `--mode callback` to receive in callbacks instead of `recv()`.
|
|
75
|
+
|
|
76
|
+
## Versioning
|
|
77
|
+
DataPath follows [Semantic Versioning](https://semver.org): MAJOR changes on any API- or ABI-incompatible change (the shared library's SOVERSION is MAJOR), MINOR on compatible additions, PATCH on compatible fixes. The version lives in `CMakeLists.txt` (`DATAPATH_VERSION_MAJOR/MINOR/PATCH`); the Python package reads it from there, and `bindings/node/package.json` and `bindings/rust/Cargo.toml` (plus the `=` dependency in `bindings/rust/datapath/Cargo.toml`) must carry the same number. Wire-protocol versions are separate and unrelated.
|
|
78
|
+
|
|
79
|
+
## Releasing
|
|
80
|
+
1. Bump the version (see Versioning) in a pull request and merge it.
|
|
81
|
+
2. Tag the merge commit `vX.Y.Z` and push the tag. `.github/workflows/release.yml` checks that every package carries that version, builds everything, runs `npm publish --dry-run`, `cargo publish --dry-run` and `twine check`, and creates a draft GitHub Release with the source tarball and prebuilt C/C++ archives (static and shared, Release and Debug).
|
|
82
|
+
3. Start `release.yml` by hand on the tag with target `test` to upload to TestPyPI first, then with target `release` to publish to PyPI, npm and crates.io. Each registry's GitHub environment (`testpypi`, `pypi`, `npm`, `crates-io`) can require approval.
|
|
83
|
+
4. Publish the draft GitHub Release. C/C++ users consume the release archives (CMake `find_package(datapath)` or pkg-config) or the tag through FetchContent; there are no vcpkg, Conan or distribution packages.
|
|
84
|
+
|
|
85
|
+
## Pull requests
|
|
86
|
+
* Keep a pull request to one change, and say in the description what you measured before and after if it touches the data path.
|
|
87
|
+
* Format C++ changes with the repository's `.clang-format`.
|
|
88
|
+
* By contributing you agree that your contribution is licensed under the project's license, the BSD 3-Clause License.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 - 2026, Narta Xaymar Dirks <info@xaymar.com>
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: com.xaymar.datapath
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Fast, predictable message passing between processes on the same machine
|
|
5
|
+
Keywords: ipc,low-latency,named-pipes,unix-sockets,messaging
|
|
6
|
+
Author-Email: Narta Xaymar Dirks <info@xaymar.com>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: MacOS
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: C++
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Topic :: System :: Networking
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Project-URL: Homepage, https://github.com/Xaymar/datapath
|
|
22
|
+
Project-URL: Source, https://github.com/Xaymar/datapath
|
|
23
|
+
Project-URL: Issues, https://github.com/Xaymar/datapath/issues
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# DataPath for Python
|
|
28
|
+
**Fast, predictable message passing between processes on the same machine.**
|
|
29
|
+
|
|
30
|
+
Python bindings for [DataPath](https://github.com/Xaymar/datapath), a C++ IPC library built for low tail latency. It moves whole, length-framed messages between one server and any number of clients, over named pipes with I/O completion ports on Windows and Unix domain sockets with epoll on Linux.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install com.xaymar.datapath
|
|
34
|
+
```
|
|
35
|
+
The distribution is called `com.xaymar.datapath` (PyPI has no namespaces); the import name is `datapath`. Wheels are built for CPython 3.10 and newer (one abi3 wheel covers 3.12+, and free-threaded 3.14t/3.15t builds run without the GIL) on Windows, Linux and macOS, x86-64 and ARM64.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
```python
|
|
39
|
+
import datapath
|
|
40
|
+
|
|
41
|
+
# Server
|
|
42
|
+
with datapath.host("my-service") as server:
|
|
43
|
+
client = server.accept() # waits for the next client
|
|
44
|
+
while True:
|
|
45
|
+
data = client.recv() # bytes; raises ClosedError when the client leaves
|
|
46
|
+
client.send(data.upper())
|
|
47
|
+
|
|
48
|
+
# Client, in another process
|
|
49
|
+
with datapath.connect("my-service") as sock:
|
|
50
|
+
sock.send(b"hello")
|
|
51
|
+
print(sock.recv(timeout=1.0)) # b'HELLO'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Callbacks instead of `recv()`/`accept()`:
|
|
55
|
+
```python
|
|
56
|
+
clients = []
|
|
57
|
+
|
|
58
|
+
def on_accept(sock: datapath.Socket) -> None:
|
|
59
|
+
clients.append(sock) # keep it, or the connection closes
|
|
60
|
+
sock.on_message(lambda data: sock.send(data)) # runs on an I/O thread
|
|
61
|
+
sock.on_close(lambda reason: clients.remove(sock))
|
|
62
|
+
|
|
63
|
+
server = datapath.host("my-service", on_accept=on_accept)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Two ways to receive
|
|
67
|
+
* **`recv()` / `accept()`**: the I/O thread copies each message into a queue without touching the interpreter. `recv()` busy-waits for `Socket.recv_spin_us` (default 50 µs) with the GIL released, then sleeps until a message arrives. Use this when your own thread drives the conversation, or when other Python threads are busy: the I/O thread never waits for the GIL, so one slow Python thread can't stall other connections.
|
|
68
|
+
* **`on_message()` / `on_accept()`**: the I/O thread takes the GIL and calls your function. This skips the hand-off between threads and had the lowest latency in our measurements (below), close to the C++ library. The catch: when another Python thread holds the GIL, the I/O thread waits for it, up to `sys.getswitchinterval()` (5 ms by default) on GIL builds. On free-threaded Python there is no such wait.
|
|
69
|
+
|
|
70
|
+
Setting `on_message` hands over any messages already queued for `recv()`, in order; `on_message(None)` switches back. While a callback is set, `recv()` raises `RuntimeError`.
|
|
71
|
+
|
|
72
|
+
## Semantics worth knowing
|
|
73
|
+
* **Messages are whole.** Each `send()` arrives as one `recv()` result or callback, never split or merged. `send()` takes any contiguous bytes-like object (`bytes`, `bytearray`, `memoryview`, NumPy arrays…); `sendv([a, b, c])` sends several parts as one message. `recv_into(buffer)` copies into your own buffer.
|
|
74
|
+
* **`send()` never blocks.** It raises `TooLargeError` above the connection's `max_message_size` (default 64 MiB, the smaller of both peers' values), `WouldBlockError` when more than `max_queued_bytes` (default 64 MiB) is waiting, and `ClosedError` after the connection closed. It's thread-safe and can be called from callbacks.
|
|
75
|
+
* **Closing.** `close()` drops unsent messages. Messages already received stay readable: `recv()` returns them, then raises `ClosedError`. `close_reason` tells why the connection ended. A peer's disconnect is noticed while the socket is receiving, which starts with the first `recv()`, `on_message()` or `on_close()`. Dropping the last reference to a socket or server closes it too, so keep accepted sockets somewhere.
|
|
76
|
+
* **The server accepts at once.** A client's `connect()` only completes once the server accepted it, so `host()` accepts every client right away and queues it for `accept()`. Pass `on_accept=` to `host()` to decide per client: returning `False` rejects it, anything else (including `None`) accepts.
|
|
77
|
+
* **Errors** derive from `datapath.DatapathError` (with the native code in `.error`) and from the closest built-in: `ClosedError` is a `ConnectionError`, `TimedOutError` a `TimeoutError`, `NotFoundError` a `FileNotFoundError`, `AccessDeniedError` a `PermissionError`, `WouldBlockError` a `BlockingIOError`, `TooLargeError` and `InvalidPathError` a `ValueError`.
|
|
78
|
+
* **Exceptions in callbacks** go to `sys.unraisablehook` (printed to stderr by default). An exception in `on_accept` rejects the client.
|
|
79
|
+
* **Contexts.** All sockets share one process-wide set of I/O threads unless you pass `context=datapath.Context(spin_us=..., io_threads=..., priority=...)`. The options are those of the C++ `context_options`; see the [main README](https://github.com/Xaymar/datapath#semantics-worth-knowing). Closing a context closes everything on it.
|
|
80
|
+
* **Paths.** A bare name maps to `\\.\pipe\<name>` on Windows and to the abstract socket `datapath.<name>` on Linux; on Linux a path starting with `/` is a filesystem socket. Access is limited to the current user unless you pass `permissions=datapath.Permissions.Group` or `World`.
|
|
81
|
+
* **Timeouts** are in seconds (`None` waits forever); waits can be interrupted with Ctrl+C. Spin settings are in microseconds.
|
|
82
|
+
|
|
83
|
+
## Latency
|
|
84
|
+
Round trip (send, echo, receive) between two Python processes, from `python/benchmarks/pingpong.py`, median of 3 runs of 20,000 round trips. Measured on 2026-11-19 in a 4-core cloud container (Intel Xeon 2.1 GHz, Linux 6.18, CPython 3.10), so absolute numbers are higher and noisier than on a desktop. p99.9 in µs:
|
|
85
|
+
|
|
86
|
+
| | 8 B | 64 B | 4 KiB | 64 KiB |
|
|
87
|
+
|---|---|---|---|---|
|
|
88
|
+
| C++ client and server (`datapath-benchmark local`) | 43.5 | 30.0 | 71.1 | 252 |
|
|
89
|
+
| Python, callbacks on both sides | 45.2 | 36.8 | 45.9 | 75 |
|
|
90
|
+
| Python, `recv()` on both sides | 187 | 247 | 217 | 642 |
|
|
91
|
+
|
|
92
|
+
With four cores, `recv()` mode has four threads spinning at once (an I/O thread and a Python thread per process), which is the oversubscription the main README warns about; expect it to do better with more cores. Run `python python/benchmarks/pingpong.py local --help` to measure your own machine, including against the C++ echo server (`--cpp-server`).
|
|
93
|
+
|
|
94
|
+
## Building from source
|
|
95
|
+
```bash
|
|
96
|
+
pip install . # from a checkout of the repository
|
|
97
|
+
pip install pytest && pytest python/tests
|
|
98
|
+
```
|
|
99
|
+
This needs CMake 3.16+ and a C++17 compiler; scikit-build-core and nanobind are fetched automatically.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
BSD 3-Clause License. Copyright (c) 2017 - 2026, Narta Xaymar Dirks.
|