Files
zeekay d14b104790 feat(zap): v2 generic API, bufpool, transport allocator + UMA/RDMA cgo
Three orthogonal additions, one wire format.

v2 package — generic ad-hoc schema dispatch (~/work/lux/zap/v2):
- README + IMPOSSIBILITY + BENCH_RESULTS document the v1↔v2 split.
- builder/field/iter/list/pool/registry/schema/view + codegen package
  emit v1-equivalent fast paths from declarative .zap sources.
- _compile_fail_test/ + examples/ cover negative and positive cases.
- v2_test.go exercises the generic dispatch path.
- doc.go in v1 marks v1 deprecated for *new* schema authoring; existing
  v1 buffers stay parseable by both v1 and v2.

bufpool — pooled read slabs (bufpool.go + bufpool_test.go):
- Message gains optional *bufRef; Release() returns the slab to its
  pool when sourced from the pooled read path, GC-managed otherwise.
- ParseHeader returns (data, rootOffset) without allocating *Message,
  used by zapv2 to avoid two allocations per parse.
- bench_read_test.go + node_quic_stream_test.go cover both paths.

Transport allocator + UMA/RDMA cgo (transport/*):
- Transport.Caps()/Buffer interface: capability + slab-typed buffer
  contract. Bytes() vs DevicePtr() decoupled so UMA and GPUDirect
  can share the same call surface.
- DPDK PMD + GPUDirect RDMA + CUDA UMA real cgo backends gated behind
  build tags; stub paths remain default on darwin / non-Linux.
- transport_test.go covers Caps reporting + Buffer lifecycle on the
  default transport.

LLM.md + go.mod follow the additions.
2026-06-04 17:06:59 -07:00

53 lines
1.2 KiB
C

// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//
//go:build cgo && linux && dpdk
//
// Real DPDK EAL bring-up. Compiled into the binary only when the dpdk
// build tag is set (see dpdk_linux_real.go). When not built, the weak
// stubs in dpdk_pmd.c take over and the probe reports
// "librte_eal not linkable".
#if defined(LUX_ZAP_DPDK_BUILD)
#include "dpdk_pmd.h"
#include <errno.h>
#include <rte_eal.h>
#include <rte_errno.h>
#include <stdlib.h>
#include <string.h>
static int g_eal_inited = 0;
int luxzap_dpdk_init(int argc, char** argv) {
if (g_eal_inited) return 0;
// Default arg vector when caller passes none — DPDK insists on argv.
char* default_argv[] = {
"luxzap",
"--proc-type=auto",
"--in-memory",
NULL,
};
if (argc <= 0 || argv == NULL) {
argc = (int)(sizeof(default_argv) / sizeof(default_argv[0])) - 1;
argv = default_argv;
}
int rc = rte_eal_init(argc, argv);
if (rc < 0) {
return rte_errno ? rte_errno : EIO;
}
g_eal_inited = 1;
return 0;
}
int luxzap_dpdk_shutdown(void) {
if (!g_eal_inited) return 0;
int rc = rte_eal_cleanup();
if (rc < 0) return -rc;
g_eal_inited = 0;
return 0;
}
#endif // LUX_ZAP_DPDK_BUILD