Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
0cc2730
Rust client
dallison Sep 23, 2025
81b0907
Protobuf 21.7
dallison Sep 23, 2025
cfad077
Improve ability to import to other bazel repos as module
dallison Sep 24, 2025
11d5220
Remove rust and add some warning options
dallison Sep 25, 2025
d373f0f
Use _ instead of __ for header guard macros
dallison Sep 25, 2025
c96d0f1
Underscore followed by upper case is a reserved identifier
dallison Sep 25, 2025
c762fe8
Add some missing functionality from cruise
Sep 26, 2025
74c6bfa
Modernize coroutine usage and add plugins
Oct 7, 2025
39444ed
Expose some server function to plugins
Oct 7, 2025
cbe630d
Add changes for Cruise import
Oct 8, 2025
1ef18f6
New coroutine library layout
Oct 8, 2025
86f97f8
A few more functions from Cruise
Oct 9, 2025
68e2532
More Cruise features
Oct 11, 2025
d0afdd2
Mostly working
Oct 13, 2025
c062eae
More cruise fixes and features
Oct 14, 2025
351939c
Minor fixes
Oct 15, 2025
77ef52d
stats and virtual memory from client
Oct 15, 2025
fe5b441
Update v2 doc
Oct 16, 2025
959e1fe
Coroutines 2.1.6
Oct 16, 2025
4897ea8
New toolbelt and workaround for bazel issues
Oct 20, 2025
6bade62
New toolbelt
dallison Oct 26, 2025
35e93b1
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Oct 26, 2025
25e0eb8
New toolbelt and co archives
Oct 28, 2025
3bc6ce6
Fix a test and add a few accessors for prefix
Oct 29, 2025
66edc95
Use commits for co and toolbelt
Oct 29, 2025
3013e67
Fix sha typo
Oct 29, 2025
8c21b21
Merge remote-tracking branch 'origin/main' into import_fixesx
Oct 29, 2025
193b19f
A few fixes for asan etc.
Oct 29, 2025
d237302
Call OnReady even when there is no notify fd
Oct 31, 2025
26e0ee8
Allow resizes of channel directory and stats channels
Nov 3, 2025
672ec85
Improve performance of muxes
Nov 4, 2025
53250dd
More test coverage
Nov 4, 2025
73877c1
Fix placeholder checks
Nov 7, 2025
1361f7f
Add free_slots bitset to CCB
Nov 7, 2025
ee6abe6
Add atomic free_slots_exhausted variable
Nov 8, 2025
e4f9368
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Nov 8, 2025
28d432d
Fix virtual overrides
dallison Nov 8, 2025
2da66c7
Add optional thread safety to client.
Nov 10, 2025
23764bb
Add 'lock' parameter to GetMessageBuffer
Nov 11, 2025
52443d2
Fix cast
dallison Nov 15, 2025
185d248
Add send_server_channels boolean
Nov 21, 2025
5081171
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
Nov 21, 2025
98a6f7c
Fix pub and sub moves
Nov 24, 2025
e7bddbc
Move callback lambdas on pub/sub move
Nov 24, 2025
d91079b
Fix callbacks
Nov 24, 2025
283c441
Fix callback moves again
Nov 25, 2025
99da7b3
Add checksums and buffer file ownership
Nov 26, 2025
99d9fad
Formatting
Nov 26, 2025
878050a
Intrinsic crc32 checksums
dallison Nov 27, 2025
66df567
Remove comment
dallison Nov 27, 2025
c8d8d19
Add macro to disable hardware CRC
dallison Nov 27, 2025
1c8b651
Add ARM CRC32 function
dallison Nov 28, 2025
f0caf4e
Intel crc
dallison Nov 28, 2025
32c4ffb
Minor changes to ARM checksum
dallison Nov 28, 2025
1c0f32b
Detect CRC support on ARM
Dec 1, 2025
87fcaa4
Fix cmake build
Dec 3, 2025
c4f6915
Update README.md
Dec 3, 2025
0ec78f6
Coroutines 3.0.0
dallison Dec 5, 2025
70fb9d6
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Dec 5, 2025
4342c0a
Fix UB when deleting virtual channels
dallison Dec 17, 2025
41031ca
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Dec 17, 2025
204cd19
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Dec 17, 2025
fdbb7e3
New abseil and fix a UB bug
dallison Dec 17, 2025
ac6c2af
New co and toolbelt
Dec 17, 2025
a11bbf0
Make Posix memory alloatio
dallison Jan 12, 2026
7832925
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Jan 12, 2026
b1f89b5
POSIX shared memory
Jan 12, 2026
6bf5cb9
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
Jan 12, 2026
3aefc22
Latest co library
Jan 12, 2026
508f95c
Apple build fixes
dallison Jan 12, 2026
3e33089
Merge branch 'main' into import_fixesx
dallison Jan 14, 2026
51d24dd
Merge Mikael's changes
dallison Jan 14, 2026
ce67441
Toolbelt 2.0.0 release
dallison Jan 14, 2026
378ae37
Fixes for bridge
dallison Jan 19, 2026
f727ad0
Bazel 9 and fix bridge test
Jan 21, 2026
8892d68
Version 2.0.0 of toolbelt
dallison Jan 24, 2026
9bb66d1
Try to get qnx toolchain working
dallison Jan 24, 2026
72484b5
Trying qnx bazel and cmake build
Jan 25, 2026
376ebdb
Try to replace -MD with -Wc,-MD for qnx
Jan 25, 2026
2d151f4
Trying again
Jan 25, 2026
89ed527
Trying a single arg
Jan 25, 2026
16a6fa9
Try passing -I and -iquote through in toolchain
Jan 25, 2026
6a7767f
Trying again from scratch
Jan 26, 2026
215ebdf
Toolbelt 2.0.0 from BCR
dallison Jan 29, 2026
768c96c
Tidy up MODULE.bazel
dallison Jan 29, 2026
1602910
Merge branch 'import_fixesx' of https://github.com/dallison/subspace …
dallison Jan 29, 2026
2a07284
Add CHANGELOG.md
dallison Jan 29, 2026
636e6c9
Update copyright dates and add Cruise acknowledgement
dallison Feb 1, 2026
fe7f37e
Correct start date was 2023
dallison Feb 1, 2026
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
25 changes: 25 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address

# Enable the built-in platform-specific configuration feature
common --enable_platform_specific_config

# Apply this flag only when building on/for macOS
build:macos --macos_minimum_os=10.15

# For all builds, use C++17
build --cxxopt="-std=c++17"
build --cxxopt='-Wno-sign-compare'
Expand All @@ -15,6 +21,9 @@ build:apple_silicon --cpu=darwin_arm64
# Common flags for Clang
build:clang --action_env=BAZEL_COMPILER=clang
build:clang --action_env=CC=clang --action_env=CXX=clang++
build:clang --copt="-Wno-reserved-macro-identifier"
build:clang --copt="-Wunused-parameter"

#build:clang --linkopt=-fuse-ld=lld

# Clang with libc++
Expand All @@ -25,3 +34,19 @@ build:libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++
build:libc++ --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a
build:libc++ --action_env=BAZEL_LINKOPTS=-lm:-pthread
build:libc++ --define force_libcpp=enabled

# QNX 8 Toolchain Configurations
# Set QNX_SDP_PATH environment variable or use default ~/qnx800
build:qnx_aarch64 --platforms=//bazel/toolchains/qnx/platforms:qnx_aarch64
build:qnx_aarch64 --action_env=QNX_SDP_PATH
build:qnx_aarch64 --define=QNX_SDP_PATH=/home/dave.allison/qnx800
build:qnx_aarch64 --cxxopt=-D__QNX__

build:qnx_x86_64 --platforms=//bazel/toolchains/qnx/platforms:qnx_x86_64
build:qnx_x86_64 --action_env=QNX_SDP_PATH
build:qnx_x86_64 --define=QNX_SDP_PATH=/home/dave.allison/qnx800
build:qnx_x86_64 --cxxopt=-D__QNX__

# QNX common flags
build:qnx --cxxopt=-std=c++17
build:qnx --cxxopt=-Wno-sign-compare
171 changes: 171 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# CHANGELOG.md

## Subspace Version 2.2.0

### Client API Improvements

#### Publisher Options
- **Retirement notification support**: Enhanced publisher options with retirement notification capabilities
- `notify_retirement` option for publishers to receive slot retirement notifications
- `GetRetirementFd()` method to obtain file descriptor for retirement notifications
- Improved retirement tracking for GPU memory management and external resource cleanup

#### Thread Safety Features
- **Configurable thread safety**: New thread safety options for concurrent client usage
- Optional mutex protection for all client operations
- Automatic message buffer locking during publish operations
- Configurable locking behavior for performance optimization
- Thread-safe message retirement handling

#### Checksums
- **Configurable checksum generation and checking**: Optionally allows a CRC32 checksum to be added into the `MessagePrefix` for a published message and checked in subscribers. A message with a failed checksum can either be dropped by the client or received with a failure notification.

#### Portability
- **POSIX shared memory**: for non-Linux systems, uses POSIX shared memory with a shadow file in /tmp.

#### Bridge Support
- **Enhanced bridge publisher/subscriber options**: Improved bridge functionality in client options
- Better bridge detection and configuration
- Enhanced virtual channel support for bridged communications
- Improved multiplexer channel handling across bridges

### New Features

#### Server Plugin Architecture
- **Dynamic plugin loading**: Added comprehensive plugin system for extending server functionality
- Plugin interface with lifecycle hooks: `onStartup`, `onReady`, `onShutdown`
- Event-driven callbacks for channel and user management: `onNewChannel`, `onRemoveChannel`, `onNewPublisher`, `onRemovePublisher`, `onNewSubscriber`, `onRemoveSubscriber`
- Plugin context system with integrated logging support
- Single-threaded coroutine-based execution model for plugins
- Dynamic library loading support with C-style function interfaces

#### Client-Side Thread Safety
- **Optional thread safety support**: Added thread-safe client operations for multi-threaded applications
- `SetThreadSafe(true)` method to enable mutex-protected client operations
- Thread-safe publisher message buffer management with automatic locking
- Configurable locking behavior with option to disable automatic locking for zero-copy operations
- Mutual exclusion protection for concurrent client operations
- Thread-safe retirement notification handling across multiple threads

#### Message Checksum Support
- **Hardware-accelerated checksums**: Integrated CRC32 checksum calculation for message integrity
- Hardware CRC32 instruction support with fallback implementations
- `CalculateChecksum()` and `VerifyChecksum()` functions for multi-span data validation
- ARM assembly optimizations for CRC32 calculations
- Configurable hardware acceleration via `SUBSPACE_HARDWARE_CRC` compilation flag
- Template-based checksum calculation for arbitrary data spans

### Testing Infrastructure

#### Bridge Testing Framework
- **Comprehensive bridge retirement testing**: Added extensive test coverage for message retirement across bridges
- `BasicRetirement` test: Validates basic retirement notification functionality
- `MultipleRetirement` test: Tests retirement notifications for multiple messages with slot tracking
- `MultipleRetirement2` test: Alternative retirement scenario testing with different slot allocation patterns
- **Multi-server bridge testing**: Enhanced test infrastructure supporting multiple Subspace servers
- Two-server test setup with proper lifecycle management
- Bridge notification pipes for inter-server communication testing
- Retirement notification validation across server boundaries

#### Multi-threaded Testing
- **Concurrent operation validation**: Extensive multi-threaded testing infrastructure
- Stress tests with multiple concurrent clients and channels
- Latency testing under multi-threaded conditions
- Thread safety validation for concurrent publisher/subscriber operations
- Performance benchmarking for threaded vs non-threaded scenarios

#### Test Utilities
- **Improved test helpers**: Enhanced utility functions for bridge testing
- `WaitForSubscribedMessage`: Robust waiting mechanism for bridge subscription notifications
- Better signal handling for test debugging (`SigQuitHandler`)
- Enhanced coroutine debugging capabilities for multi-server scenarios

### Server Infrastructure

#### Bridge Communication
- **Enhanced bridge transmitter functionality**: Improved the bridge transmitter coroutine system
- Better retirement notification handling across bridges
- Improved error handling for bridge connection failures
- Enhanced retirement socket management

#### Retirement Notification System
- **Robust retirement tracking**: Improved retirement notification system for bridged channels
- Better tracking of active messages across bridge connections
- Enhanced retirement receiver coroutine functionality
- Improved slot retirement correlation across server boundaries

#### Plugin Integration
- **Server extension points**: Comprehensive plugin integration throughout server lifecycle
- Plugin initialization during server startup
- Event notifications for all channel and user lifecycle events
- Graceful plugin shutdown handling
- Error handling and logging for plugin operations


### Documentation

#### Version 2 Features
- **Comprehensive feature documentation**: Enhanced documentation of Subspace Version 2 features
- Lock-free shared memory implementation details
- Message retirement notification system documentation
- Multiplexed virtual channels usage patterns
- C client API documentation
- Thread safety features and guidelines
- Server plugin development guide


### Bug Fixes

#### Bridge Test Improvements
- **Fixed bridge test debug output**: Removed excessive debug logging in `bridge_test.cc` that was cluttering test output
- Removed verbose bridge notification length logging in `WaitForSubscribedMessage` function
- Improved test output clarity for bridge functionality testing

#### Bridge Notification System
- **Enhanced bridge notification handling**: Improved the robustness of bridge notification processing
- Better error handling for bridge notification pipe operations
- Cleaner separation of bridge notification logic from debug output

### Infrastructure Improvements

#### Build System
- **Enhanced CMake support**: Improved CMake build configuration
- Better dependency management for server components
- Enhanced library linking for cross-platform builds
- Improved target configuration for test executables
- Plugin compilation support

#### Development Tools
- **Better debugging support**: Enhanced debugging capabilities for multi-server scenarios
- Improved coroutine introspection tools
- Better signal handling for development debugging
- Enhanced test output formatting
- Plugin debugging and logging infrastructure

### Performance Enhancements

#### Hardware Acceleration
- **Optimized checksum calculations**: Hardware-accelerated CRC32 for improved performance
- ARM assembly optimizations for mobile and embedded platforms
- Intel hardware CRC32 instruction utilization
- Fallback implementations for compatibility

#### Thread Safety Optimization
- **Selective locking**: Configurable thread safety to minimize performance impact
- Optional locking for zero-copy operations
- Minimal mutex contention in multi-threaded scenarios
- Atomic operations for retirement trigger management

### Breaking Changes
- None in this release - all changes are backward compatible bug fixes and improvements

### Migration Notes
- No migration required for existing applications
- New retirement notification features are opt-in via publisher options
- Thread safety must be explicitly enabled via `SetThreadSafe(true)`
- Server plugins require separate compilation and loading
- Enhanced bridge testing infrastructure is available for developers working with multi-server deployments

---

**Note**: This release focuses primarily on improving the stability and testability of the bridge communication system, while adding significant new capabilities for server extensibility, client thread safety, and message integrity validation. All new features maintain backward compatibility with existing Subspace applications.
58 changes: 44 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# build systems.

cmake_minimum_required(VERSION 3.15)
project(Subspace LANGUAGES CXX)
project(Subspace LANGUAGES CXX ASM)

# Set C++ standard and compiler flags
set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -41,38 +41,68 @@ FetchContent_Declare(
GIT_TAG 20240722.0 # Matches the version in your WORKSPACE
# Pass architecture settings and CXX standard propagation to Abseil's CMake build
CMAKE_ARGS
CMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
-DCMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
-DABSL_PROPAGATE_CXX_STD=ON # Propagate C++ standard settings
)
FetchContent_MakeAvailable(abseil)
# Abseil provides targets like absl::base, absl::strings, etc.

# --- External Dependency: co (using FetchContent for native CMake) ---
# Using the same version as Bazel build (commit cf1252b2f5952d7cba83b67dd69288971c0a2b57)
# MUST be declared before cpp_toolbelt since cpp_toolbelt depends on it
FetchContent_Declare(
co
GIT_REPOSITORY https://github.com/dallison/co.git
GIT_TAG cf1252b2f5952d7cba83b67dd69288971c0a2b57
# Pass architecture settings to co's CMake build
CMAKE_ARGS
-DCMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
)
FetchContent_MakeAvailable(co)
# co provides the 'co' target.

# --- External Dependency: cpp_toolbelt (using FetchContent for native CMake) ---
# Assumes cpp_toolbelt repository now contains a CMakeLists.txt at its root.
# Using the same version as Bazel build (commit 7ec0e2cd2a17a006f976df23d07ad530499249e0)
# Note: cpp_toolbelt's CMakeLists.txt will try to fetch co, but since we've already
# declared it above, FetchContent will use our version instead
FetchContent_Declare(
cpp_toolbelt
GIT_REPOSITORY https://github.com/dallison/cpp_toolbelt.git
GIT_TAG main
GIT_TAG 7ec0e2cd2a17a006f976df23d07ad530499249e0
# Pass architecture settings to cpp_toolbelt's CMake build
CMAKE_ARGS
CMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
-DCMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
)
FetchContent_MakeAvailable(cpp_toolbelt)
# cpp_toolbelt provides the 'toolbelt' target.

# --- External Dependency: Googletest (using FetchContent for native CMake) ---
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2 # Matches the version in MODULE.bazel
# Pass architecture settings to Googletest's CMake build
CMAKE_ARGS
-DCMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
)
FetchContent_MakeAvailable(googletest)
# Googletest provides targets like gtest, gtest_main, gmock, gmock_main

# --- External Dependency: co (using FetchContent for native CMake) ---
# Assumes co repository now contains a CMakeLists.txt at its root.
# --- External Dependency: Protobuf (using FetchContent for native CMake) ---
FetchContent_Declare(
co
GIT_REPOSITORY https://github.com/dallison/co.git
GIT_TAG main
# Pass architecture settings to co's CMake build
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG v29.5
# Protobuf's CMake build can be configured to build only necessary components
CMAKE_ARGS
CMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
-Dprotobuf_BUILD_TESTS=OFF # Explicitly disable building tests to avoid gmock conflicts
-Dprotobuf_BUILD_EXAMPLES=OFF
-Dprotobuf_BUILD_SHARED_LIBS=OFF # Build static libs
-DCMAKE_OSX_ARCHITECTURES="${CMAKE_OSX_ARCHITECTURES}"
)
FetchContent_MakeAvailable(co)
# co provides the 'co' target.
FetchContent_MakeAvailable(protobuf)
# Protobuf provides targets like protobuf::libprotobuf and protobuf::protoc
# These targets can be used directly without find_package

#add to get */file.h includes working
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
5 changes: 4 additions & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Copyright 2025 David Allison
Copyright 2023-2026 David Allison
All Rights Reserved

This is licensed under the Apache 2 license (see the LICENSE file).

Parts of this software were contributed by Cruise Auotmation LLC.

34 changes: 3 additions & 31 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module(
name = "subspace",
version = "2.2.0",
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "abseil-cpp", version = "20250512.1")
Expand All @@ -14,34 +12,8 @@ bazel_dep(name = "protobuf", version = "33.2")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")

# Toolbelt
git_repository(
name = "toolbelt",
commit = "0286a5f6da0f256d6ffbc9f6b43cd6b003fe9dbf",
remote = "https://github.com/dallison/cpp_toolbelt.git",
)
# For local debugging of toolbelt coroutine library.
# bazel_dep(name = "toolbelt")
# local_path_override(
# module_name = "toolbelt",
# path = "../cpp_toolbelt",
# )

# Coroutines
http_archive(
name = "coroutines",
integrity = "sha256-fdSwDRrEyFf6PRX8fkkfSPTWPB3Z9tc5GiUbkwsk0Mc=",
strip_prefix = "co-3.0.0",
urls = ["https://github.com/dallison/co/archive/refs/tags/3.0.0.tar.gz"],
)
# For local debugging of co coroutine library.
# bazel_dep(name = "coroutines")
# local_path_override(
# module_name = "coroutines",
# path = "../co",
# )

bazel_dep(name = "coroutines", version = "3.0.1")
bazel_dep(name = "cpp_toolbelt", version = "2.0.0")
bazel_dep(name = "rules_python", version = "1.7.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down
Loading