Skip to content

Commit

Permalink
pack: fix minor issue with smallest transaction accounting, more metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaffet-jump authored and mmcgee-jump committed Dec 5, 2024
1 parent 5d94f02 commit c9a7843
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 209 deletions.
2 changes: 2 additions & 0 deletions book/api/metrics-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
| pack_​available_​transactions | `gauge` | The total number of pending transactions in pack's pool that are available to be scheduled |
| pack_​available_​vote_​transactions | `gauge` | The number of pending simple vote transactions in pack's pool that are available to be scheduled |
| pack_​pending_​transactions_​heap_​size | `gauge` | The maximum number of pending transactions that pack can consider. This value is fixed at Firedancer startup but is a useful reference for AvailableTransactions and AvailableVoteTransactions. |
| pack_​conflicting_​transactions | `gauge` | The number of available transactions that are temporarily not being considered due to account lock conflicts with many higher paying transactions |
| pack_​smallest_​pending_​transaction | `gauge` | A lower bound on the smallest non-vote transaction (in cost units) that is immediately available for scheduling |
| pack_​microblock_​per_​block_​limit | `counter` | The number of times pack did not pack a microblock because the limit on microblocks/block had been reached |
| pack_​data_​per_​block_​limit | `counter` | The number of times pack did not pack a microblock because it reached reached the data per block limit at the start of trying to schedule a microblock |
| pack_​transaction_​schedule_​taken | `counter` | Result of trying to consider a transaction for scheduling (Pack included the transaction in the microblock) |
Expand Down
18 changes: 12 additions & 6 deletions src/ballet/pack/fd_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,10 @@ fd_pack_insert_txn_fini( fd_pack_t * pack,
ord->root = FD_ORD_TXN_ROOT_PENALTY( penalty_idx[i] );
} else {
ord->root = fd_int_if( is_vote, FD_ORD_TXN_ROOT_PENDING_VOTE, FD_ORD_TXN_ROOT_PENDING );

fd_pack_smallest_t * smallest = fd_ptr_if( is_vote, &pack->pending_votes_smallest[0], pack->pending_smallest );
smallest->cus = fd_ulong_min( smallest->cus, ord->compute_est );
smallest->bytes = fd_ulong_min( smallest->bytes, txne->txnp->payload_sz );
}

pack->pending_txn_cnt++;
Expand All @@ -1087,10 +1091,6 @@ fd_pack_insert_txn_fini( fd_pack_t * pack,
fd_pack_expq_t temp[ 1 ] = {{ .expires_at = expires_at, .txn = ord }};
expq_insert( pack->expiration_q, temp );

fd_pack_smallest_t * smallest = fd_ptr_if( is_vote, &pack->pending_votes_smallest[0], pack->pending_smallest );
smallest->cus = fd_ulong_min( smallest->cus, ord->compute_est );
smallest->bytes = fd_ulong_min( smallest->bytes, txne->txnp->payload_sz );

if( FD_LIKELY( is_vote ) ) {
treap_ele_insert( pack->pending_votes, ord, pack->pool );
return replaces ? FD_PACK_INSERT_ACCEPT_VOTE_REPLACE : FD_PACK_INSERT_ACCEPT_VOTE_ADD;
Expand All @@ -1103,8 +1103,11 @@ fd_pack_insert_txn_fini( fd_pack_t * pack,

void
fd_pack_metrics_write( fd_pack_t const * pack ) {
FD_MGAUGE_SET( PACK, AVAILABLE_TRANSACTIONS, pack->pending_txn_cnt );
FD_MGAUGE_SET( PACK, AVAILABLE_VOTE_TRANSACTIONS, treap_ele_cnt( pack->pending_votes ) );
ulong pending_votes = treap_ele_cnt( pack->pending_votes );
FD_MGAUGE_SET( PACK, AVAILABLE_TRANSACTIONS, pack->pending_txn_cnt );
FD_MGAUGE_SET( PACK, AVAILABLE_VOTE_TRANSACTIONS, pending_votes );
FD_MGAUGE_SET( PACK, CONFLICTING_TRANSACTIONS, pack->pending_txn_cnt - treap_ele_cnt( pack->pending ) - pending_votes );
FD_MGAUGE_SET( PACK, SMALLEST_PENDING_TRANSACTION, pack->pending_smallest->cus );
}

typedef struct {
Expand Down Expand Up @@ -1506,6 +1509,9 @@ fd_pack_microblock_complete( fd_pack_t * pack,
best->root = FD_ORD_TXN_ROOT_PENDING;
treap_ele_insert( pack->pending, best, pack->pool );

pack->pending_smallest->cus = fd_ulong_min( pack->pending_smallest->cus, best->compute_est );
pack->pending_smallest->bytes = fd_ulong_min( pack->pending_smallest->bytes, best->txn_e->txnp->payload_sz );

if( FD_UNLIKELY( !treap_ele_cnt( best_penalty->penalty_treap ) ) ) {
treap_delete( treap_leave( best_penalty->penalty_treap ) );
/* Removal invalidates any pointers we got from
Expand Down
18 changes: 9 additions & 9 deletions src/disco/metrics/generated/fd_metrics_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,49 +124,49 @@
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CNT (8UL)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING_OFF (8UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING_NAME "tile_regime_duration_nanos_caughtuphousekeeping"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING_NAME "tile_regime_duration_nanos_caught_up_housekeeping"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Caught up + Housekeeping)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_HOUSEKEEPING_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING_OFF (9UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING_NAME "tile_regime_duration_nanos_processinghousekeeping"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING_NAME "tile_regime_duration_nanos_processing_housekeeping"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Processing + Housekeeping)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_HOUSEKEEPING_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING_OFF (10UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING_NAME "tile_regime_duration_nanos_backpressurehousekeeping"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING_NAME "tile_regime_duration_nanos_backpressure_housekeeping"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Backpressure + Housekeeping)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_HOUSEKEEPING_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG_OFF (11UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG_NAME "tile_regime_duration_nanos_caughtupprefrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG_NAME "tile_regime_duration_nanos_caught_up_prefrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Caught up + Prefrag)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_PREFRAG_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_PREFRAG_OFF (12UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_PREFRAG_NAME "tile_regime_duration_nanos_processingprefrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_PREFRAG_NAME "tile_regime_duration_nanos_processing_prefrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_PREFRAG_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_PREFRAG_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Processing + Prefrag)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_PREFRAG_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG_OFF (13UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG_NAME "tile_regime_duration_nanos_backpressureprefrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG_NAME "tile_regime_duration_nanos_backpressure_prefrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Backpressure + Prefrag)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_BACKPRESSURE_PREFRAG_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG_OFF (14UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG_NAME "tile_regime_duration_nanos_caughtuppostfrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG_NAME "tile_regime_duration_nanos_caught_up_postfrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Caught up + Postfrag)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_CAUGHT_UP_POSTFRAG_CVT (FD_METRICS_CONVERTER_NONE)

#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_POSTFRAG_OFF (15UL)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_POSTFRAG_NAME "tile_regime_duration_nanos_processingpostfrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_POSTFRAG_NAME "tile_regime_duration_nanos_processing_postfrag"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_POSTFRAG_TYPE (FD_METRICS_TYPE_COUNTER)
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_POSTFRAG_DESC "Mutually exclusive and exhaustive duration of time the tile spent in each of the regimes. (Processing + Postfrag)"
#define FD_METRICS_COUNTER_TILE_REGIME_DURATION_NANOS_PROCESSING_POSTFRAG_CVT (FD_METRICS_CONVERTER_NONE)
Expand All @@ -182,7 +182,7 @@ extern const fd_metrics_meta_t FD_METRICS_ALL_LINK_IN[FD_METRICS_ALL_LINK_IN_TOT
#define FD_METRICS_ALL_LINK_OUT_TOTAL (1UL)
extern const fd_metrics_meta_t FD_METRICS_ALL_LINK_OUT[FD_METRICS_ALL_LINK_OUT_TOTAL];

#define FD_METRICS_TOTAL_SZ (8UL*219UL)
#define FD_METRICS_TOTAL_SZ (8UL*221UL)

#define FD_METRICS_TILE_KIND_CNT 10
extern const char * FD_METRICS_TILE_KIND_NAMES[FD_METRICS_TILE_KIND_CNT];
Expand Down
Loading

0 comments on commit c9a7843

Please sign in to comment.