Skip to content

feat(native): PR1A — fixed native baseline, buffer reduction, diagnostics#3

Open
mrmidi wants to merge 1 commit into
pr0/native-buildfrom
pr1a/native-baseline
Open

feat(native): PR1A — fixed native baseline, buffer reduction, diagnostics#3
mrmidi wants to merge 1 commit into
pr0/native-buildfrom
pr1a/native-baseline

Conversation

@mrmidi

@mrmidi mrmidi commented Jul 20, 2026

Copy link
Copy Markdown
Owner

PR1A — Native Fixed Baseline

Base: pr0/native-build (stacked PR chain)
fptn submodule: fd56bb8 (pr1a/ios-native-baseline)

Socket buffers

  • Removed conflicting 4 MiB (Connect) and 1 MiB (RunInternal) TCP buffer assignments — both commented out for easy restoration
  • First experiment: kernel default (no explicit value). Isolates the effect of removing the conflicting settings.
  • ios_socket_buffer_bytes Conan option on the fptn package (allowed: 0, 262144, 524288). Changing it changes the Conan package ID and recompiles the native library.
  • Build script passes -o "fptn/*:ios_socket_buffer_bytes=N" to every conan install and validates the value
  • Buffers applied before TCP connect (may influence window negotiation)
  • Effective values queried after connect via Boost.Asio get_option (cross-platform); failure stores 0
  • Requested values always reflect what the build asked for; failed set_option increments socket_buffer_set_error_count
  • Both requested and effective values + error count exposed in status struct (8 new fields)

Beast reader

  • 64 KiB initial reserve with a 256 KiB WebSocket message limit (was 4 MiB reserve)

Packet path

  • Removed SPDLOG_WARN + two Mach task_info syscalls from packet_callback_adapter (fired every 500 packets)
  • Atomic counters remain for getStatus() reporting; unused locals removed

Concurrency

  • Renamed thread_numberconcurrency_hint (io_context hint, not thread count)
  • Set to 1 on TARGET_OS_IOS, 4 elsewhere
  • The wrapper already drives the context from one native thread

Process-wide lifecycle counters

  • static std::atomic<int>: live_clients_, active_reader_coroutines_, active_sender_coroutines_
  • RAII AtomicActivityGuard handles normal returns, exceptions, and co_return
  • live_clients_ decrements after Stop() + ioc_.stop() complete
  • PR1C will use these for a teardown barrier

Build manifest

  • ios_socket_buffer_bytes added to manifest + cache validation

Wrapper status struct

8 new fields in WebsocketClientBridgeStatus (both app + tunnel Swift wrappers):
requestedRcvbufBytes, requestedSndbufBytes, effectiveRcvbufBytes, effectiveSndbufBytes, liveClients, activeReaderCoroutines, activeSenderCoroutines, socketBufferSetErrorCount

Unchanged (later PRs)

  • Queue: 256 packets, try_send, silent drop → PR1B
  • Teardown: detached coroutines, no barrier → PR1C
  • Serialization copies → PR5
  • Wire protocol → unchanged

Verification

  • Native framework (Debug, C++23): built
  • Conan option plumbing: verified (value reaches fptn package, changes package ID)
  • Xcode Debug build: succeeded
  • Tests: 22/22 passed

Stack

PR-1  Measurement safety
PR0   Production native build     (base)
PR1A  Native fixed baseline       ← this PR
PR1B  Queue and batch bounds
PR1C  Native teardown ownership
PR2   Wrapper/provider integration
PR3   C-based binary flight recorder

@mrmidi
mrmidi force-pushed the pr1a/native-baseline branch from cbded50 to e14f140 Compare July 20, 2026 12:59
…tics

Pin fptn submodule to 2016d5f (pr1a/ios-native-baseline).

Socket buffers:
- Remove conflicting 4 MiB / 1 MiB TCP buffer assignments (commented
  out for easy restoration). First experiment uses kernel default.
- FPTN_IOS_SOCKET_BUFFER_BYTES CMake parameter for subsequent tests
  (256 KiB, 512 KiB) without source edits.
- Buffers applied before TCP connect; effective values queried after.
- Requested + effective values exposed in status struct.

Beast reader:
- 64 KiB initial reserve with a 256 KiB WebSocket message limit
  (was 4 MiB reserve).

Packet path:
- Remove SPDLOG_WARN + Mach task_info syscalls from packet callback
  adapter. Atomic counters remain for getStatus().

Concurrency:
- io_context concurrency hint of 1 on iOS (was 4). Not a thread
  reduction — the wrapper already runs one native thread.

Lifecycle counters:
- Process-wide statics: live_clients, active_reader/sender_coroutines.
- RAII guard handles all exit paths.

Build manifest:
- ios_socket_buffer_bytes added to manifest + cache validation.

Wrapper status struct extended with 7 new fields (both app + tunnel).

Tests: 22/22 passed. Debug build succeeded.
@mrmidi
mrmidi force-pushed the pr1a/native-baseline branch from e14f140 to ea9a792 Compare July 20, 2026 13:13
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.

1 participant