obs: attribute NVMe write phases

This commit is contained in:
pingqiu committed 2026-08-01 04:05:08 -07:00
1 parent c8beef0e13
commit 3ae66df58d
6 files changed
+289 -37

No files matched your search

@@ -70,6 +70,20 @@ type phase174NVMeFixedWorkResult struct {
NVMeR2TWriteBytes uint64 `json:"nvme_r2t_write_bytes"`
NVMeH2CDataPDUs uint64 `json:"nvme_h2c_data_pdus"`
NVMeH2CDataBytes uint64 `json:"nvme_h2c_data_bytes"`
NVMeCapsuleReceiveParseOps uint64 `json:"nvme_capsule_receive_parse_ops"`
NVMeCapsuleReceiveParseNanos uint64 `json:"nvme_capsule_receive_parse_ns"`
NVMeR2TCollectionOps uint64 `json:"nvme_r2t_collection_ops"`
NVMeR2TCollectionNanos uint64 `json:"nvme_r2t_collection_ns"`
NVMeDispatchWaitOps uint64 `json:"nvme_dispatch_wait_ops"`
NVMeDispatchWaitNanos uint64 `json:"nvme_dispatch_wait_ns"`
NVMeHandlerOps uint64 `json:"nvme_handler_ops"`
NVMeHandlerNanos uint64 `json:"nvme_handler_ns"`
NVMeCompletionQueueWaitOps uint64 `json:"nvme_completion_queue_wait_ops"`
NVMeCompletionQueueWaitNanos uint64 `json:"nvme_completion_queue_wait_ns"`
NVMeCompletionSendOps uint64 `json:"nvme_completion_send_ops"`
NVMeCompletionSendNanos uint64 `json:"nvme_completion_send_ns"`
NVMeServerPhaseNanos uint64 `json:"nvme_server_phase_ns"`
NVMeClientResidualNanos uint64 `json:"nvme_client_residual_ns"`
TargetWriteOps uint64 `json:"target_write_ops"`
TargetWriteBytes uint64 `json:"target_write_bytes"`
TargetWriteNanos uint64 `json:"target_write_ns"`
@@ -215,7 +229,7 @@ func phase174RunNVMeFixedWork(
if err != nil {
t.Fatalf("measured writes: %v", err)
}
targetAfter := target.Stats()
targetAfter := phase174NVMeWaitForWritePhases(t, target, targetBefore, phase174NVMeAPIOperations)
adapterAfter := backend.WriteProfile()
storageAfter := store.WriteInstrumentation()
flusherAfter := store.FlusherInstrumentation()
@@ -244,6 +258,17 @@ func phase174RunNVMeFixedWork(
if clientLatencyNanos > targetWriteNanos {
nonBackendNanos = clientLatencyNanos - targetWriteNanos
}
serverPhaseNanos :=
(targetAfter.WriteCapsuleReceiveParseNanos - targetBefore.WriteCapsuleReceiveParseNanos) +
(targetAfter.R2TDataCollectionNanos - targetBefore.R2TDataCollectionNanos) +
(targetAfter.WriteDispatchWaitNanos - targetBefore.WriteDispatchWaitNanos) +
(targetAfter.WriteHandlerNanos - targetBefore.WriteHandlerNanos) +
(targetAfter.WriteCompletionQueueWaitNanos - targetBefore.WriteCompletionQueueWaitNanos) +
(targetAfter.WriteCompletionSendNanos - targetBefore.WriteCompletionSendNanos)
clientResidualNanos := uint64(0)
if clientLatencyNanos > serverPhaseNanos {
clientResidualNanos = clientLatencyNanos - serverPhaseNanos
}
result := phase174NVMeFixedWorkResult{
Contract: "phase174-fixed-work-v1", Layer: "nvme_tcp_rf1",
Scope: "nvme_tcp_target_durable_adapter", AckProfile: "local_durable",
@@ -261,6 +286,20 @@ func phase174RunNVMeFixedWork(
NVMeR2TWriteBytes: targetAfter.R2TWriteBytes - targetBefore.R2TWriteBytes,
NVMeH2CDataPDUs: targetAfter.H2CDataPDUs - targetBefore.H2CDataPDUs,
NVMeH2CDataBytes: targetAfter.H2CDataBytes - targetBefore.H2CDataBytes,
NVMeCapsuleReceiveParseOps: targetAfter.WriteCapsuleReceiveParseOps - targetBefore.WriteCapsuleReceiveParseOps,
NVMeCapsuleReceiveParseNanos: targetAfter.WriteCapsuleReceiveParseNanos - targetBefore.WriteCapsuleReceiveParseNanos,
NVMeR2TCollectionOps: targetAfter.R2TDataCollectionOps - targetBefore.R2TDataCollectionOps,
NVMeR2TCollectionNanos: targetAfter.R2TDataCollectionNanos - targetBefore.R2TDataCollectionNanos,
NVMeDispatchWaitOps: targetAfter.WriteDispatchWaitOps - targetBefore.WriteDispatchWaitOps,
NVMeDispatchWaitNanos: targetAfter.WriteDispatchWaitNanos - targetBefore.WriteDispatchWaitNanos,
NVMeHandlerOps: targetAfter.WriteHandlerOps - targetBefore.WriteHandlerOps,
NVMeHandlerNanos: targetAfter.WriteHandlerNanos - targetBefore.WriteHandlerNanos,
NVMeCompletionQueueWaitOps: targetAfter.WriteCompletionQueueWaitOps - targetBefore.WriteCompletionQueueWaitOps,
NVMeCompletionQueueWaitNanos: targetAfter.WriteCompletionQueueWaitNanos - targetBefore.WriteCompletionQueueWaitNanos,
NVMeCompletionSendOps: targetAfter.WriteCompletionSendOps - targetBefore.WriteCompletionSendOps,
NVMeCompletionSendNanos: targetAfter.WriteCompletionSendNanos - targetBefore.WriteCompletionSendNanos,
NVMeServerPhaseNanos: serverPhaseNanos,
NVMeClientResidualNanos: clientResidualNanos,
TargetWriteOps: adapterAfter.TargetWriteOps - adapterBefore.TargetWriteOps,
TargetWriteBytes: adapterAfter.TargetWriteBytes - adapterBefore.TargetWriteBytes,
TargetWriteNanos: targetWriteNanos,
@@ -293,6 +332,30 @@ func phase174RunNVMeFixedWork(
return result
}
func phase174NVMeWaitForWritePhases(
t *testing.T,
target *nvme.Target,
before nvme.Stats,
want uint64,
) nvme.Stats {
t.Helper()
deadline := time.Now().Add(time.Second)
for {
after := target.Stats()
if after.WriteCapsuleReceiveParseOps-before.WriteCapsuleReceiveParseOps >= want &&
after.WriteDispatchWaitOps-before.WriteDispatchWaitOps >= want &&
after.WriteHandlerOps-before.WriteHandlerOps >= want &&
after.WriteCompletionQueueWaitOps-before.WriteCompletionQueueWaitOps >= want &&
after.WriteCompletionSendOps-before.WriteCompletionSendOps >= want {
return after
}
if time.Now().After(deadline) {
t.Fatalf("write phase stats did not reach %d: before=%+v after=%+v", want, before, after)
}
time.Sleep(time.Millisecond)
}
}
func phase174NVMeWrites(
t *testing.T,
client *multiQueueClient,
@@ -424,15 +487,21 @@ func phase174NVMeValidateResult(t *testing.T, result phase174NVMeFixedWorkResult
wantOps := uint64(phase174NVMeAPIOperations)
wantBytes := uint64(phase174NVMeAPIOperations * phase174NVMeBlockSize)
for name, got := range map[string]uint64{
"nvme_write_commands": result.NVMeWriteCommands,
"nvme_r2t_write_commands": result.NVMeR2TWriteCommands,
"nvme_h2c_data_pdus": result.NVMeH2CDataPDUs,
"target_write_ops": result.TargetWriteOps,
"adapter_request_ops": result.AdapterRequestOps,
"adapter_write_ops": result.AdapterWriteOps,
"adapter_storage_write_calls": result.AdapterStorageCalls,
"adapter_storage_write_blocks": result.AdapterStorageBlocks,
"primary_wal_write_ops": result.PrimaryWALWrites,
"nvme_write_commands": result.NVMeWriteCommands,
"nvme_r2t_write_commands": result.NVMeR2TWriteCommands,
"nvme_h2c_data_pdus": result.NVMeH2CDataPDUs,
"nvme_capsule_receive_parse_ops": result.NVMeCapsuleReceiveParseOps,
"nvme_r2t_collection_ops": result.NVMeR2TCollectionOps,
"nvme_dispatch_wait_ops": result.NVMeDispatchWaitOps,
"nvme_handler_ops": result.NVMeHandlerOps,
"nvme_completion_queue_wait_ops": result.NVMeCompletionQueueWaitOps,
"nvme_completion_send_ops": result.NVMeCompletionSendOps,
"target_write_ops": result.TargetWriteOps,
"adapter_request_ops": result.AdapterRequestOps,
"adapter_write_ops": result.AdapterWriteOps,
"adapter_storage_write_calls": result.AdapterStorageCalls,
"adapter_storage_write_blocks": result.AdapterStorageBlocks,
"primary_wal_write_ops": result.PrimaryWALWrites,
} {
if got != wantOps {
t.Fatalf("%s=%d want %d", name, got, wantOps)
@@ -453,6 +522,11 @@ func phase174NVMeValidateResult(t *testing.T, result phase174NVMeFixedWorkResult
t.Fatalf("recovery stable=%d head=%d samples=%d",
result.PrimaryStableLSN, result.PrimaryHeadLSN, result.CorrectnessSamples)
}
if result.NVMeServerPhaseNanos > result.ClientWriteLatencyNanos ||
result.NVMeClientResidualNanos != result.ClientWriteLatencyNanos-result.NVMeServerPhaseNanos {
t.Fatalf("NVMe phase time does not reconcile: client=%d server=%d residual=%d",
result.ClientWriteLatencyNanos, result.NVMeServerPhaseNanos, result.NVMeClientResidualNanos)
}
}
func phase174NVMeValidateWriters(writers int) error {
+71 -6
View File
@@ -67,6 +67,7 @@ import (
"net"
"sync"
"sync/atomic"
"time"
)
// errDisconnect is a sentinel returned by handleDisconnect (BUG-002)
@@ -76,10 +77,11 @@ var errDisconnect = errors.New("disconnect")
// Request represents an in-flight NVMe command being processed.
type Request struct {
capsule CapsuleCommand
payload []byte // inline/R2T-collected data for Write
resp CapsuleResponse
c2hData []byte // non-nil for Read/Identify responses
capsule CapsuleCommand
payload []byte // inline/R2T-collected data for Write
resp CapsuleResponse
c2hData []byte // non-nil for Read/Identify responses
dispatchReadyAt time.Time
}
// response represents a pending response to be written by txLoop.
@@ -92,6 +94,9 @@ type response struct {
r2t *R2THeader
r2tDone chan struct{}
writeCompletion bool
queuedAt time.Time
}
// Session carries per-connection NVMe/TCP state.
@@ -249,6 +254,7 @@ func (s *Session) rxLoop(ctx context.Context) error {
}
func (s *Session) parseCapsule() (*Request, error) {
start := time.Now()
var capsule CapsuleCommand
if err := s.wire.Receive(&capsule); err != nil {
return nil, err
@@ -262,6 +268,9 @@ func (s *Session) parseCapsule() (*Request, error) {
}
req := &Request{capsule: capsule, payload: payload}
req.resp.CID = capsule.CID
if s.qid > 0 && capsule.OpCode == ioWrite {
s.recordWriteCapsuleReceiveParse(time.Since(start))
}
return req, nil
}
@@ -312,6 +321,7 @@ func (s *Session) dispatchFromRx(ctx context.Context, req *Request) error {
} else {
s.recordInlineWrite(uint32(len(req.payload)))
}
req.dispatchReadyAt = time.Now()
}
s.cmdWg.Add(1)
@@ -328,6 +338,7 @@ func (s *Session) dispatchFromRx(ctx context.Context, req *Request) error {
// blocks rxLoop; pipelined Cmds arriving during this window are
// absorbed into pendingCapsules by bufferInterleaved.
func (s *Session) collectR2TData(req *Request) error {
start := time.Now()
totalBytes := req.capsule.LbaLength() * s.handler.BlockSize()
r2tDone := make(chan struct{})
@@ -356,6 +367,7 @@ func (s *Session) collectR2TData(req *Request) error {
return err
}
req.payload = data
s.recordR2TDataCollection(time.Since(start))
return nil
}
@@ -521,6 +533,9 @@ func (s *Session) writeResponse(resp *response) error {
} else {
resp.resp.SQHD = uint16(s.sqhd.Load())
}
if resp.writeCompletion {
s.recordWriteCompletionQueueWait(time.Since(resp.queuedAt))
}
if len(resp.c2hData) > 0 {
s.recordC2HData(uint32(len(resp.c2hData)))
@@ -533,7 +548,12 @@ func (s *Session) writeResponse(resp *response) error {
return err
}
}
return s.wire.SendHeaderOnly(pduCapsuleResp, &resp.resp, capsuleRespSize)
sendStart := time.Now()
err := s.wire.SendHeaderOnly(pduCapsuleResp, &resp.resp, capsuleRespSize)
if resp.writeCompletion {
s.recordWriteCompletionSend(time.Since(sendStart))
}
return err
}
func (s *Session) enqueueResponse(resp *response) {
@@ -563,6 +583,8 @@ func (s *Session) handleRead(ctx context.Context, req *Request) {
func (s *Session) handleWrite(ctx context.Context, req *Request) {
s.recordWriteCommand()
s.recordWriteDispatchWait(time.Since(req.dispatchReadyAt))
handlerStart := time.Now()
res := s.handler.Handle(ctx, IOCommand{
Opcode: req.capsule.OpCode,
NSID: req.capsule.NSID,
@@ -570,10 +592,11 @@ func (s *Session) handleWrite(ctx context.Context, req *Request) {
NLB: req.capsule.LbaLength(),
Data: req.payload,
})
s.recordWriteHandler(time.Since(handlerStart))
if res.AsError() != nil {
req.resp.Status = MakeStatusField(res.SCT, res.SC, true)
}
s.enqueueResponse(&response{resp: req.resp})
s.enqueueResponse(&response{resp: req.resp, writeCompletion: true, queuedAt: time.Now()})
}
// ---------- Fabric ----------
@@ -765,6 +788,48 @@ func (s *Session) recordC2HData(bytes uint32) {
}
}
func (s *Session) recordWriteCapsuleReceiveParse(d time.Duration) {
if s.target != nil {
s.target.stats.writeCapsuleReceiveParseOps.Add(1)
s.target.stats.writeCapsuleReceiveParseNanos.Add(statsDurationNanos(d))
}
}
func (s *Session) recordR2TDataCollection(d time.Duration) {
if s.target != nil {
s.target.stats.r2tDataCollectionOps.Add(1)
s.target.stats.r2tDataCollectionNanos.Add(statsDurationNanos(d))
}
}
func (s *Session) recordWriteDispatchWait(d time.Duration) {
if s.target != nil {
s.target.stats.writeDispatchWaitOps.Add(1)
s.target.stats.writeDispatchWaitNanos.Add(statsDurationNanos(d))
}
}
func (s *Session) recordWriteHandler(d time.Duration) {
if s.target != nil {
s.target.stats.writeHandlerOps.Add(1)
s.target.stats.writeHandlerNanos.Add(statsDurationNanos(d))
}
}
func (s *Session) recordWriteCompletionQueueWait(d time.Duration) {
if s.target != nil {
s.target.stats.writeCompletionQueueWaitOps.Add(1)
s.target.stats.writeCompletionQueueWaitNanos.Add(statsDurationNanos(d))
}
}
func (s *Session) recordWriteCompletionSend(d time.Duration) {
if s.target != nil {
s.target.stats.writeCompletionSendOps.Add(1)
s.target.stats.writeCompletionSendNanos.Add(statsDurationNanos(d))
}
}
// handleDisconnect (BUG-002).
func (s *Session) handleDisconnect(req *Request) error {
if s.logger != nil && s.ctrl != nil {
+68 -16
View File
@@ -1,12 +1,19 @@
package nvme
import "sync/atomic"
import (
"sync/atomic"
"time"
)
// Stats is a snapshot of target-level NVMe/TCP activity.
//
// It is intentionally transport-focused, not a performance API. The first use
// is lab evidence: after a real Linux initiator run, we need to know whether
// writes arrived inline in the capsule or through R2T/H2CData.
// writes arrived inline in the capsule or through R2T/H2CData. Phase timings
// are cumulative per-operation attribution evidence; concurrent phases can
// overlap in wall time and do not affect request handling. Capsule receive
// includes socket wait and decode. R2T collection includes target send,
// initiator response, and H2CData receive.
type Stats struct {
SessionsAccepted uint64 `json:"sessions_accepted"`
AdminConnects uint64 `json:"admin_connects"`
@@ -25,6 +32,19 @@ type Stats struct {
H2CDataBytes uint64 `json:"h2c_data_bytes"`
C2HDataPDUs uint64 `json:"c2h_data_pdus"`
C2HDataBytes uint64 `json:"c2h_data_bytes"`
WriteCapsuleReceiveParseOps uint64 `json:"write_capsule_receive_parse_ops"`
WriteCapsuleReceiveParseNanos uint64 `json:"write_capsule_receive_parse_ns"`
R2TDataCollectionOps uint64 `json:"r2t_data_collection_ops"`
R2TDataCollectionNanos uint64 `json:"r2t_data_collection_ns"`
WriteDispatchWaitOps uint64 `json:"write_dispatch_wait_ops"`
WriteDispatchWaitNanos uint64 `json:"write_dispatch_wait_ns"`
WriteHandlerOps uint64 `json:"write_handler_ops"`
WriteHandlerNanos uint64 `json:"write_handler_ns"`
WriteCompletionQueueWaitOps uint64 `json:"write_completion_queue_wait_ops"`
WriteCompletionQueueWaitNanos uint64 `json:"write_completion_queue_wait_ns"`
WriteCompletionSendOps uint64 `json:"write_completion_send_ops"`
WriteCompletionSendNanos uint64 `json:"write_completion_send_ns"`
}
type targetStats struct {
@@ -45,6 +65,19 @@ type targetStats struct {
h2cDataBytes atomic.Uint64
c2hDataPDUs atomic.Uint64
c2hDataBytes atomic.Uint64
writeCapsuleReceiveParseOps atomic.Uint64
writeCapsuleReceiveParseNanos atomic.Uint64
r2tDataCollectionOps atomic.Uint64
r2tDataCollectionNanos atomic.Uint64
writeDispatchWaitOps atomic.Uint64
writeDispatchWaitNanos atomic.Uint64
writeHandlerOps atomic.Uint64
writeHandlerNanos atomic.Uint64
writeCompletionQueueWaitOps atomic.Uint64
writeCompletionQueueWaitNanos atomic.Uint64
writeCompletionSendOps atomic.Uint64
writeCompletionSendNanos atomic.Uint64
}
func (s *targetStats) snapshot() Stats {
@@ -52,19 +85,38 @@ func (s *targetStats) snapshot() Stats {
return Stats{}
}
return Stats{
SessionsAccepted: s.sessionsAccepted.Load(),
AdminConnects: s.adminConnects.Load(),
IOConnects: s.ioConnects.Load(),
ReadCommands: s.readCommands.Load(),
WriteCommands: s.writeCommands.Load(),
FlushCommands: s.flushCommands.Load(),
InlineWriteCommands: s.inlineWriteCommands.Load(),
InlineWriteBytes: s.inlineWriteBytes.Load(),
R2TWriteCommands: s.r2tWriteCommands.Load(),
R2TWriteBytes: s.r2tWriteBytes.Load(),
H2CDataPDUs: s.h2cDataPDUs.Load(),
H2CDataBytes: s.h2cDataBytes.Load(),
C2HDataPDUs: s.c2hDataPDUs.Load(),
C2HDataBytes: s.c2hDataBytes.Load(),
SessionsAccepted: s.sessionsAccepted.Load(),
AdminConnects: s.adminConnects.Load(),
IOConnects: s.ioConnects.Load(),
ReadCommands: s.readCommands.Load(),
WriteCommands: s.writeCommands.Load(),
FlushCommands: s.flushCommands.Load(),
InlineWriteCommands: s.inlineWriteCommands.Load(),
InlineWriteBytes: s.inlineWriteBytes.Load(),
R2TWriteCommands: s.r2tWriteCommands.Load(),
R2TWriteBytes: s.r2tWriteBytes.Load(),
H2CDataPDUs: s.h2cDataPDUs.Load(),
H2CDataBytes: s.h2cDataBytes.Load(),
C2HDataPDUs: s.c2hDataPDUs.Load(),
C2HDataBytes: s.c2hDataBytes.Load(),
WriteCapsuleReceiveParseOps: s.writeCapsuleReceiveParseOps.Load(),
WriteCapsuleReceiveParseNanos: s.writeCapsuleReceiveParseNanos.Load(),
R2TDataCollectionOps: s.r2tDataCollectionOps.Load(),
R2TDataCollectionNanos: s.r2tDataCollectionNanos.Load(),
WriteDispatchWaitOps: s.writeDispatchWaitOps.Load(),
WriteDispatchWaitNanos: s.writeDispatchWaitNanos.Load(),
WriteHandlerOps: s.writeHandlerOps.Load(),
WriteHandlerNanos: s.writeHandlerNanos.Load(),
WriteCompletionQueueWaitOps: s.writeCompletionQueueWaitOps.Load(),
WriteCompletionQueueWaitNanos: s.writeCompletionQueueWaitNanos.Load(),
WriteCompletionSendOps: s.writeCompletionSendOps.Load(),
WriteCompletionSendNanos: s.writeCompletionSendNanos.Load(),
}
}
func statsDurationNanos(d time.Duration) uint64 {
if d <= 0 {
return 0
}
return uint64(d.Nanoseconds())
}
+35 -1
View File
@@ -2,6 +2,7 @@ package nvme_test
import (
"testing"
"time"
"github.com/seaweedfs/seaweed-block/core/frontend"
"github.com/seaweedfs/seaweed-block/core/frontend/nvme"
@@ -45,7 +46,7 @@ func TestTargetStats_RecordInlineAndR2TWrites(t *testing.T) {
status = writeChunkedOnClient(t, cli, 1, 2, r2tPayload, 2)
expectStatusSuccess(t, status, "R2T Write")
st := tg.Stats()
st := waitForWritePhaseStats(t, tg, 2)
if st.AdminConnects != 1 || st.IOConnects != 1 {
t.Fatalf("connect stats admin=%d io=%d want 1/1", st.AdminConnects, st.IOConnects)
}
@@ -64,6 +65,39 @@ func TestTargetStats_RecordInlineAndR2TWrites(t *testing.T) {
t.Fatalf("h2c stats pdus=%d bytes=%d want 2/%d",
st.H2CDataPDUs, st.H2CDataBytes, len(r2tPayload))
}
for name, got := range map[string]uint64{
"write capsule receive/parse": st.WriteCapsuleReceiveParseOps,
"write dispatch wait": st.WriteDispatchWaitOps,
"write handler": st.WriteHandlerOps,
"write completion queue wait": st.WriteCompletionQueueWaitOps,
"write completion send": st.WriteCompletionSendOps,
} {
if got != 2 {
t.Fatalf("%s ops=%d want 2", name, got)
}
}
if st.R2TDataCollectionOps != 1 {
t.Fatalf("R2T data collection ops=%d want 1", st.R2TDataCollectionOps)
}
}
func waitForWritePhaseStats(t *testing.T, target *nvme.Target, want uint64) nvme.Stats {
t.Helper()
deadline := time.Now().Add(time.Second)
for {
stats := target.Stats()
if stats.WriteCapsuleReceiveParseOps >= want &&
stats.WriteDispatchWaitOps >= want &&
stats.WriteHandlerOps >= want &&
stats.WriteCompletionQueueWaitOps >= want &&
stats.WriteCompletionSendOps >= want {
return stats
}
if time.Now().After(deadline) {
t.Fatalf("write phase stats did not reach %d: %+v", want, stats)
}
time.Sleep(time.Millisecond)
}
}
func TestTargetStats_RecordReadAndFlush(t *testing.T) {
@@ -45,15 +45,21 @@ SW_BLOCK_PHASE174_SOURCE_COMMIT=<full-source-commit> \
time plus NVMe/TCP round-trip non-backend time. The latter includes test
initiator, loopback TCP, R2T/H2C receive, dispatch, and completion; do not
relabel it as a pure target CPU measurement.
6. Final NVMe Flush succeeds, close/reopen/recovery reaches `R == H`, and at
6. The detailed target counters each report 16,384 operations and split the
server path into capsule receive/parse, R2T data collection, dispatch wait,
handler, completion queue wait, and completion send. Capsule receive/parse
includes inbound socket wait; R2T collection includes target/initiator/wire
exchange time. Their sum must not exceed accumulated client request latency;
the exact difference is the remaining client/wire residual.
7. Final NVMe Flush succeeds, close/reopen/recovery reaches `R == H`, and at
least five measured LBAs retain the expected bytes.
7. Capture merged CPU, block, and mutex profiles for five four-queue diagnostic
8. Capture merged CPU, block, and mutex profiles for five four-queue diagnostic
runs.
8. Record the four-writer admission stability and all-shapes stability
9. Record the four-writer admission stability and all-shapes stability
separately. A range above `1.25x` is HOLD evidence, not a reason to delete
a slow run or select an architecture candidate. Correlate four/eight-writer
foreground time with the existing WAL flusher counters.
9. All test stores and the test binary are removed after the gate.
10. All test stores and the test binary are removed after the gate.
## Mounted Boundary
@@ -185,6 +185,8 @@ for row in rows:
raise SystemExit(f"bad fixed work: {row}")
for key in (
"nvme_write_commands", "nvme_r2t_write_commands", "nvme_h2c_data_pdus",
"nvme_capsule_receive_parse_ops", "nvme_r2t_collection_ops", "nvme_dispatch_wait_ops",
"nvme_handler_ops", "nvme_completion_queue_wait_ops", "nvme_completion_send_ops",
"target_write_ops", "adapter_request_ops", "adapter_write_ops",
"adapter_storage_write_calls", "adapter_storage_write_blocks",
"primary_wal_write_ops",
@@ -201,6 +203,10 @@ for row in rows:
raise SystemExit(f"target duration exceeds client duration: {row}")
if row["nvme_round_trip_nonbackend_ns"] != row["client_write_latency_ns"] - row["target_write_ns"]:
raise SystemExit(f"non-backend duration mismatch: {row}")
if row["nvme_server_phase_ns"] > row["client_write_latency_ns"]:
raise SystemExit(f"server phase duration exceeds client duration: {row}")
if row["nvme_client_residual_ns"] != row["client_write_latency_ns"] - row["nvme_server_phase_ns"]:
raise SystemExit(f"client residual duration mismatch: {row}")
if row["primary_stable_lsn"] != row["primary_head_lsn"]:
raise SystemExit(f"primary frontier mismatch: {row}")
if not row["flusher_phase_reset"] or not row["close_recover_complete"]:
@@ -254,6 +260,16 @@ all_shapes_stable = all(
target_per_op = median_per_op(four, "target_write_ns")
roundtrip_per_op = median_per_op(four, "nvme_round_trip_nonbackend_ns")
dominant = "target_backend_call" if target_per_op >= roundtrip_per_op else "nvme_tcp_round_trip_nonbackend"
phase_fields = {
"capsule_receive_parse": "nvme_capsule_receive_parse_ns",
"r2t_collection": "nvme_r2t_collection_ns",
"dispatch_wait": "nvme_dispatch_wait_ns",
"handler": "nvme_handler_ns",
"completion_queue_wait": "nvme_completion_queue_wait_ns",
"completion_send": "nvme_completion_send_ns",
"client_residual": "nvme_client_residual_ns",
}
dominant_phase = max(phase_fields, key=lambda name: median_per_op(four, phase_fields[name]))
with open(summary_path, "a", encoding="utf-8") as out:
for writers in (1, 4, 8):
@@ -263,6 +279,9 @@ with open(summary_path, "a", encoding="utf-8") as out:
out.write(f"nvme_tcp_rf1_writers_{writers}_set2_max_min_ratio={rate_range(writers, 2):.3f}\n")
for field in (
"client_write_latency_ns", "nvme_round_trip_nonbackend_ns", "target_write_ns",
"nvme_capsule_receive_parse_ns", "nvme_r2t_collection_ns", "nvme_dispatch_wait_ns",
"nvme_handler_ns", "nvme_completion_queue_wait_ns", "nvme_completion_send_ns",
"nvme_server_phase_ns", "nvme_client_residual_ns",
"adapter_write_ns", "primary_write_commit_lock_wait_ns", "primary_wal_encode_ns",
"primary_wal_append_ns", "primary_dirty_map_ns", "foreground_flusher_cycle_ns",
"foreground_flusher_extent_write_ns", "foreground_flusher_extent_sync_ns",
@@ -272,7 +291,9 @@ with open(summary_path, "a", encoding="utf-8") as out:
out.write(f"nvme_tcp_rf1_writers_8_flusher_cycle_ns_per_op={median_per_op(eight, 'foreground_flusher_cycle_ns'):.3f}\n")
out.write(f"nvme_tcp_rf1_writers_8_flusher_foreground_correlation={correlation(eight, 'foreground_flusher_cycle_ns'):.3f}\n")
out.write(f"nvme_tcp_rf1_dominant_accumulated_boundary={dominant}\n")
out.write(f"nvme_tcp_rf1_dominant_detailed_phase={dominant_phase}\n")
out.write("nvme_tcp_rf1_counter_reconciliation=true\n")
out.write("nvme_tcp_rf1_phase_counter_reconciliation=true\n")
out.write("nvme_tcp_rf1_close_recover_verified=true\n")
out.write(f"nvme_tcp_rf1_four_writer_stability_gate={'pass' if four_stable else 'hold'}\n")
out.write(f"nvme_tcp_rf1_all_shapes_stability_gate={'pass' if all_shapes_stable else 'hold'}\n")