Skip to content

Commit 007db59

Browse files
committed
gui: add end slot reason to slot details
1 parent 6d8a2f1 commit 007db59

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

book/api/websocket.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,7 @@ explicitly mentioned, skipped slots are not included.
20512051
"max_total_microblocks": 32768
20522052
},
20532053
"scheduler_stats": {
2054+
"end_slot_reason": "timeout",
20542055
"slot_schedule_counts": [123, 123, 123, 123, 123, 123, 123],
20552056
"end_slot_schedule_counts": [0, 10, 0, 0, 0, 0, 0],
20562057
"pending_smallest_cost": 3000,
@@ -2190,6 +2191,7 @@ explicitly mentioned, skipped slots are not included.
21902191
**`SlotScheduleStats`**
21912192
| Field | Type | Description |
21922193
|------------------------------|-------------------|-------------|
2194+
| end_slot_reason | `string` | The reason pack ended packing for this leader slot. One of `"timeout"`, `"microblock_limit"`, or `"leader_switch"` |
21932195
| slot_schedule_counts | `number[]` | `slot_schedule_counts[i]` is the number of transactions across the leader slot that had `["success", "fail_taken", "fail_fast_path", "fail_byte_limit", "fail_write_cost", "fail_slow_path", "fail_defer_skip"][i]` as the outcome after being scheduled. "success" means the transaction was successfully scheduled to a bank. "fail_cu_limit" means Pack skipped the transaction because it would have exceeded the block CU limit. "fail_fast_path" means Pack skipped the transaction because of account conflicts using the fast bitvector check. "fail_byte_limit" means Pack skipped the transaction because it would have exceeded the block data size limit. "fail_write_cost" means Pack skipped the transaction because it would have caused a writable account to exceed the per-account block write cost limit. "fail_slow_path" means Pack skipped the transaction because of account conflicts using the full slow check. "fail_defer_skip" means Pack skipped the transaction it previously exceeded the per-account block write cost limit too many times |
21942196
| end_slot_schedule_counts | `number[]` | `end_slot_schedule_counts` has the same meaning as `slot_schedule_counts` except only transactions that occur after the last successfully scheduled transaction in the slot are counted |
21952197
| pending_smallest_cost | `number` | The cost in compute units of the smallest eligible non-vote transaction in pack's transaction buffer at the end of the slot. If the buffer is empty, then this is `null` |

src/disco/gui/fd_gui_printf.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,21 @@ fd_gui_printf_slot_transactions_request( fd_gui_t * gui,
15521552
jsonp_close_object( gui->http );
15531553

15541554
jsonp_open_object( gui->http, "scheduler_stats" );
1555+
switch( lslot->scheduler_stats->end_slot_reason ) {
1556+
case FD_PACK_END_SLOT_REASON_TIME: {
1557+
jsonp_string( gui->http, "end_slot_reason", "timeout" );
1558+
break;
1559+
}
1560+
case FD_PACK_END_SLOT_REASON_MICROBLOCK: {
1561+
jsonp_string( gui->http, "end_slot_reason", "microblock_limit" );
1562+
break;
1563+
}
1564+
case FD_PACK_END_SLOT_REASON_LEADER_SWITCH: {
1565+
jsonp_string( gui->http, "end_slot_reason", "leader_switch" );
1566+
break;
1567+
}
1568+
default: __builtin_unreachable();
1569+
}
15551570
jsonp_open_array( gui->http, "slot_schedule_counts" );
15561571
for( ulong i = 0; i<FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT; i++ ) jsonp_ulong( gui->http, NULL, lslot->scheduler_stats->block_results[ i ] );
15571572
jsonp_close_array( gui->http );

src/disco/pack/fd_pack_tile.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ log_end_block_metrics( fd_pack_ctx_t * ctx,
397397
}
398398

399399
static inline void
400-
get_done_packing( fd_pack_ctx_t * ctx, fd_done_packing_t * done_packing ) {
400+
get_done_packing( fd_pack_ctx_t * ctx, fd_done_packing_t * done_packing, int reason ) {
401401
done_packing->microblocks_in_slot = ctx->slot_microblock_cnt;
402+
done_packing->end_slot_reason = reason;
402403
fd_pack_get_block_limits( ctx->pack, done_packing->limits_usage, done_packing->limits );
403404

404405
#define DELTA( mem, m ) (fd_metrics_tl[ MIDX(COUNTER, PACK, TRANSACTION_SCHEDULE_##m) ] - ctx->mem->sched_results[ FD_METRICS_ENUM_PACK_TXN_SCHEDULE_V_##m##_IDX ])
@@ -574,7 +575,7 @@ after_credit( fd_pack_ctx_t * ctx,
574575
*charge_busy = 1;
575576

576577
fd_done_packing_t * done_packing = fd_chunk_to_laddr( ctx->poh_out_mem, ctx->poh_out_chunk );
577-
get_done_packing( ctx, done_packing ); /* needs to be called before fd_pack_end_block */
578+
get_done_packing( ctx, done_packing, FD_PACK_END_SLOT_REASON_TIME ); /* needs to be called before fd_pack_end_block */
578579
fd_pack_end_block( ctx->pack );
579580
fd_pack_get_top_writers( ctx->pack, done_packing->limits_usage->top_writers ); /* needs to be called after fd_pack_end_block */
580581

@@ -813,7 +814,7 @@ after_credit( fd_pack_ctx_t * ctx,
813814
FD_MCNT_INC( PACK, MICROBLOCK_PER_BLOCK_LIMIT, 1UL );
814815

815816
fd_done_packing_t * done_packing = fd_chunk_to_laddr( ctx->poh_out_mem, ctx->poh_out_chunk );
816-
get_done_packing( ctx, done_packing );
817+
get_done_packing( ctx, done_packing, FD_PACK_END_SLOT_REASON_MICROBLOCK );
817818
fd_pack_end_block( ctx->pack );
818819
fd_pack_get_top_writers( ctx->pack, done_packing->limits_usage->top_writers );
819820

@@ -1027,7 +1028,7 @@ after_frag( fd_pack_ctx_t * ctx,
10271028

10281029
if( FD_UNLIKELY( ctx->leader_slot!=ULONG_MAX ) ) {
10291030
fd_done_packing_t * done_packing = fd_chunk_to_laddr( ctx->poh_out_mem, ctx->poh_out_chunk );
1030-
get_done_packing( ctx, done_packing );
1031+
get_done_packing( ctx, done_packing, FD_PACK_END_SLOT_REASON_LEADER_SWITCH );
10311032
fd_pack_end_block( ctx->pack );
10321033
fd_pack_get_top_writers( ctx->pack, done_packing->limits_usage->top_writers );
10331034

src/disco/tiles.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ struct fd_microblock_trailer {
149149
};
150150
typedef struct fd_microblock_trailer fd_microblock_trailer_t;
151151

152+
#define FD_PACK_END_SLOT_REASON_TIME (1)
153+
#define FD_PACK_END_SLOT_REASON_MICROBLOCK (2)
154+
#define FD_PACK_END_SLOT_REASON_LEADER_SWITCH (3)
155+
152156
struct fd_done_packing {
153157
ulong microblocks_in_slot;
154158

@@ -160,6 +164,8 @@ struct fd_done_packing {
160164

161165
fd_pack_smallest_t pending_smallest[ 1 ];
162166
fd_pack_smallest_t pending_votes_smallest[ 1 ];
167+
168+
int end_slot_reason;
163169
};
164170
typedef struct fd_done_packing fd_done_packing_t;
165171

0 commit comments

Comments
 (0)