Commit Graph
11183 Commits
Author SHA1 Message Date
Tim Smart fd96c5d704 wip: DatagramSocket receive path on effect/Queue (option 1) 2026-09-28 23:28:32 +00:00
Tim Smart 4bc7bb1199 fix: keep DatagramSocket adapter helpers local and native callbacks detachable 2026-09-24 23:15:39 +00:00
Tim Smart a8c757a27f test: cover detached error hook and Bun thrown send 2026-09-24 23:09:08 +00:00
Tim Smart 967d18c174 test: pin detached DatagramSocket native callbacks 2026-09-24 23:06:11 +00:00
Tim Smart 605d4f9207 refactor: fromNativeHandle captures context, and Bun writes without a callback
- fromNativeHandle returns an Effect that captures the builder's services,
  as Socket.fromWebSocket does, and takes `{ receiveBuffer, onError }`.
  Adapters pass their options straight through, and the node-shared
  make/adopt glue and its casts go away
- NativeHandle gains an optional synchronous `trySend`. Core calls it
  first, so a Bun write that goes out at once allocates no completion
  closure (about 43 fewer bytes per write). When it refuses, core calls
  `send` with the same datagram and Bun queues or reports what `trySend`
  found, without a second native send
2026-09-24 22:59:05 +00:00
Tim Smart d9689dda20 refactor: share DatagramSocket adapter plumbing and trim core
- node-shared exports the open planning, peer resolution, errno mapping
  and constructor glue as @internal helpers; Bun and Deno use them
  instead of their own copies, so the family rule lives in one place
- core sends no destination on a connected socket, as the NativeHandle
  contract says, so adapters drop their `connected` checks
- ReaderState is the handle's NativeEvents, removing four closures per
  reader and a call per packet
- writes keep `instanceof` for their destination check: the TypeId
  guard costs 7-21% on writeAll per datagram
- NetAddress: simpler zone parsing and IPv6 segment shift
2026-09-24 22:35:16 +00:00
Tim Smart 55946d7cc9 docs: document the DatagramSocket family rule, fix the Deno multicast example and refine errors by TypeId 2026-09-24 21:43:50 +00:00
Tim Smart 0a3f8e8667 fix(platform-bun): fail queued DatagramSocket writes when the socket closed silently 2026-09-24 21:43:50 +00:00
Tim Smart 64af8925f7 test: cover datagram bind family and Bun adopted socket closure 2026-09-24 21:36:38 +00:00
Tim Smart 36e03ea0f8 test: cover interrupted and parked DatagramSocket writes
Adds deterministic core tests for the write parking path: a late send
completion after an interrupted write or writeAll must not resume a fiber
that has parked elsewhere, a masked parked write completes before its
interruption applies, and a parked writeAll resumes with success or with
the failing datagram's destination. TestHandle can now defer sendMany.
2026-09-24 06:54:36 +00:00
Tim Smart be11966e4b perf: add the Bun DatagramSocket benchmark
Compares BunDatagramSocket with raw Bun.udpSocket over loopback and
measures the core layer with a fake native handle, with the same workloads
and columns as the Node benchmark. Records the Bun 1.4.2 tier (b) baseline.
2026-09-24 06:12:04 +00:00
Tim Smart 69a01597f4 perf: complete synchronous DatagramSocket sends without suspending
A write or writeAll whose native send completes synchronously (Bun) now
returns its result directly, and one that doesn't parks the fiber as pull
does instead of going through Effect.callback. Bun writes allocate about
40% less and cost about 20% less CPU per send; Node's async writes
allocate about 120 B less with CPU unchanged.
2026-09-24 06:12:04 +00:00
Tim Smart c968192fb6 perf(platform-deno): tighten the DatagramSocket benchmark's read-loop count, timeouts and baseline notes 2026-09-24 05:33:07 +00:00
Tim Smart 6055fc018a perf(platform-deno): add the DatagramSocket benchmark against raw Deno.listenDatagram 2026-09-24 05:15:43 +00:00
Tim Smart 2c45c6fb4a test(platform-deno): bind multicast sender and join to loopback 2026-09-24 04:25:37 +00:00
Tim Smart 1b1fffb91a feat(platform): return Effects from the Bun and Deno datagram constructors 2026-09-24 04:22:20 +00:00
Tim Smart b67257d71b test(platform): prepare Bun and Deno datagram constructor call sites 2026-09-24 04:19:33 +00:00
Tim Smart 3b69b151e9 test(platform-bun): cover closure during drain and loopback multicast 2026-09-24 04:09:52 +00:00
Tim Smart 05304bc3f7 fix(platform-bun): stop draining once the datagram socket closes 2026-09-24 04:02:02 +00:00
Tim Smart c130aa47aa fix(platform-deno): map DNS permission errors on socket open 2026-09-24 01:47:55 +00:00
Tim Smart ce6808c8e8 fix(platform-deno): submit datagram batches sequentially 2026-09-24 01:41:16 +00:00
Tim Smart 529d770841 test: require sequential Deno datagram batch sends 2026-09-24 01:37:40 +00:00
Tim Smart cebd25cd3a fix: use system DNS lookup for Deno datagram endpoints 2026-09-24 01:29:16 +00:00
Tim Smart 2a1fbfb2f7 test: assert Deno hostname resolution uses node:dns lookup 2026-09-24 01:26:11 +00:00
Tim Smart f43054854a feat: implement DenoDatagramSocket adapter
Build the Deno adapter on DatagramSocket.fromNativeHandle over
Deno.listenDatagram, checking for the unstable API when a reader opens.
Give DatagramSocketUnsupportedError a message naming the runtime and the
missing capability.
2026-09-24 01:15:10 +00:00
Tim Smart cbdc3399e3 feat: implement BunDatagramSocket adapter on native Bun.udpSocket 2026-09-24 01:12:13 +00:00
Tim Smart 7968af1c28 refactor: address DatagramSocket core review comments 2026-09-24 01:03:07 +00:00
Tim Smart 50c0dd4fa4 perf: record the Node DatagramSocket tier (b) baseline for the inline park 2026-09-24 01:00:39 +00:00
Tim Smart 431bee650f perf: build the DatagramSocket pull on withFiber to keep run-loop dispatch shapes unchanged 2026-09-24 01:00:39 +00:00
Tim Smart b8f2ed714a perf: park DatagramSocket pulls with a dedicated primitive instead of Effect.callback 2026-09-24 01:00:39 +00:00
Tim Smart 0b221d96a6 test: cover DatagramSocket pull interruption paths 2026-09-24 01:00:39 +00:00
Tim Smart 832d9aa215 perf: avoid poisoned array push feedback in DatagramSocket receive 2026-09-24 01:00:39 +00:00
Tim Smart 790beb23f8 perf: park DatagramSocket pulls in a waiter slot and slide the full queue as a ring 2026-09-24 01:00:39 +00:00
Tim Smart 048275d49f test: guard DatagramSocket waiter promotion and sliding retention 2026-09-24 01:00:39 +00:00
Tim Smart 7c2fa7c200 perf: add Node DatagramSocket benchmark and compact sliding queue with a plain loop
Closes nothing on its own; part of the shared DatagramSocket PR (EFF-1518).
2026-09-24 01:00:39 +00:00
Tim Smart 9d3caac9e6 test: isolate Node datagram DNS lookup count from mock clearing 2026-09-24 01:00:39 +00:00
Tim Smart 233189f425 feat: implement NodeDatagramSocket adapter
Run the native open in the reader's scope so adopted sockets can register
finalizers, and re-export the adapter from @effect/platform-node.
2026-09-24 01:00:39 +00:00
Tim Smart cfffeacaf7 refactor: simplify DatagramSocket core ownership and error paths
- gate reader exclusivity with a Latch instead of a hand-rolled waiter set
- register the scope finalizer only after the handle exists; the orphaned
  open path frees the slot from the open fiber's observer
- cache the sticky failure exit instead of rebuilding it per pull/write
- derive scopeIds from the handle, share the payload encoder, drop the
  redundant closed guards and per-write try/catch (the run loop already
  turns a throwing register into a defect)
2026-09-24 01:00:39 +00:00
Tim Smart 772761bc7b test(deno): specify DatagramSocket adapter contract 2026-09-24 01:00:39 +00:00
Tim Smart 3eb36dfe03 test: add NodeDatagramSocket loopback tests and API stubs 2026-09-24 01:00:39 +00:00
Tim Smart 0e18a181ba Add Bun DatagramSocket adapter contract tests and signatures 2026-09-24 01:00:39 +00:00
Tim Smart 67eae643c4 fix: hold DatagramSocket reader ownership, serve pulls FIFO and use callback sends 2026-09-24 01:00:39 +00:00
Tim Smart 53d8d849ef test: cover DatagramSocket ownership and callback send regressions 2026-09-24 01:00:39 +00:00
Tim Smart 163687c814 feat: implement DatagramSocket core module 2026-09-24 01:00:39 +00:00
Tim Smart 2556f7b4c7 test: define DatagramSocket API and native handle contract 2026-09-24 01:00:39 +00:00
Tim Smart e1bbb36a99 fix: bound IPv6 dotted-tail detection to address 2026-09-24 01:00:39 +00:00
Tim Smart 811f2cc63c test: cover dotted IPv6 scope names in native addresses 2026-09-24 01:00:39 +00:00
Tim Smart 6e4b9a3578 feat: parse trusted native socket addresses directly 2026-09-24 01:00:39 +00:00
Tim Smart 2f0b7e7cce test: assert unknown native IPv6 zone error 2026-09-24 01:00:39 +00:00
Tim Smart 1ff53afe42 test: cover native address edge cases and unknown zones 2026-09-24 01:00:39 +00:00