Skip to content

Commit 5743c38

Browse files
committed
Remove valloc
1 parent e21f2c5 commit 5743c38

File tree

25 files changed

+27
-1016
lines changed

25 files changed

+27
-1016
lines changed

contrib/codeql/nightly/SurelyWrongConstPure.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ where
2626
/* for a nightly query, we only want known non-const/non-pure functions */
2727
f.hasName("fd_log_private_1") or
2828
f.hasName("fd_log_private_2") or
29-
f.hasName("fd_log_wallclock()") or
30-
f.getName().matches("fd_valloc_%")
29+
f.hasName("fd_log_wallclock()")
3130
) and r.calls*(f)
3231
select r, f + " is called (transitively) by " + r + " which is marked as " + r.getAnAttribute().getName()

src/app/ledger/main.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ struct fd_ledger_args {
1717
int copy_txn_status; /* determine if txns should be copied to the blockstore during minify/replay */
1818
ulong trash_hash; /* trash hash to be used for negative cases*/
1919
char const * rocksdb_path; /* path to rocksdb directory */
20-
fd_valloc_t valloc; /* wksp valloc that should NOT be used for runtime allocations */
2120
};
2221
typedef struct fd_ledger_args fd_ledger_args_t;
2322

2423
/***************************** Helpers ****************************************/
25-
static fd_valloc_t
24+
static void
2625
allocator_setup( fd_wksp_t * wksp ) {
2726

2827
if( FD_UNLIKELY( !wksp ) ) {
@@ -35,20 +34,12 @@ allocator_setup( fd_wksp_t * wksp ) {
3534
if( FD_UNLIKELY( !alloc_shalloc ) ) { FD_LOG_ERR( ( "fd_alloc_new failed" ) ); }
3635
fd_alloc_t * alloc = fd_alloc_join( alloc_shalloc, 3UL );
3736
if( FD_UNLIKELY( !alloc ) ) { FD_LOG_ERR( ( "fd_alloc_join failed" ) ); }
38-
fd_valloc_t valloc = fd_alloc_virtual( alloc );
39-
return valloc;
40-
41-
/* NOTE: Enable this if leak hunting */
42-
//return fd_backtracing_alloc_virtual( &valloc );
43-
4437
}
4538

4639
void
4740
ingest_rocksdb( char const * file,
4841
ulong start_slot,
49-
ulong end_slot,
50-
FD_PARAM_UNUSED ulong trash_hash,
51-
fd_valloc_t valloc ) {
42+
ulong end_slot ) {
5243

5344
fd_rocksdb_t rocks_db;
5445
char * err = fd_rocksdb_init( &rocks_db, file );
@@ -76,7 +67,7 @@ ingest_rocksdb( char const * file,
7667

7768
int block_found = -1;
7869
while ( block_found!=0 && start_slot<=end_slot ) {
79-
block_found = fd_rocksdb_root_iter_seek( &iter, &rocks_db, start_slot, &slot_meta, valloc );
70+
block_found = fd_rocksdb_root_iter_seek( &iter, &rocks_db, start_slot, &slot_meta );
8071
if ( block_found!=0 ) {
8172
start_slot++;
8273
}
@@ -108,10 +99,10 @@ ingest_rocksdb( char const * file,
10899

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

111-
int ret = fd_rocksdb_root_iter_next( &iter, &slot_meta, valloc );
102+
int ret = fd_rocksdb_root_iter_next( &iter, &slot_meta );
112103
if( ret < 0 ) {
113104
// FD_LOG_WARNING(("Failed for slot %lu", slot + 1));
114-
ret = fd_rocksdb_get_meta( &rocks_db, slot + 1, &slot_meta, valloc );
105+
ret = fd_rocksdb_get_meta( &rocks_db, slot + 1, &slot_meta );
115106
if( ret < 0 ) {
116107
break;
117108
}
@@ -173,8 +164,6 @@ minify( fd_ledger_args_t * args ) {
173164
FD_LOG_ERR(( "minified rocksdb path is NULL" ));
174165
}
175166

176-
args->valloc = allocator_setup( args->wksp );
177-
178167
fd_rocksdb_t big_rocksdb;
179168
char * err = fd_rocksdb_init( &big_rocksdb, args->rocksdb_path );
180169
if( FD_UNLIKELY( err!=NULL ) ) {
@@ -215,8 +204,7 @@ minify( fd_ledger_args_t * args ) {
215204
// args->start_slot,
216205
// args->end_slot,
217206
// args->blockstore,
218-
// ULONG_MAX,
219-
// args->valloc );
207+
// ULONG_MAX );
220208

221209
} else {
222210
FD_LOG_NOTICE(( "skipping copying of transaction statuses" ));

src/choreo/forks/fd_forks.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ fd_forks_query_const( fd_forks_t const * forks, ulong slot ) {
136136
// ulong slot,
137137
// fd_funk_t * funk,
138138
// fd_blockstore_t * blockstore,
139-
// fd_funk_t * funk,
140-
// fd_valloc_t valloc ) {
139+
// fd_funk_t * funk ) {
141140
// // Remove slot ctx from frontier
142141
// fd_fork_t * child = fd_fork_frontier_ele_remove( forks->frontier,
143142
// &fork->slot,

src/choreo/voter/test_voter.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ main( int argc, char ** argv ) {
103103
// TEST_VOTE_TXN_MAGIC );
104104
// void * alloc_shalloc = fd_alloc_new( alloc_shmem, TEST_VOTE_TXN_MAGIC );
105105
// FD_PARAM_UNUSED fd_alloc_t * alloc = fd_alloc_join( alloc_shalloc, 0UL );
106-
// FD_PARAM_UNUSED fd_valloc_t valloc = fd_alloc_virtual( alloc );
107106

108107
// /* create compact_vote_state_update with dummy values */
109108
// fd_compact_vote_state_update_t compact_vote_update = {0};
@@ -126,7 +125,6 @@ main( int argc, char ** argv ) {
126125
// fd_compact_vote_state_update_t parsed_vote_update;
127126
// FD_TEST( FD_VOTER_OK == fd_vote_txn_parse( txn_buf,
128127
// txn_size,
129-
// valloc,
130128
// &parsed_recent_blockhash_off,
131129
// &parsed_vote_update ) );
132130
// FD_LOG_NOTICE(( "recent blockhash: %s == %s",

src/discof/backtest/fd_backtest_tile.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ typedef struct {
9595

9696
ulong * published_wmark; /* same as the one in replay tile */
9797
fd_alloc_t * alloc;
98-
fd_valloc_t valloc;
9998
long replay_time;
10099
ulong slot_cnt;
101100

@@ -138,8 +137,8 @@ static fd_shred_t const *
138137
rocksdb_get_shred( ctx_t * ctx,
139138
ulong * out_sz ) {
140139
if( ctx->rocksdb_curr_idx==ctx->rocksdb_end_idx ) {
141-
if( FD_UNLIKELY( fd_rocksdb_root_iter_next( &ctx->rocksdb_root_iter, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) return NULL;
142-
if( FD_UNLIKELY( fd_rocksdb_get_meta( &ctx->rocksdb, ctx->rocksdb_slot_meta.slot, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) return NULL;
140+
if( FD_UNLIKELY( fd_rocksdb_root_iter_next( &ctx->rocksdb_root_iter, &ctx->rocksdb_slot_meta ) ) ) return NULL;
141+
if( FD_UNLIKELY( fd_rocksdb_get_meta( &ctx->rocksdb, ctx->rocksdb_slot_meta.slot, &ctx->rocksdb_slot_meta ) ) ) return NULL;
143142
ctx->rocksdb_curr_idx = 0;
144143
ctx->rocksdb_end_idx = ctx->rocksdb_slot_meta.received;
145144
}
@@ -230,19 +229,13 @@ unprivileged_init( fd_topo_t * topo,
230229
if( FD_UNLIKELY( !ctx->alloc ) ) {
231230
FD_LOG_ERR( ( "fd_alloc_join failed" ) );
232231
}
233-
ctx->valloc = fd_alloc_virtual( ctx->alloc );
234232

235233
/* Tower */
236234
ctx->tower = fd_tower_join( fd_tower_new( tower_mem ) );
237235
if( FD_UNLIKELY( !ctx->tower ) ) {
238236
FD_LOG_ERR( ( "fd_tower_join failed" ) );
239237
}
240238

241-
ctx->rocksdb_bank_hash = fd_valloc_malloc( ctx->valloc, fd_frozen_hash_versioned_align(), sizeof(fd_frozen_hash_versioned_t) );
242-
if( FD_UNLIKELY( NULL==ctx->rocksdb_bank_hash ) ) {
243-
FD_LOG_ERR(( "Failed at allocating memory for rocksdb bank hash" ));
244-
}
245-
246239
fd_topo_link_t * replay_in_link = &topo->links[ tile->in_link_id[ REPLAY_IN_IDX ] ];
247240
ctx->replay_in_mem = topo->workspaces[ topo->objs[ replay_in_link->dcache_obj_id ].wksp_id ].wksp;
248241
ctx->replay_in_chunk0 = fd_dcache_compact_chunk0( ctx->replay_in_mem, replay_in_link->dcache );
@@ -356,7 +349,7 @@ after_credit_rocksdb( ctx_t * ctx,
356349
ctx->playback_started = 1;
357350

358351
fd_rocksdb_root_iter_new( &ctx->rocksdb_root_iter );
359-
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) {
352+
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta ) ) ) {
360353
FD_LOG_CRIT(( "Failed at seeking rocksdb root iter for slot=%lu", wmark ));
361354
}
362355
ctx->rocksdb_iter = rocksdb_create_iterator_cf(ctx->rocksdb.db, ctx->rocksdb.ro, ctx->rocksdb.cf_handles[FD_ROCKSDB_CFIDX_DATA_SHRED]);
@@ -545,7 +538,7 @@ after_credit( ctx_t * ctx,
545538
switch( ctx->ingest_mode ) {
546539
case FD_BACKTEST_ROCKSDB_INGEST:
547540
fd_rocksdb_root_iter_new( &ctx->rocksdb_root_iter );
548-
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta, ctx->valloc ) ) ) {
541+
if( FD_UNLIKELY( fd_rocksdb_root_iter_seek( &ctx->rocksdb_root_iter, &ctx->rocksdb, wmark, &ctx->rocksdb_slot_meta ) ) ) {
549542
FD_LOG_CRIT(( "Failed at seeking rocksdb root iter for slot=%lu", wmark ));
550543
}
551544
ctx->rocksdb_iter = rocksdb_create_iterator_cf(ctx->rocksdb.db, ctx->rocksdb.ro, ctx->rocksdb.cf_handles[FD_ROCKSDB_CFIDX_DATA_SHRED]);
@@ -589,16 +582,9 @@ rocksdb_bank_hash_check( ctx_t * ctx, ulong slot, fd_hash_t * bank_hash ) {
589582
if( FD_UNLIKELY( err || vallen==0 ) ) {
590583
FD_LOG_ERR(( "Failed at reading bank hash for slot%lu from rocksdb", slot ));
591584
}
592-
fd_bincode_decode_ctx_t decode = {
593-
.data = res,
594-
.dataend = res + vallen
595-
};
596-
ulong total_sz = 0UL;
597-
int decode_err = fd_frozen_hash_versioned_decode_footprint( &decode, &total_sz );
598585

599-
fd_frozen_hash_versioned_t * versioned = fd_frozen_hash_versioned_decode( ctx->rocksdb_bank_hash, &decode );
600-
if( FD_UNLIKELY( decode_err!=FD_BINCODE_SUCCESS ) ||
601-
FD_UNLIKELY( decode.data!=decode.dataend ) ||
586+
fd_frozen_hash_versioned_t versioned[1];
587+
if( FD_UNLIKELY( !fd_bincode_decode_static( frozen_hash_versioned, versioned, res, vallen, NULL ) ) ||
602588
FD_UNLIKELY( versioned->discriminant!=fd_frozen_hash_versioned_enum_current ) ) {
603589
FD_LOG_ERR(( "Failed at decoding bank hash from rocksdb" ));
604590
}

0 commit comments

Comments
 (0)