Skip to content

netlib v2 greenfield — io_uring + coro + RIO milestone#3

Draft
retretx wants to merge 84 commits into
masterfrom
cursor/netlib-2-greenfield-3df4
Draft

netlib v2 greenfield — io_uring + coro + RIO milestone#3
retretx wants to merge 84 commits into
masterfrom
cursor/netlib-2-greenfield-3df4

Conversation

@retretx

@retretx retretx commented Jul 8, 2026

Copy link
Copy Markdown
Owner

netlib v2 greenfield milestone

Platform matrix (v2)

OS Engine v2_echo v2_echo_bench
Linux io_uring yes yes
Windows RIO yes yes
macOS poll_engine yes yes

Latest: macOS poll_engine + benchmarks

  • poll_engine — BSD poll() + nonblocking live TCP I/O
  • v2_echo + coro integration tests on Darwin
  • v2_echo_bench via poll_engine; CI smoke on macOS

CI (8 jobs — all green on ad7d6c1)

  • Linux gcc/clang: tests, v2_echo smoke, v2_echo_bench smoke (gcc)
  • Windows: tests, v2_echo smoke, v2_echo_bench smoke
  • macOS: tests, nostd, v2_echo smoke, v2_echo_bench smoke (this commit)
Open in Web Open in Cursor 

- Add netlib::span, text_view, result, optional, duration, inplace_vector, ring_buffer
- Add null_logger and io::mock_engine for zero-vtable testing
- CMake netlib::core target with nostdinc++ compile gate (netlib_core_nostd_check)
- v2 unit tests with Catch2 in runner only; v1 tests behind NETLIB_BUILD_V1_TESTS
- Project rules (.cursor/rules/netlib-2.mdc) and docs/NOSTDLIB.md
- Bump project version to 2.0.0; simplify CI for v2 scaffold

Co-authored-by: Nikita <retretx@gmail.com>
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

cursoragent and others added 24 commits July 8, 2026 22:38
- Add buffer_registry for consumer-owned span regions
- Add netlib_platform_uring static lib with raw io_uring syscalls
- io_uring_engine: open/submit/poll for READ/WRITE ops
- Integration test: socketpair read via io_uring
- Rules: do not create branches/PRs without user request

Co-authored-by: Nikita <retretx@gmail.com>
… of cursor rules)

Co-authored-by: Nikita <retretx@gmail.com>
- Extend io_uring_engine with register_buffers, CONNECT/ACCEPT ops
- Pack op_kind into user_data for correct completion dispatch
- Add io_context template and Linux platform alias
- Implement socket_posix TCP helpers (bind ephemeral, connect)
- Add mock_engine stubs for open/register_buffers
- Integration tests: buffer registration, TCP echo via READ/WRITE

Co-authored-by: Nikita <retretx@gmail.com>
- submission: reg_index/offset/length + read_fixed_op/write_fixed_op
- io_uring_engine: IORING_OP_READ/WRITE_FIXED, accept addr2, accept fd in completion
- poll: min_complete=0 to avoid indefinite blocking
- Tests: async ACCEPT, CONNECT (SKIP if unsupported), registered buffer echo

Co-authored-by: Nikita <retretx@gmail.com>
- io::byte_stream: consumer-owned buffer cursor (read/write positions)
- io::socket: non-owning fd handle with read/write submission helpers
- io::pipe: operator| for read_into, write_from, echo_to chains
- run_read/run_write/run_echo helpers with poll loop
- tests/v2/socket_tests: mock + TCP integration via pipe API

Co-authored-by: Nikita <retretx@gmail.com>
- io::tcp_acceptor: RAII listen socket, bind_loopback_ephemeral(out)
- resolve_host: IPv4 literal fast-path + getaddrinfo cold path
- io::connect(sock, host, port): blocking TCP connect by hostname
- pipe::accept_peer / run_accept for async ACCEPT via operator|
- Tests: mock accept, DNS resolve, acceptor + connect integration

Co-authored-by: Nikita <retretx@gmail.com>
- socket::connect_submission, pipe::connect_to / connect_host
- make_connect resolves host then stages CONNECT submission
- run_connect and connect_async poll for connect completion
- Tests: mock connect, accept+async connect integration (SKIP if unsupported)

Co-authored-by: Nikita <retretx@gmail.com>
- include/netlib/io/coro.hpp вне nostd modules: read/write/connect/accept awaitables
- sync_wait(io_context, io_task) с poll-драйвером для mock/io_uring
- NETLIB_ENABLE_COROUTINES по умолчанию ON при поддержке toolchain
- 4 теста в tests/v2/coro_tests.cpp (mock_engine)

Co-authored-by: Nikita <retretx@gmail.com>
- pipe: staged_handshake, run_handshake (accept+connect submit, joint poll)
- pipe: make_handshake, handshake_async(host) cold-path resolve
- coro: handshake_awaitable с session::handshake_wait и pump_handshake
- тесты mock + linux integration + coro handshake

Co-authored-by: Nikita <retretx@gmail.com>
- platform/windows: rio_engine (RIO probe, CQ create, software completion fallback)
- socket_winsock: tcp_socket, resolve, tcp_acceptor bind/listen
- connect.hpp + io_context platform alias for NETLIB_PLATFORM_WINDOWS
- CMake netlib::platform_rio (ws2_32, mswsock), tests/v2/rio_tests.cpp (WIN32)

Co-authored-by: Nikita <retretx@gmail.com>
…actor

- session::multi_wait заменяет handshake_wait (до 8 параллельных op)
- multi_op::descriptor для accept/connect/read/write
- when_all(ctx, op...) + when_all_result<N>
- handshake_awaitable построен поверх when_all_2
- тест parallel reads (4+8 bytes)

Co-authored-by: Nikita <retretx@gmail.com>
- parallel_op + parallel_slot_result (accept/connect/read/write)
- run_when_all(ctx, ops[N], out[N]) с poll_parallel
- run_handshake рефакторен через run_when_all
- тест parallel reads (4+8 bytes)

Co-authored-by: Nikita <retretx@gmail.com>
- Probe IORING_OP_CONNECT and registered I/O at engine open
- Fallback run_connect/run_handshake to blocking TCP when async connect unavailable
- blocking_connect temporarily clears O_NONBLOCK for libc connect on Linux
- pipe::parallel_op alias in coro multi_op; capability test + CI coroutines

Co-authored-by: Nikita <retretx@gmail.com>
…rts_async_connect

- connect_awaitable и handshake_awaitable делегируют blocking path
- Linux coro integration test с io_uring + blocking connect fallback

Co-authored-by: Nikita <retretx@gmail.com>
- resolve_submission: READ/WRITE_FIXED → READ/WRITE через buffer_registry при !supports_registered_io
- Пропуск io_uring_register_buffers если fixed ops недоступны
- buffer_registry::slice, pipe read_fixed_into/write_fixed_from + run_*_fixed
- Тесты: echo через fallback, invalid reg_index, pipe mock

Co-authored-by: Nikita <retretx@gmail.com>
- read_fixed_async / write_fixed_async поверх staged_read/write_fixed
- pipe staged_echo_fixed: read_fixed_into | echo_to + run_echo_fixed
- Тесты: mock pipe/coro, io_uring pipe echo через span fallback

Co-authored-by: Nikita <retretx@gmail.com>
…robe

- coro echo_fixed_async делегирует pipe::run_echo_fixed
- parallel_op/multi_op read_fixed/write_fixed для when_all
- Windows: RIOCreateRequestQueue при probe, request_queue_ready()
- Тесты: coro when_all fixed, pipe run_when_all fixed

Co-authored-by: Nikita <retretx@gmail.com>
- coro when_all read_fixed и echo_fixed_async на io_uring + span fallback
- Windows RIORegisterBuffer/RIODeregisterBuffer, registered_buffer_count()
- rio_tests: register_buffers через io_context

Co-authored-by: Nikita <retretx@gmail.com>
…n_all io_uring test

- session::sequential_step для цепочки read_fixed → write_fixed без sync run_echo_fixed
- pipe run_when_all parallel read_fixed на io_uring + span fallback

Co-authored-by: Nikita <retretx@gmail.com>
…helpers

- io_task_awaiter с continuation для вложенных coro-задач
- echo_async: sequential read→write через byte_stream
- detail::sequential_arm/finish — DRY для echo_fixed/echo
- Тесты: echo_async, nested io_task co_await

Co-authored-by: Nikita <retretx@gmail.com>
…ll stream reads

- coro: echo_async TCP + when_all stream reads на io_uring
- pipe: run_echo TCP + run_when_all stream reads на io_uring

Co-authored-by: Nikita <retretx@gmail.com>
- connect_host_awaitable / handshake_host_awaitable с cold-path resolve
- Тесты mock + io_uring handshake(host); coro:: квалификация vs pipe::
- CHANGELOG: coro layer, capability probe, span fallback, RIO, CI

Co-authored-by: Nikita <retretx@gmail.com>
- Rename pipe sync helpers to run_connect_host/run_handshake_host to avoid
  ambiguity with coro::connect_async/handshake_async
- Windows rio_engine: RIOReceive/RIOSend for registered fixed I/O, per-socket
  request queue pool, hybrid hardware/software poll
- Update docs/COROUTINES.md with v2 pipe/coro API section

Co-authored-by: Nikita <retretx@gmail.com>
- tcp_acceptor::bind_host + platform bind_ipv4 (Linux/Windows)
- pipe::run_accept_bind_host, coro::accept_bind_async
- detail::sequential_awaitable_base CRTP for echo awaitables
- Tests: bind_host, accept_bind_async; docs + CHANGELOG

Co-authored-by: Nikita <retretx@gmail.com>
@cursor cursor Bot changed the title netlib 2.0 Phase 0: core primitives without C++ stdlib netlib v2 greenfield — io_uring + coro + RIO milestone Jul 9, 2026
cursoragent and others added 3 commits July 9, 2026 00:38
- sequential2_awaitable, read_then_write_async/fixed_async, sequential_async
- Windows RIO: on-demand span buffer registration (submit_rio_span)
- Linux integration: bind_host + async accept + client connect
- Tests + docs/COROUTINES.md + CHANGELOG

Co-authored-by: Nikita <retretx@gmail.com>
- sequentialN_awaitable + sequential_chain builder (2..8 steps)
- echo_async/echo_fixed_async delegate to read_then_write_*
- commit_write_stream on sequential2 for stream echo semantics
- coro tests: 3-step chain, handshake after bind_host, when_all accept+connect

Co-authored-by: Nikita <retretx@gmail.com>
- coro::accept_connect_async with blocking-connect fallback (handshake delegate)
- pipe::run_accept_connect sync alias
- sequential_chain::defer_write_after_read for dynamic write after read
- docs/EXAMPLES.md v2 section; accept_connect io_uring integration test

Co-authored-by: Nikita <retretx@gmail.com>
cursoragent and others added 30 commits July 9, 2026 11:30
- Build uring_tests only when platform_uring target exists (Linux)
- coro when_all handshake: int32_t indices instead of ssize_t
- Undef Windows rpcndr byte macro after Winsock includes

Co-authored-by: Nikita <retretx@gmail.com>
- rio_tests: winsock headers + undef byte/socket macros
- coro_tests Windows block: platform namespace + io::socket
- tests CMake: explicit NETLIB_PLATFORM_* definitions on test target
- socket_tests: undef socket macro after Winsock

Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
Add win_test_prereq.hpp to include winsock and undef the rpcndr byte
macro before netlib headers. Use nl::byte in coro_tests without breaking
byte_stream, byte_span, or *_bytes identifiers. Wire rio_tests and
socket_tests Windows sections through the shared prereq header.

Co-authored-by: Nikita <retretx@gmail.com>
- Rename netlib::memcpy to memory_copy to avoid CRT overload ambiguity
  when Windows headers are included alongside using-directives.
- Move win_test_prereq out of coro_tests global scope; include only in
  platform-specific sections that need real sockets.
- Replace using namespace rrmode::netlib with explicit nl::/io:: aliases
  in test TUs; rename stop_source shutdown vars (conflicts with ::shutdown).

Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
NETLIB_EXAMPLES_REQUIRE_POSIX previously returned from examples/CMakeLists
on Windows, so v2_echo targets were never generated but CI still tried to
build them. Skip only tcp/udp/unix on Windows; keep v2_echo (RIO backend).

Harden v2_echo server/client for Winsock: undef byte/socket, explicit nl::
aliases, stop_src rename, platform namespace alias.

Co-authored-by: Nikita <retretx@gmail.com>
- ensure_winsock_started/release_winsock in win_detail for tcp_socket, stop_wake,
  and rio_engine (fixes tests calling sockets without engine open).
- supports_registered_io: true in software mode after open (fixes buffer count).
- SKIP mock-fd coro rio tests when hardware_fixed_io is active on CI hosts.

Co-authored-by: Nikita <retretx@gmail.com>
Low SOCKET values on Windows CI may alias live handles, causing
is_real_socket() to treat mock fds as real and fail with invalid_argument.

Co-authored-by: Nikita <retretx@gmail.com>
Export win_detail::is_live_socket and gate rio_engine coro await_suspend
blocking syscalls on real sockets. Mock-fd software completions use async
submit path, fixing rio coro unit tests on Windows CI.

Co-authored-by: Nikita <retretx@gmail.com>
- CHANGELOG: memory_copy, WSAStartup, is_live_socket, v2_echo Windows
- COROUTINES: blocking fallback only for live SOCKET
- TESTING: v2 test layout and win_test_prereq.hpp
- PLATFORMS/EXAMPLES: v2_echo on Windows

Co-authored-by: Nikita <retretx@gmail.com>
- rio_engine_config::force_software_mode bypasses hardware RIO in unit tests
- coro mock-fd tests no longer SKIP on hardware RIO CI
- rio_tests: force_software_mode coverage
- CI: explicit netlib_core_nostd_check build step
- README/DEVELOPMENT/TESTING docs for v2 workflow

Co-authored-by: Nikita <retretx@gmail.com>
- flush_software_submissions: nonblocking recv/send on live SOCKET
- WSAPoll pending read/write fds in wait_pending_software
- rio_tests: real TCP span echo and hardware fixed round-trip
- coro_tests: echo_async/echo_fixed on real TCP via rio_engine
- CI: macOS job (v2 mock+coro), Windows nostd gate

Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
- NETLIB_PLATFORM_POSIX: socket_posix + pipe stop_wake on Darwin
- connect.hpp/coro.hpp/stop_token: POSIX blocking_connect and wake
- core_tests: pipe wake test on POSIX
- rio_tests: byte_stream lvalue for MSVC

Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
- benchmarks/v2_echo_bench.cpp: loopback connect/write/read throughput
- NETLIB_BENCHMARK_BUILD_V2 CMake option; independent of v1 network benches
- docs: BENCHMARKS, GETTING_STARTED v2 section; README phase note

Co-authored-by: Nikita <retretx@gmail.com>
- CI: NETLIB_BUILD_BENCHMARKS + smoke v2_echo_bench (linux gcc, windows)
- rio_tests: hardware span read/write on live TCP (skip without hardware RIO)
- docs/CMAKE_OPTIONS: NETLIB_BENCHMARK_BUILD_V2

Co-authored-by: Nikita <retretx@gmail.com>
- poll_engine: BSD poll() + nonblocking accept/connect/read/write for live TCP
- is_live_socket() via getsockopt(SO_TYPE) on POSIX sockets
- coro blocking traits for poll_engine (mirrors RIO software path)
- posix_poll_tests: mock submit + real TCP run_echo integration
- CI macOS: build and smoke v2_echo_server/client_coro

Co-authored-by: Nikita <retretx@gmail.com>
- mock echo_peer/accept_echo_once via software completions
- real TCP client echo round trip and echo_async via poll_engine
- extend shared coro test helpers for NETLIB_PLATFORM_POSIX

Co-authored-by: Nikita <retretx@gmail.com>
io_context.hpp pulls io_uring/RIO engine headers on Linux/Windows; add the
same POSIX branch so v2_echo and coro.hpp see poll_engine via the include chain.

Co-authored-by: Nikita <retretx@gmail.com>
blocking_tcp_client_then_cancel used Windows path on Darwin; extend Linux
branch to NETLIB_PLATFORM_POSIX. Fix typo close_fd in posix_poll_tests.

Co-authored-by: Nikita <retretx@gmail.com>
Extend LINUX||WINDOWS blocking accept/connect/rw guards to POSIX and
enable would_block retry for poll_engine (fixes v2_echo smoke hang).

Co-authored-by: Nikita <retretx@gmail.com>
Raw read() on O_NONBLOCK client fd returns EAGAIN on Darwin before echo
reply is ready; blocking_read_some temporarily clears nonblocking.

Co-authored-by: Nikita <retretx@gmail.com>
Co-authored-by: Nikita <retretx@gmail.com>
- Extend v2_echo_bench for NETLIB_PLATFORM_POSIX (poll_engine)
- benchmarks/CMakeLists: Darwin backend alongside io_uring/RIO
- CI macOS: NETLIB_BUILD_BENCHMARKS + smoke v2_echo_bench 10 iters
- Docs: BENCHMARKS, PLATFORMS, CMAKE_OPTIONS, CHANGELOG

Co-authored-by: Nikita <retretx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants