Skip to content

Commit 1917f75

Browse files
committed
Initial plugin-ipc import
0 parents  commit 1917f75

57 files changed

Lines changed: 11005 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.o
2+
build/
3+
**/target/
4+
ipc-bench
5+
libnetipc.a
6+
netipc-codec-c
7+
netipc-shm-server-demo
8+
netipc-shm-client-demo
9+
netipc-uds-server-demo
10+
netipc-uds-client-demo
11+
tests/fixtures/go/netipc-codec-go
12+
bench/drivers/go/netipc-live-go

CMakeLists.txt

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
project(plugin_ipc LANGUAGES C)
4+
5+
set(CMAKE_C_STANDARD 11)
6+
set(CMAKE_C_STANDARD_REQUIRED ON)
7+
set(CMAKE_C_EXTENSIONS ON)
8+
9+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
10+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
11+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
12+
13+
option(NETIPC_BUILD_FIXTURES "Build C fixture binaries" ON)
14+
option(NETIPC_BUILD_BENCH "Build the C benchmark driver" ON)
15+
option(NETIPC_BUILD_HELPERS "Build Go/Rust helper binaries via CMake" ON)
16+
17+
find_package(Threads REQUIRED)
18+
19+
add_subdirectory(src/libnetdata/netipc)
20+
21+
if(NETIPC_BUILD_HELPERS)
22+
find_program(CARGO_EXECUTABLE cargo)
23+
find_program(GO_EXECUTABLE go)
24+
25+
file(GLOB_RECURSE NETIPC_RUST_CRATE_SOURCES CONFIGURE_DEPENDS
26+
"${CMAKE_SOURCE_DIR}/src/crates/netipc/src/*.rs"
27+
"${CMAKE_SOURCE_DIR}/src/crates/netipc/Cargo.toml"
28+
)
29+
file(GLOB_RECURSE NETIPC_GO_PACKAGE_SOURCES CONFIGURE_DEPENDS
30+
"${CMAKE_SOURCE_DIR}/src/go/pkg/netipc/*.go"
31+
"${CMAKE_SOURCE_DIR}/src/go/go.mod"
32+
)
33+
34+
set(NETIPC_RUST_FIXTURES_MANIFEST "${CMAKE_SOURCE_DIR}/tests/fixtures/rust/Cargo.toml")
35+
set(NETIPC_RUST_FIXTURES_TARGET "${CMAKE_SOURCE_DIR}/tests/fixtures/rust/target/release")
36+
set(NETIPC_CODEC_RS_BIN "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/netipc-codec-rs")
37+
set(NETIPC_LIVE_RS_BIN "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/netipc_live_rs")
38+
39+
if(CARGO_EXECUTABLE)
40+
add_custom_command(
41+
OUTPUT "${NETIPC_CODEC_RS_BIN}" "${NETIPC_LIVE_RS_BIN}"
42+
COMMAND "${CARGO_EXECUTABLE}" build --release --manifest-path "${NETIPC_RUST_FIXTURES_MANIFEST}"
43+
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
44+
"${NETIPC_RUST_FIXTURES_TARGET}/netipc-codec-rs"
45+
"${NETIPC_CODEC_RS_BIN}"
46+
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
47+
"${NETIPC_RUST_FIXTURES_TARGET}/netipc_live_rs"
48+
"${NETIPC_LIVE_RS_BIN}"
49+
DEPENDS
50+
"${NETIPC_RUST_FIXTURES_MANIFEST}"
51+
"${CMAKE_SOURCE_DIR}/tests/fixtures/rust/build.rs"
52+
"${CMAKE_SOURCE_DIR}/tests/fixtures/rust/src/bin/netipc_codec_rs.rs"
53+
"${CMAKE_SOURCE_DIR}/tests/fixtures/rust/src/bin/netipc_live_rs.rs"
54+
${NETIPC_RUST_CRATE_SOURCES}
55+
VERBATIM
56+
)
57+
58+
add_custom_target(netipc-codec-rs DEPENDS "${NETIPC_CODEC_RS_BIN}")
59+
add_custom_target(netipc_live_rs DEPENDS "${NETIPC_LIVE_RS_BIN}")
60+
61+
set(NETIPC_RUST_BENCH_MANIFEST "${CMAKE_SOURCE_DIR}/bench/drivers/rust/Cargo.toml")
62+
set(NETIPC_RUST_BENCH_TARGET "${CMAKE_SOURCE_DIR}/bench/drivers/rust/target/release")
63+
set(NETIPC_LIVE_UDS_RS_BIN "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/netipc_live_uds_rs")
64+
65+
add_custom_command(
66+
OUTPUT "${NETIPC_LIVE_UDS_RS_BIN}"
67+
COMMAND "${CARGO_EXECUTABLE}" build --release --manifest-path "${NETIPC_RUST_BENCH_MANIFEST}"
68+
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
69+
"${NETIPC_RUST_BENCH_TARGET}/netipc_live_uds_rs"
70+
"${NETIPC_LIVE_UDS_RS_BIN}"
71+
DEPENDS
72+
"${NETIPC_RUST_BENCH_MANIFEST}"
73+
"${CMAKE_SOURCE_DIR}/bench/drivers/rust/netipc_live_uds_rs.rs"
74+
${NETIPC_RUST_CRATE_SOURCES}
75+
VERBATIM
76+
)
77+
78+
add_custom_target(netipc_live_uds_rs DEPENDS "${NETIPC_LIVE_UDS_RS_BIN}")
79+
endif()
80+
81+
if(GO_EXECUTABLE)
82+
set(NETIPC_CODEC_GO_BIN "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/netipc-codec-go")
83+
add_custom_command(
84+
OUTPUT "${NETIPC_CODEC_GO_BIN}"
85+
COMMAND "${CMAKE_COMMAND}" -E chdir "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
86+
"${GO_EXECUTABLE}" build -o "${NETIPC_CODEC_GO_BIN}" .
87+
DEPENDS
88+
"${CMAKE_SOURCE_DIR}/tests/fixtures/go/go.mod"
89+
"${CMAKE_SOURCE_DIR}/tests/fixtures/go/main.go"
90+
${NETIPC_GO_PACKAGE_SOURCES}
91+
VERBATIM
92+
)
93+
add_custom_target(netipc-codec-go DEPENDS "${NETIPC_CODEC_GO_BIN}")
94+
95+
set(NETIPC_LIVE_GO_BIN "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/netipc-live-go")
96+
add_custom_command(
97+
OUTPUT "${NETIPC_LIVE_GO_BIN}"
98+
COMMAND "${CMAKE_COMMAND}" -E chdir "${CMAKE_SOURCE_DIR}/bench/drivers/go"
99+
"${GO_EXECUTABLE}" build -o "${NETIPC_LIVE_GO_BIN}" .
100+
DEPENDS
101+
"${CMAKE_SOURCE_DIR}/bench/drivers/go/go.mod"
102+
"${CMAKE_SOURCE_DIR}/bench/drivers/go/main.go"
103+
${NETIPC_GO_PACKAGE_SOURCES}
104+
VERBATIM
105+
)
106+
add_custom_target(netipc-live-go DEPENDS "${NETIPC_LIVE_GO_BIN}")
107+
endif()
108+
endif()

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.DEFAULT_GOAL := all
2+
3+
BUILD_DIR ?= build
4+
CMAKE ?= cmake
5+
LEGACY_ROOT_ARTIFACTS := \
6+
ipc-bench \
7+
libnetipc.a \
8+
netipc-codec-c \
9+
netipc-shm-server-demo \
10+
netipc-shm-client-demo \
11+
netipc-uds-server-demo \
12+
netipc-uds-client-demo
13+
FORWARD_TARGETS := $(filter-out all configure clean,$(MAKECMDGOALS))
14+
15+
.PHONY: all configure clean $(FORWARD_TARGETS)
16+
17+
all: configure
18+
$(CMAKE) --build $(BUILD_DIR)
19+
20+
configure:
21+
$(CMAKE) -S . -B $(BUILD_DIR)
22+
23+
clean:
24+
rm -rf $(BUILD_DIR)
25+
rm -f $(LEGACY_ROOT_ARTIFACTS)
26+
27+
ifneq ($(FORWARD_TARGETS),)
28+
$(FORWARD_TARGETS): configure
29+
$(CMAKE) --build $(BUILD_DIR) --target $@
30+
endif

README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# plugin-ipc
2+
3+
Cross-language IPC workbench and library repository for Netdata plugins.
4+
5+
This repository is now organized to mirror the eventual Netdata monorepo layout:
6+
7+
- C library code: `src/libnetdata/netipc/`
8+
- Go package home: `src/go/pkg/netipc/`
9+
- Rust crate home: `src/crates/netipc/`
10+
- Test fixtures and helper apps: `tests/fixtures/`
11+
- Benchmark drivers: `bench/drivers/`
12+
13+
The current validated implementation is still primarily the POSIX prototype:
14+
15+
- C typed frame/schema library
16+
- POSIX shared-memory hybrid transport
17+
- POSIX `UDS_SEQPACKET` transport with profile negotiation
18+
- Rust/Go helper binaries for interop and benchmark validation
19+
20+
The reusable Go package and Rust crate locations are now scaffolded, but their full library port is still pending.
21+
22+
## Build
23+
24+
Canonical build entry point:
25+
26+
```bash
27+
cmake -S . -B build
28+
cmake --build build
29+
```
30+
31+
Compatibility wrapper:
32+
33+
```bash
34+
make
35+
```
36+
37+
Primary build artifacts:
38+
39+
- `build/lib/libnetipc.a`
40+
- `build/bin/ipc-bench`
41+
- `build/bin/netipc-codec-c`
42+
- `build/bin/netipc-shm-server-demo`
43+
- `build/bin/netipc-shm-client-demo`
44+
- `build/bin/netipc-uds-server-demo`
45+
- `build/bin/netipc-uds-client-demo`
46+
- `build/bin/netipc-codec-rs`
47+
- `build/bin/netipc_live_rs`
48+
- `build/bin/netipc_live_uds_rs`
49+
- `build/bin/netipc-codec-go`
50+
- `build/bin/netipc-live-go`
51+
52+
## Repository Layout
53+
54+
```text
55+
.
56+
├── CMakeLists.txt
57+
├── bench/
58+
│ └── drivers/
59+
├── docs/
60+
├── src/
61+
│ ├── libnetdata/
62+
│ │ └── netipc/
63+
│ ├── go/
64+
│ │ └── pkg/netipc/
65+
│ └── crates/
66+
│ └── netipc/
67+
└── tests/
68+
├── fixtures/
69+
└── run-*.sh
70+
```
71+
72+
## POSIX Baseline
73+
74+
- Baseline profile: `UDS_SEQPACKET`
75+
- Negotiation: fixed-binary hello/ack with supported/preferred bitmasks and server-selected profile
76+
- Optional fast profile: `SHM_HYBRID` (`profile 2`) for C/Rust live paths
77+
- Go remains `UDS_SEQPACKET` only in the current phase
78+
79+
## C Library Paths
80+
81+
Headers:
82+
83+
- `src/libnetdata/netipc/include/netipc/netipc_schema.h`
84+
- `src/libnetdata/netipc/include/netipc/netipc_shm_hybrid.h`
85+
- `src/libnetdata/netipc/include/netipc/netipc_uds_seqpacket.h`
86+
87+
Sources:
88+
89+
- `src/libnetdata/netipc/src/protocol/netipc_schema.c`
90+
- `src/libnetdata/netipc/src/transport/posix/netipc_shm_hybrid.c`
91+
- `src/libnetdata/netipc/src/transport/posix/netipc_uds_seqpacket.c`
92+
93+
## Test And Benchmark Helpers
94+
95+
Schema fixtures:
96+
97+
- C fixture: `tests/fixtures/c/netipc_codec_tool.c`
98+
- Rust fixture crate: `tests/fixtures/rust/`
99+
- Go fixture module: `tests/fixtures/go/`
100+
101+
Benchmark drivers:
102+
103+
- C driver: `bench/drivers/c/ipc_bench.c`
104+
- Rust UDS driver crate: `bench/drivers/rust/`
105+
- Go UDS driver module: `bench/drivers/go/`
106+
107+
## Validation
108+
109+
Interop and protocol tests:
110+
111+
```bash
112+
./tests/run-interop.sh
113+
./tests/run-live-interop.sh
114+
./tests/run-live-uds-interop.sh
115+
./tests/run-uds-seqpacket.sh
116+
./tests/run-uds-negotiation-negative.sh
117+
```
118+
119+
Benchmarks:
120+
121+
```bash
122+
./tests/run-live-uds-bench.sh
123+
./tests/run-negotiated-profile-bench.sh
124+
```
125+
126+
Quick manual runs:
127+
128+
```bash
129+
build/bin/netipc-shm-server-demo /tmp netflow 3
130+
build/bin/netipc-shm-client-demo /tmp netflow 41 3
131+
132+
build/bin/netipc-uds-server-demo /tmp netflow 3
133+
build/bin/netipc-uds-client-demo /tmp netflow 41 3
134+
135+
build/bin/ipc-bench --transport stream --mode pingpong --clients 1 --payloads 32 --duration 1
136+
build/bin/ipc-bench --transport shm-hybrid --mode pingpong --clients 1 --payloads 32 --duration 5 --target-rps 100000
137+
```
138+
139+
## Current Limits
140+
141+
- The reusable C library is the only fully implemented library surface in this repo today.
142+
- Go and Rust still rely on helper binaries for the validated live interop/benchmark paths.
143+
- Windows transport directories are scaffolded, not implemented.
144+
- Netdata integration wiring is intentionally out of scope for this repository phase.

0 commit comments

Comments
 (0)