Skip to content

Commit f87d7b9

Browse files
committed
gui: add end slot reason, blockhash
1 parent 6d8a2f1 commit f87d7b9

File tree

7 files changed

+43
-5
lines changed

7 files changed

+43
-5
lines changed

book/api/websocket.md

Lines changed: 3 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,8 @@ explicitly mentioned, skipped slots are not included.
21902191
**`SlotScheduleStats`**
21912192
| Field | Type | Description |
21922193
|------------------------------|-------------------|-------------|
2194+
| block_hash | `string` | The final POH hash in the block as a base58 encoded string |
2195+
| end_slot_reason | `string` | The reason pack ended packing for this leader slot. One of `"timeout"`, `"microblock_limit"`, or `"leader_switch"` |
21932196
| 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 |
21942197
| 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 |
21952198
| 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.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ fd_gui_clear_slot( fd_gui_t * gui,
14981498
fd_gui_leader_slot_t * lslot = gui->leader_slots[ slot->leader_history_idx % FD_GUI_LEADER_CNT ];
14991499

15001500
lslot->slot = _slot;
1501+
memset( lslot->block_hash.uc, 0, sizeof(fd_hash_t) );
15011502
lslot->leader_start_time = LONG_MAX;
15021503
lslot->leader_end_time = LONG_MAX;
15031504
lslot->tile_timers_sample_cnt = 0UL;
@@ -2557,6 +2558,7 @@ fd_gui_handle_tower_update( fd_gui_t * gui,
25572558
void
25582559
fd_gui_handle_replay_update( fd_gui_t * gui,
25592560
fd_gui_slot_completed_t * slot_completed,
2561+
fd_hash_t const * block_hash,
25602562
long now ) {
25612563
(void)now;
25622564

@@ -2574,6 +2576,11 @@ fd_gui_handle_replay_update( fd_gui_t * gui,
25742576
slot = fd_gui_clear_slot( gui, slot_completed->slot, slot_completed->parent_slot );
25752577
}
25762578

2579+
if( FD_UNLIKELY( slot->mine ) ) {
2580+
fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, slot->slot );
2581+
if( FD_LIKELY( lslot ) ) fd_memcpy( lslot->block_hash.uc, block_hash->uc, sizeof(fd_hash_t) );
2582+
}
2583+
25772584
slot->completed_time = slot_completed->completed_time;
25782585
slot->parent_slot = slot_completed->parent_slot;
25792586
slot->max_compute_units = fd_uint_if( slot_completed->max_compute_units==UINT_MAX, slot->max_compute_units, slot_completed->max_compute_units );

src/disco/gui/fd_gui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ typedef struct fd_gui_scheduler_counts fd_gui_scheduler_counts_t;
259259

260260
struct fd_gui_leader_slot {
261261
ulong slot;
262+
fd_hash_t block_hash;
262263
long leader_start_time; /* UNIX timestamp of when we first became leader in this slot */
263264
long leader_end_time; /* UNIX timestamp of when we stopped being leader in this slot */
264265

@@ -852,6 +853,7 @@ fd_gui_handle_tower_update( fd_gui_t * gui,
852853
void
853854
fd_gui_handle_replay_update( fd_gui_t * gui,
854855
fd_gui_slot_completed_t * slot_completed,
856+
fd_hash_t const * block_hash,
855857
long now );
856858

857859
void

src/disco/gui/fd_gui_printf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,25 @@ 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+
char block_hash_base58[ FD_BASE58_ENCODED_32_SZ ];
1556+
fd_base58_encode_32( lslot->block_hash.uc, NULL, block_hash_base58 );
1557+
jsonp_string( gui->http, "block_hash", block_hash_base58 );
1558+
1559+
switch( lslot->scheduler_stats->end_slot_reason ) {
1560+
case FD_PACK_END_SLOT_REASON_TIME: {
1561+
jsonp_string( gui->http, "end_slot_reason", "timeout" );
1562+
break;
1563+
}
1564+
case FD_PACK_END_SLOT_REASON_MICROBLOCK: {
1565+
jsonp_string( gui->http, "end_slot_reason", "microblock_limit" );
1566+
break;
1567+
}
1568+
case FD_PACK_END_SLOT_REASON_LEADER_SWITCH: {
1569+
jsonp_string( gui->http, "end_slot_reason", "leader_switch" );
1570+
break;
1571+
}
1572+
default: __builtin_unreachable();
1573+
}
15551574
jsonp_open_array( gui->http, "slot_schedule_counts" );
15561575
for( ulong i = 0; i<FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT; i++ ) jsonp_ulong( gui->http, NULL, lslot->scheduler_stats->block_results[ i ] );
15571576
jsonp_close_array( gui->http );

src/disco/gui/fd_gui_tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ after_frag( fd_gui_ctx_t * ctx,
417417
fd_gui_peers_handle_vote_update( ctx->peers, ctx->peers->votes, vote_count, fd_clock_now( ctx->clock ), ctx->gui->ipinfo.country_code );
418418

419419
/* update slot data */
420-
fd_gui_handle_replay_update( ctx->gui, &slot_completed, fd_clock_now( ctx->clock ) );
420+
fd_gui_handle_replay_update( ctx->gui, &slot_completed, &replay->block_hash, fd_clock_now( ctx->clock ) );
421421

422422
} else if( FD_UNLIKELY( sig==REPLAY_SIG_BECAME_LEADER ) ) {
423423
fd_became_leader_t * became_leader = (fd_became_leader_t *)src;

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)