Skip to content

Remove valloc #6008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions contrib/codeql/nightly/SurelyWrongConstPure.ql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ where
/* for a nightly query, we only want known non-const/non-pure functions */
f.hasName("fd_log_private_1") or
f.hasName("fd_log_private_2") or
f.hasName("fd_log_wallclock()") or
f.getName().matches("fd_valloc_%")
f.hasName("fd_log_wallclock()")
) and r.calls*(f)
select r, f + " is called (transitively) by " + r + " which is marked as " + r.getAnAttribute().getName()
24 changes: 6 additions & 18 deletions src/app/ledger/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ struct fd_ledger_args {
int copy_txn_status; /* determine if txns should be copied to the blockstore during minify/replay */
ulong trash_hash; /* trash hash to be used for negative cases*/
char const * rocksdb_path; /* path to rocksdb directory */
fd_valloc_t valloc; /* wksp valloc that should NOT be used for runtime allocations */
};
typedef struct fd_ledger_args fd_ledger_args_t;

/***************************** Helpers ****************************************/
static fd_valloc_t
static void
allocator_setup( fd_wksp_t * wksp ) {

if( FD_UNLIKELY( !wksp ) ) {
Expand All @@ -35,20 +34,12 @@ allocator_setup( fd_wksp_t * wksp ) {
if( FD_UNLIKELY( !alloc_shalloc ) ) { FD_LOG_ERR( ( "fd_alloc_new failed" ) ); }
fd_alloc_t * alloc = fd_alloc_join( alloc_shalloc, 3UL );
if( FD_UNLIKELY( !alloc ) ) { FD_LOG_ERR( ( "fd_alloc_join failed" ) ); }
fd_valloc_t valloc = fd_alloc_virtual( alloc );
return valloc;

/* NOTE: Enable this if leak hunting */
//return fd_backtracing_alloc_virtual( &valloc );

}

void
ingest_rocksdb( char const * file,
ulong start_slot,
ulong end_slot,
FD_PARAM_UNUSED ulong trash_hash,
fd_valloc_t valloc ) {
ulong end_slot ) {

fd_rocksdb_t rocks_db;
char * err = fd_rocksdb_init( &rocks_db, file );
Expand Down Expand Up @@ -76,7 +67,7 @@ ingest_rocksdb( char const * file,

int block_found = -1;
while ( block_found!=0 && start_slot<=end_slot ) {
block_found = fd_rocksdb_root_iter_seek( &iter, &rocks_db, start_slot, &slot_meta, valloc );
block_found = fd_rocksdb_root_iter_seek( &iter, &rocks_db, start_slot, &slot_meta );
if ( block_found!=0 ) {
start_slot++;
}
Expand Down Expand Up @@ -108,10 +99,10 @@ ingest_rocksdb( char const * file,

memset( &slot_meta, 0, sizeof(fd_slot_meta_t) );

int ret = fd_rocksdb_root_iter_next( &iter, &slot_meta, valloc );
int ret = fd_rocksdb_root_iter_next( &iter, &slot_meta );
if( ret < 0 ) {
// FD_LOG_WARNING(("Failed for slot %lu", slot + 1));
ret = fd_rocksdb_get_meta( &rocks_db, slot + 1, &slot_meta, valloc );
ret = fd_rocksdb_get_meta( &rocks_db, slot + 1, &slot_meta );
if( ret < 0 ) {
break;
}
Expand Down Expand Up @@ -173,8 +164,6 @@ minify( fd_ledger_args_t * args ) {
FD_LOG_ERR(( "minified rocksdb path is NULL" ));
}

args->valloc = allocator_setup( args->wksp );

fd_rocksdb_t big_rocksdb;
char * err = fd_rocksdb_init( &big_rocksdb, args->rocksdb_path );
if( FD_UNLIKELY( err!=NULL ) ) {
Expand Down Expand Up @@ -215,8 +204,7 @@ minify( fd_ledger_args_t * args ) {
// args->start_slot,
// args->end_slot,
// args->blockstore,
// ULONG_MAX,
// args->valloc );
// ULONG_MAX );

} else {
FD_LOG_NOTICE(( "skipping copying of transaction statuses" ));
Expand Down
3 changes: 1 addition & 2 deletions src/choreo/forks/fd_forks.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ fd_forks_query_const( fd_forks_t const * forks, ulong slot ) {
// ulong slot,
// fd_funk_t * funk,
// fd_blockstore_t * blockstore,
// fd_funk_t * funk,
// fd_valloc_t valloc ) {
// fd_funk_t * funk ) {
// // Remove slot ctx from frontier
// fd_fork_t * child = fd_fork_frontier_ele_remove( forks->frontier,
// &fork->slot,
Expand Down
2 changes: 0 additions & 2 deletions src/choreo/voter/test_voter.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ main( int argc, char ** argv ) {
// TEST_VOTE_TXN_MAGIC );
// void * alloc_shalloc = fd_alloc_new( alloc_shmem, TEST_VOTE_TXN_MAGIC );
// FD_PARAM_UNUSED fd_alloc_t * alloc = fd_alloc_join( alloc_shalloc, 0UL );
// FD_PARAM_UNUSED fd_valloc_t valloc = fd_alloc_virtual( alloc );

// /* create compact_vote_state_update with dummy values */
// fd_compact_vote_state_update_t compact_vote_update = {0};
Expand All @@ -126,7 +125,6 @@ main( int argc, char ** argv ) {
// fd_compact_vote_state_update_t parsed_vote_update;
// FD_TEST( FD_VOTER_OK == fd_vote_txn_parse( txn_buf,
// txn_size,
// valloc,
// &parsed_recent_blockhash_off,
// &parsed_vote_update ) );
// FD_LOG_NOTICE(( "recent blockhash: %s == %s",
Expand Down
26 changes: 6 additions & 20 deletions src/discof/backtest/fd_backtest_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ typedef struct {

ulong * published_wmark; /* same as the one in replay tile */
fd_alloc_t * alloc;
fd_valloc_t valloc;
long replay_time;
ulong slot_cnt;

Expand Down Expand Up @@ -138,8 +137,8 @@ static fd_shred_t const *
rocksdb_get_shred( ctx_t * ctx,
ulong * out_sz ) {
if( ctx->rocksdb_curr_idx==ctx->rocksdb_end_idx ) {
if( FD_UNLIKELY( fd_rocksdb_root_iter_next( &ctx->rocksdb_root_iter, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) return NULL;
if( FD_UNLIKELY( fd_rocksdb_get_meta( &ctx->rocksdb, ctx->rocksdb_slot_meta.slot, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) return NULL;
if( FD_UNLIKELY( fd_rocksdb_root_iter_next( &ctx->rocksdb_root_iter, &ctx->rocksdb_slot_meta ) ) ) return NULL;
if( FD_UNLIKELY( fd_rocksdb_get_meta( &ctx->rocksdb, ctx->rocksdb_slot_meta.slot, &ctx->rocksdb_slot_meta ) ) ) return NULL;
ctx->rocksdb_curr_idx = 0;
ctx->rocksdb_end_idx = ctx->rocksdb_slot_meta.received;
}
Expand Down Expand Up @@ -230,19 +229,13 @@ unprivileged_init( fd_topo_t * topo,
if( FD_UNLIKELY( !ctx->alloc ) ) {
FD_LOG_ERR( ( "fd_alloc_join failed" ) );
}
ctx->valloc = fd_alloc_virtual( ctx->alloc );

/* Tower */
ctx->tower = fd_tower_join( fd_tower_new( tower_mem ) );
if( FD_UNLIKELY( !ctx->tower ) ) {
FD_LOG_ERR( ( "fd_tower_join failed" ) );
}

ctx->rocksdb_bank_hash = fd_valloc_malloc( ctx->valloc, fd_frozen_hash_versioned_align(), sizeof(fd_frozen_hash_versioned_t) );
if( FD_UNLIKELY( NULL==ctx->rocksdb_bank_hash ) ) {
FD_LOG_ERR(( "Failed at allocating memory for rocksdb bank hash" ));
}

fd_topo_link_t * replay_in_link = &topo->links[ tile->in_link_id[ REPLAY_IN_IDX ] ];
ctx->replay_in_mem = topo->workspaces[ topo->objs[ replay_in_link->dcache_obj_id ].wksp_id ].wksp;
ctx->replay_in_chunk0 = fd_dcache_compact_chunk0( ctx->replay_in_mem, replay_in_link->dcache );
Expand Down Expand Up @@ -356,7 +349,7 @@ after_credit_rocksdb( ctx_t * ctx,
ctx->playback_started = 1;

fd_rocksdb_root_iter_new( &ctx->rocksdb_root_iter );
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) {
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta ) ) ) {
FD_LOG_CRIT(( "Failed at seeking rocksdb root iter for slot=%lu", wmark ));
}
ctx->rocksdb_iter = rocksdb_create_iterator_cf(ctx->rocksdb.db, ctx->rocksdb.ro, ctx->rocksdb.cf_handles[FD_ROCKSDB_CFIDX_DATA_SHRED]);
Expand Down Expand Up @@ -545,7 +538,7 @@ after_credit( ctx_t * ctx,
switch( ctx->ingest_mode ) {
case FD_BACKTEST_ROCKSDB_INGEST:
fd_rocksdb_root_iter_new( &ctx->rocksdb_root_iter );
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) {
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta ) ) ) {
FD_LOG_CRIT(( "Failed at seeking rocksdb root iter for slot=%lu", wmark ));
}
ctx->rocksdb_iter = rocksdb_create_iterator_cf(ctx->rocksdb.db, ctx->rocksdb.ro, ctx->rocksdb.cf_handles[FD_ROCKSDB_CFIDX_DATA_SHRED]);
Expand Down Expand Up @@ -589,16 +582,9 @@ rocksdb_bank_hash_check( ctx_t * ctx, ulong slot, fd_hash_t * bank_hash ) {
if( FD_UNLIKELY( err || vallen==0 ) ) {
FD_LOG_ERR(( "Failed at reading bank hash for slot%lu from rocksdb", slot ));
}
fd_bincode_decode_ctx_t decode = {
.data = res,
.dataend = res + vallen
};
ulong total_sz = 0UL;
int decode_err = fd_frozen_hash_versioned_decode_footprint( &decode, &total_sz );

fd_frozen_hash_versioned_t * versioned = fd_frozen_hash_versioned_decode( ctx->rocksdb_bank_hash, &decode );
if( FD_UNLIKELY( decode_err!=FD_BINCODE_SUCCESS ) ||
FD_UNLIKELY( decode.data!=decode.dataend ) ||
fd_frozen_hash_versioned_t versioned[1];
if( FD_UNLIKELY( !fd_bincode_decode_static( frozen_hash_versioned, versioned, res, vallen, NULL ) ) ||
FD_UNLIKELY( versioned->discriminant!=fd_frozen_hash_versioned_enum_current ) ) {
FD_LOG_ERR(( "Failed at decoding bank hash from rocksdb" ));
}
Expand Down
Loading
Loading