Skip to content

Commit 62f1ea2

Browse files
committed
bundle: improve busy reporting
1 parent a5d9e06 commit 62f1ea2

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/disco/bundle/fd_bundle_client.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ fd_bundle_client_step( fd_bundle_tile_t * ctx,
256256
FD_LOG_INFO(( "Bundle gRPC connect attempt failed (%i-%s)", connect_err, fd_io_strerror( connect_err ) ));
257257
fd_bundle_client_reset( ctx );
258258
ctx->metrics.transport_fail_cnt++;
259-
*charge_busy =1 ;
259+
*charge_busy = 1;
260260
return;
261261
}
262262
if( pfds[0].revents & POLLOUT ) {
263263
FD_LOG_DEBUG(( "Bundle TCP socket connected" ));
264264
ctx->tcp_sock_connected = 1;
265-
*charge_busy =1 ;
265+
*charge_busy = 1;
266266
return;
267267
}
268268
return;
@@ -301,33 +301,34 @@ fd_bundle_client_step( fd_bundle_tile_t * ctx,
301301
}
302302
if( FD_UNLIKELY( ctx->auther.state!=FD_BUNDLE_AUTH_STATE_DONE_WAIT ) ) return;
303303

304-
*charge_busy = 1;
305-
306304
/* Request block builder info */
307305
if( FD_UNLIKELY( !ctx->builder_info_live && !ctx->builder_info_wait ) ) {
308306
fd_bundle_client_request_builder_info( ctx );
309-
return;
307+
goto busy_exit;
310308
}
311309

312310
/* Subscribe to packets */
313311
if( FD_UNLIKELY( !ctx->packet_subscription_live && !ctx->packet_subscription_wait ) ) {
314312
fd_bundle_client_subscribe_packets( ctx );
315-
return;
313+
goto busy_exit;
316314
}
317315

318316
/* Subscribe to bundles */
319317
if( FD_UNLIKELY( !ctx->bundle_subscription_live && !ctx->bundle_subscription_wait ) ) {
320318
fd_bundle_client_subscribe_bundles( ctx );
321-
return;
319+
goto busy_exit;
322320
}
323321

324322
/* Send a PING */
325323
if( FD_UNLIKELY( fd_bundle_client_keepalive_due( ctx, io_ts ) ) ) {
326324
fd_bundle_client_send_ping( ctx );
327-
return;
325+
goto busy_exit;
328326
}
329327

330-
*charge_busy = 0;
328+
return;
329+
busy_exit:
330+
*charge_busy = 1;
331+
return;
331332
}
332333

333334
void

src/disco/bundle/fd_bundle_tile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@ unprivileged_init( fd_topo_t * topo,
477477
}
478478

479479
/* Set socket receive buffer size */
480-
ulong so_rcvbuf = tile->bundle.buf_sz + 65536UL;
481-
if( so_rcvbuf > INT_MAX ) FD_LOG_ERR(( "Invalid [development.bundle.buffer_size_kib]: too large" ));
480+
ulong so_rcvbuf = tile->bundle.buf_sz;
481+
if( FD_UNLIKELY( so_rcvbuf < 2048UL ) ) FD_LOG_ERR(( "Invalid [development.bundle.buffer_size_kib]: too small" ));
482+
if( FD_UNLIKELY( so_rcvbuf > INT_MAX ) ) FD_LOG_ERR(( "Invalid [development.bundle.buffer_size_kib]: too large" ));
482483
ctx->so_rcvbuf = (int)so_rcvbuf;
483484

484485
/* Set idle ping timer */

src/waltz/grpc/fd_grpc_client.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,29 +194,37 @@ fd_grpc_client_rxtx_socket( fd_grpc_client_t * client,
194194
int sock_fd,
195195
int * charge_busy ) {
196196
fd_h2_conn_t * conn = client->conn;
197+
ulong const frame_rx_lo_0 = client->frame_rx->lo_off;
198+
ulong const frame_rx_hi_0 = client->frame_rx->hi_off;
199+
ulong const frame_tx_lo_1 = client->frame_tx->lo_off;
200+
ulong const frame_tx_hi_1 = client->frame_tx->hi_off;
197201

198-
ulong frame_rx_0 = client->frame_rx->hi_off;
199202
int rx_err = fd_h2_rbuf_recvmsg( client->frame_rx, sock_fd, MSG_NOSIGNAL|MSG_DONTWAIT );
200203
if( FD_UNLIKELY( rx_err ) ) {
201204
FD_LOG_INFO(( "Disconnected: recvmsg error (%i-%s)", rx_err, fd_io_strerror( rx_err ) ));
202205
return 0;
203206
}
204-
ulong frame_rx_1 = client->frame_rx->hi_off;
205-
if( frame_rx_0!=frame_rx_1 ) *charge_busy = 1;
206207

207208
if( FD_UNLIKELY( conn->flags ) ) fd_h2_tx_control( conn, client->frame_tx, &fd_grpc_client_h2_callbacks );
208209
fd_h2_rx( conn, client->frame_rx, client->frame_tx, client->frame_scratch, FD_GRPC_CLIENT_BUFSZ, &fd_grpc_client_h2_callbacks );
209210
fd_grpc_client_send_stream_window_updates( client );
210211

211-
ulong frame_tx_0 = client->frame_tx->lo_off;
212212
int tx_err = fd_h2_rbuf_sendmsg( client->frame_tx, sock_fd, MSG_NOSIGNAL|MSG_DONTWAIT );
213213
if( FD_UNLIKELY( tx_err ) ) {
214214
FD_LOG_WARNING(( "fd_h2_rbuf_sendmsg failed (%i-%s)", tx_err, fd_io_strerror( tx_err ) ));
215215
return 0;
216216
}
217-
ulong frame_tx_1 = client->frame_tx->lo_off;
218217

219-
if( frame_rx_0!=frame_rx_1 || frame_tx_0!=frame_tx_1 ) *charge_busy = 1;
218+
ulong const frame_rx_lo_1 = client->frame_rx->lo_off;
219+
ulong const frame_rx_hi_1 = client->frame_rx->hi_off;
220+
ulong const frame_tx_lo_0 = client->frame_tx->lo_off;
221+
ulong const frame_tx_hi_0 = client->frame_tx->hi_off;
222+
223+
if( frame_rx_lo_0!=frame_rx_lo_1 || frame_rx_hi_0!=frame_rx_hi_1 ||
224+
frame_tx_lo_0!=frame_tx_lo_1 || frame_tx_hi_0!=frame_tx_hi_1 ) {
225+
*charge_busy = 1;
226+
}
227+
220228
return 1;
221229
}
222230

0 commit comments

Comments
 (0)