Commit ef84e01
committed
perf(fiber-da): skip flatten allocation on single-item Submit; honor ctx
Three changes in fiber_client.go::Submit, all hot-path correctness/
efficiency wins surfaced while debugging Fibre throughput:
1. Single-item fast path that bypasses flattenBlobs.
For data blobs, limitBatchBySize already caps each Submit call at
one item (each block's data already saturates MaxBlobBytes). The
flatten step was therefore allocating MaxBlobSize bytes and
memcpy'ing the entire payload solely to prepend the 8-byte
count/length prefix used by splitBlobs. At 128 MiB blocks that's
~128 MB held in two places at once during every Upload. The fast
path passes data[0] straight through and saves the full copy.
Wire-format caveat: a retriever (full-node syncer or light client)
downloading a blob written via this fast path can't decode it —
splitBlobs always expects the prefix. The right fix is to pair
this with a per-item Upload model so flatten falls away entirely;
tracked as a TODO in the source pointing at the concurrent-uploads
work where that lands naturally.
2. Honor caller's ctx in Upload.
The previous context.Background() kept Uploads alive past node
shutdown and was the proximate cause of the "payment promise
already processed" warnings — a stale Upload would settle on-chain
after ev-node had already moved on. Threading the caller's ctx
makes shutdown promptly cancel in-flight Uploads.
3. Correct SubmittedCount on error.
On a full-Upload failure the result reported len(data)-1 as
submitted, which both reads weirdly for len==1 (uint64 underflow
risk in any future arithmetic) and lies to submitToDA's
prefix-of-success retry advance. Reset to 0 on error.
No behaviour change for the multi-item retrieve path (flatten still
runs when len > 1). Validated via go build / go vet.1 parent 44e977a commit ef84e01
1 file changed
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
91 | 106 | | |
92 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
93 | 114 | | |
94 | 115 | | |
95 | 116 | | |
| |||
103 | 124 | | |
104 | 125 | | |
105 | 126 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
109 | 133 | | |
110 | 134 | | |
111 | 135 | | |
| |||
0 commit comments