Skip to content

Commit a219ecb

Browse files
committed
work
1 parent bdd7c4f commit a219ecb

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

src/discof/rpcserver/fd_rpc_history.c

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ typedef struct fd_rpc_reasm_map_elem fd_rpc_reasm_map_elem_t;
9595
#define FD_REASM_MAP_COL_HEIGHT (128UL)
9696
struct fd_rpc_reasm_map {
9797
struct fd_rpc_reasm_map_column {
98-
ulong max_idx; /* The max shred index set in this column + 1 */
99-
ulong used_cnt; /* The number of shreds received in this column */
100-
uchar end_found; /* Whether the last slice of the slot has been found */
98+
ulong ele_cnt; /* The number of shreds received in this column */ uchar end_found; /* Whether the last slice of the slot has been found */
10199
fd_rpc_reasm_map_elem_t * ele[FD_REASM_MAP_COL_HEIGHT];
102100
} cols[FD_REASM_MAP_COL_CNT];
103101
ulong head; /* Next open column */
@@ -185,8 +183,8 @@ fd_rpc_history_debug(fd_rpc_history_t * hist) {
185183
for( ulong slot = reasm_map->tail; slot < reasm_map->head; slot++ ) {
186184
ulong col_idx = slot & (FD_REASM_MAP_COL_CNT - 1);
187185
struct fd_rpc_reasm_map_column * col = &reasm_map->cols[col_idx];
188-
FD_LOG_NOTICE(( "slot %lu: %lu fecs, %lu max, %d end_found", slot, col->used_cnt, col->max_idx, (int)col->end_found ));
189-
tot_cnt += col->used_cnt;
186+
FD_LOG_NOTICE(( "slot %lu: %lu fecs", slot, col->ele_cnt ));
187+
tot_cnt += col->ele_cnt;
190188
}
191189
FD_LOG_NOTICE(( "%lu head, %lu tail, %lu total fecs, %lu total blocks",
192190
reasm_map->head, reasm_map->tail, tot_cnt, reasm_map->head - reasm_map->tail ));
@@ -269,13 +267,13 @@ fd_rpc_history_process_column(fd_rpc_history_t * hist, struct fd_rpc_reasm_map_c
269267
/* Assemble the block */
270268
ulong slot = fec->slot;
271269
ulong blk_sz = 0;
272-
for( ulong i = 0; i < col->max_idx; i++ ) {
270+
for( ulong i = 0; i < col->ele_cnt; i++ ) {
273271
fd_rpc_reasm_map_elem_t * ele = col->ele[i];
274272
blk_sz += ele->data.data_sz;
275273
}
276274
uchar * blk_data = fd_spad_alloc( hist->spad, alignof(ulong), blk_sz );
277275
ulong blk_off = 0;
278-
for( ulong i = 0; i < col->max_idx; i++ ) {
276+
for( ulong i = 0; i < col->ele_cnt; i++ ) {
279277
fd_rpc_reasm_map_elem_t * ele = col->ele[i];
280278
fd_memcpy( blk_data + blk_off, ele->data.data, ele->data.data_sz );
281279
blk_off += ele->data.data_sz;
@@ -304,16 +302,14 @@ static void
304302
fd_rpc_history_discard_column(fd_rpc_reasm_map_t * reasm_map, fd_rpc_reasm_map_elem_t * reasm_pool, ulong slot) {
305303
ulong col_idx = slot & (FD_REASM_MAP_COL_CNT - 1);
306304
struct fd_rpc_reasm_map_column * col = &reasm_map->cols[col_idx];
307-
for( ulong i = 0; i < col->max_idx; i++ ) {
305+
for( ulong i = 0; i < col->ele_cnt; i++ ) {
308306
fd_rpc_reasm_map_elem_t * ele = col->ele[i];
309307
if( ele ) {
310308
fd_rpc_reasm_pool_ele_release( reasm_pool, ele );
311309
col->ele[i] = NULL;
312310
}
313311
}
314-
col->max_idx = 0;
315-
col->used_cnt = 0;
316-
col->end_found = 0;
312+
col->ele_cnt = 0;
317313
}
318314

319315
void
@@ -336,24 +332,16 @@ fd_rpc_history_save_fec(fd_rpc_history_t * hist, fd_store_t * store, fd_reasm_fe
336332
while( fec_msg->slot >= reasm_map->head ) {
337333
ulong col_idx = (reasm_map->head++) & (FD_REASM_MAP_COL_CNT - 1);
338334
struct fd_rpc_reasm_map_column * col = &reasm_map->cols[col_idx];
339-
col->max_idx = 0;
340-
col->used_cnt = 0;
341-
col->end_found = 0;
335+
col->ele_cnt = 0;
342336
}
343337
FD_TEST( fec_msg->slot >= reasm_map->tail && fec_msg->slot < reasm_map->head && reasm_map->head - reasm_map->tail <= FD_REASM_MAP_COL_CNT );
344338

345339
ulong col_idx = fec_msg->slot & (FD_REASM_MAP_COL_CNT - 1);
346340
struct fd_rpc_reasm_map_column * col = &reasm_map->cols[col_idx];
347341

348-
FD_TEST( fec_msg->fec_set_idx < FD_REASM_MAP_COL_HEIGHT );
342+
FD_TEST( col->ele_cnt < FD_REASM_MAP_COL_HEIGHT );
349343

350-
/* See if we've already received this fec */
351-
if( col->max_idx > fec_msg->fec_set_idx && col->ele[fec_msg->fec_set_idx] != NULL ) return;
352-
while( col->max_idx <= fec_msg->fec_set_idx ) {
353-
col->ele[col->max_idx++] = NULL;
354-
}
355-
356-
/* Acquire space for the shred. If we've run out of space, discard the oldest column */
344+
/* Acquire space for the fec data. If we've run out of space, discard the oldest column */
357345
fd_rpc_reasm_map_elem_t * ele = NULL;
358346
do {
359347
ele = fd_rpc_reasm_pool_ele_acquire( reasm_pool );
@@ -364,11 +352,9 @@ fd_rpc_history_save_fec(fd_rpc_history_t * hist, fd_store_t * store, fd_reasm_fe
364352

365353
ulong data_sz = ele->data.data_sz = fec_p->data_sz;
366354
fd_memcpy( ele->data.data, fec_p->data, data_sz );
367-
col->ele[fec_msg->fec_set_idx] = ele;
368-
col->used_cnt++;
369-
if( FD_UNLIKELY( fec_msg->slot_complete ) ) col->end_found = 1;
355+
col->ele[col->ele_cnt++] = ele;
370356

371-
if( col->end_found && col->used_cnt == col->max_idx ) {
357+
if( fec_msg->slot_complete ) {
372358
/* We've received all the shreds for this slot. Process it. */
373359
fd_rpc_history_process_column( hist, col, fec_msg );
374360
fd_rpc_history_discard_column( reasm_map, reasm_pool, fec_msg->slot );

0 commit comments

Comments
 (0)