Skip to content

First Fin-FinAck Support - #46

Merged
franklee26 merged 11 commits into
mainfrom
frank/fin-ack
May 15, 2026
Merged

franklee26 merged 11 commits into
mainfrom
frank/fin-ack

Conversation

@franklee26

@franklee26 franklee26 commented May 15, 2026 •

Copy link
Copy Markdown
Owner
        sender side                          receiver side
       ─────────────                        ───────────────
       OPEN                                  OPEN
         │  user calls close()                │
         │  ───── flush() ──────────────►     │
         │  ───── Fin(pn=N) ─────────────►    │  (recv_bytes drains buffer)
         │                                    │  recv → Ok(0)  (EOF surfaced)
       FIN_SENT                                │
         │                                  FIN_OBSERVED
         │  ◄──── FinAck(pn=N) ──────────     │  (conn_reader auto-emits)
         │                                    │
         │  remove from ConnectionManager   remove from ConnectionManager
       CLOSED                                CLOSED
                          ┌──────────────────────────────┐
 user code  ──send()────► │ writer queue (flume bounded) │ ──► WriterHandler
 user code  ──close() ─┐  └──────────────────────────────┘         │
                       │                                            │ send_fin(pn)
                       │  flush() → reserve_close_pn → ─────────────┤
                       │                                            ▼
                       │                                       UDP socket
                       │                                            │
                       │     ┌────────────────────────────┐         │  (peer)
                       │     │ await_fin_ack(pn, 200ms)   │ ◄───────┤
                       │     └────────────────────────────┘         │
                       │             ▲                              │
                       │             │ peer's FinAck sets            │
                       │             │ local_fin_acked = true        │
                       │             │                               │
                       │     ┌──────────────────┐  fin_ack_tx        │
                       │     │  CloseBuffer     │ ◄────────────┐     │
                       │     │  - peer_fin_obs  │              │     │
                       │     │  - pending_fa_pn │              │     │
                       │     │  - local_fin_pn  │              │     │
                       │     │  - local_fin_acked│             │     │
                       │     └──────────────────┘              │     │
                       │             ▲                          │     │
                       │             │                          │     │
                       │   ┌─────────────────────────┐          │     │
                       │   │ buffer_in_close_packets │ ─────────┘     │
                       │   │ (in conn_reader)        │ ◄──────────────┤
                       │   └─────────────────────────┘ Fin/FinAck     │
                       │             │                                │
                       │             │ wake recv() if Fin              
                       │             ▼                                
                       └──► recv_bytes() returns Ok(0) when            
                            peer_fin_observed && data_buf empty       

@codecov

codecov Bot commented May 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.13095% with 194 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.13%. Comparing base (80c8310) to head (0ec514b).

Files with missing lines Patch % Lines
bluefintool/src/main.rs 53.33% 63 Missing ⚠️
bluefin/src/bin/client.rs 0.00% 37 Missing ⚠️
bluefin/src/net/close_handler.rs 78.23% 32 Missing ⚠️
bluefin/src/bin/server.rs 0.00% 24 Missing ⚠️
bluefin/src/net/connection.rs 76.27% 14 Missing ⚠️
bluefin/src/worker/reader.rs 60.00% 10 Missing ⚠️
bluefin/src/worker/writer.rs 81.81% 10 Missing ⚠️
bluefin/src/worker/conn_reader.rs 97.10% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
+ Coverage   63.74%   69.13%   +5.39%     
==========================================
  Files          23       24       +1     
  Lines        3194     3833     +639     
==========================================
+ Hits         2036     2650     +614     
- Misses       1158     1183      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown

Bluefin throughput bench (macOS) ✅ PASS

Config: 5 run(s) × 2 conn(s) on Darwin arm64

Client throttle: 25 µs sleep every 3000 sends

Retries: 4 of 5 run(s) needed retry (+6 extra attempt(s)). See per-run table.

why retries vary across runs

Hosted CI runners occasionally land on a deeply contended host where both bench peers get starved and a run produces 0 GOOD conns despite no actual code regression. To absorb this without weakening the gate, this job uses an asymmetric retry policy (current values: ON_ZERO=2, ON_PARTIAL=0, backoff 5s):

attempt outcome extra retries granted
all 2 conns good 0 (accept)
1..1 conns good (partial) up to ON_PARTIAL=0
0 conns good (catastrophic) up to ON_ZERO=2

The retry budget is per-run and only shrinks across attempts: once a partial-good attempt has been observed in a run, that run is locked to the partial budget for the rest of its attempts -- it can never be promoted to the larger 0-good budget by a later attempt happening to collapse to 0. Only the final attempt's data is committed to the aggregate stats; earlier attempts' logs are still on disk under the run's attempt_* directory but are not parsed.

So the same code can show 0, 1, or 2 retries on different CI runs purely from runner-allocation luck. The attempts column in the per-run table below shows how many attempts each run took (bold = needed at least one retry).

Aggregate

metric observed floor result
mean avg gb/s (good only) 0.475 0.40 ✅
raw mean avg gb/s 0.229 — —
min avg gb/s 0.039 — —
mean peak gb/s 0.917 — —
max peak gb/s (good only) 1.830 1.30 ✅
good conns 3 / 10 3 ✅

Per-run

run attempts good/N mean avg gb/s (good) max peak gb/s (good) raw max peak gb/s
1 3 0/2 — — 0.08
2 2 1/2 0.50 1.83 1.83
3 3 0/2 — — 1.11
4 2 1/2 0.46 1.40 1.40
5 1 1/2 0.47 1.53 1.53

A "good conn" delivered ≥ 700 MB before idle timeout.
"max peak (good only)" filters out kernel-buffer-drain artifacts
that appear as huge inst-throughput readings on starved conns under
runner CPU contention. Floors are env-var overridable:
BLUEFIN_BENCH_FLOOR_MEAN_AVG_GBPS, BLUEFIN_BENCH_FLOOR_MAX_PEAK_GBPS,
BLUEFIN_BENCH_FLOOR_GOOD_CONNS, BLUEFIN_BENCH_GOOD_CONN_MIN_BYTES.
Ratchet up after stable runs land. Script: bench_ci.sh.

@franklee26
franklee26 merged commit 6e8a0a4 into main May 15, 2026
7 checks passed
@franklee26
franklee26 deleted the frank/fin-ack branch May 15, 2026 23:12
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