@@ -145,7 +145,7 @@ pub struct LoadedProgram {
145
145
pub latest_access_slot : AtomicU64 ,
146
146
}
147
147
148
- /// Global cache statistics for [LoadedPrograms ].
148
+ /// Global cache statistics for [ProgramCache ].
149
149
#[ derive( Debug , Default ) ]
150
150
pub struct Stats {
151
151
/// a program was already in the cache
@@ -568,7 +568,7 @@ struct SecondLevel {
568
568
/// - allows for cooperative loading of TX batches which hit the same missing programs simultaneously.
569
569
/// - enforces that all programs used in a batch are eagerly loaded ahead of execution.
570
570
/// - is not persisted to disk or a snapshot, so it needs to cold start and warm up first.
571
- pub struct LoadedPrograms < FG : ForkGraph > {
571
+ pub struct ProgramCache < FG : ForkGraph > {
572
572
/// A two level index:
573
573
///
574
574
/// The first level is for the address at which programs are deployed and the second level for the slot (and thus also fork).
@@ -595,9 +595,9 @@ pub struct LoadedPrograms<FG: ForkGraph> {
595
595
pub loading_task_waiter : Arc < LoadingTaskWaiter > ,
596
596
}
597
597
598
- impl < FG : ForkGraph > Debug for LoadedPrograms < FG > {
598
+ impl < FG : ForkGraph > Debug for ProgramCache < FG > {
599
599
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
600
- f. debug_struct ( "LoadedPrograms " )
600
+ f. debug_struct ( "ProgramCache " )
601
601
. field ( "root slot" , & self . latest_root_slot )
602
602
. field ( "root epoch" , & self . latest_root_epoch )
603
603
. field ( "stats" , & self . stats )
@@ -606,11 +606,11 @@ impl<FG: ForkGraph> Debug for LoadedPrograms<FG> {
606
606
}
607
607
}
608
608
609
- /// Local view into [LoadedPrograms ] which was extracted for a specific TX batch.
609
+ /// Local view into [ProgramCache ] which was extracted for a specific TX batch.
610
610
///
611
- /// This isolation enables the global [LoadedPrograms ] to continue to evolve (e.g. evictions),
611
+ /// This isolation enables the global [ProgramCache ] to continue to evolve (e.g. evictions),
612
612
/// while the TX batch is guaranteed it will continue to find all the programs it requires.
613
- /// For program management instructions this also buffers them before they are merged back into the global [LoadedPrograms ].
613
+ /// For program management instructions this also buffers them before they are merged back into the global [ProgramCache ].
614
614
#[ derive( Clone , Debug , Default ) ]
615
615
pub struct LoadedProgramsForTxBatch {
616
616
/// Pubkey is the address of a program.
@@ -681,7 +681,7 @@ pub enum LoadedProgramMatchCriteria {
681
681
NoCriteria ,
682
682
}
683
683
684
- impl < FG : ForkGraph > LoadedPrograms < FG > {
684
+ impl < FG : ForkGraph > ProgramCache < FG > {
685
685
pub fn new ( root_slot : Slot , root_epoch : Epoch ) -> Self {
686
686
Self {
687
687
entries : HashMap :: new ( ) ,
@@ -734,7 +734,7 @@ impl<FG: ForkGraph> LoadedPrograms<FG> {
734
734
( LoadedProgramType :: Unloaded ( _) , LoadedProgramType :: TestLoaded ( _) ) => { }
735
735
_ => {
736
736
// Something is wrong, I can feel it ...
737
- error ! ( "LoadedPrograms ::assign_program() failed key={:?} existing={:?} entry={:?}" , key, slot_versions, entry) ;
737
+ error ! ( "ProgramCache ::assign_program() failed key={:?} existing={:?} entry={:?}" , key, slot_versions, entry) ;
738
738
debug_assert ! ( false , "Unexpected replacement of an entry" ) ;
739
739
self . stats . replacements . fetch_add ( 1 , Ordering :: Relaxed ) ;
740
740
return true ;
@@ -1146,9 +1146,9 @@ impl solana_frozen_abi::abi_example::AbiExample for LoadedProgram {
1146
1146
}
1147
1147
1148
1148
#[ cfg( RUSTC_WITH_SPECIALIZATION ) ]
1149
- impl < FG : ForkGraph > solana_frozen_abi:: abi_example:: AbiExample for LoadedPrograms < FG > {
1149
+ impl < FG : ForkGraph > solana_frozen_abi:: abi_example:: AbiExample for ProgramCache < FG > {
1150
1150
fn example ( ) -> Self {
1151
- // LoadedPrograms isn't serializable by definition.
1151
+ // ProgramCache isn't serializable by definition.
1152
1152
Self :: new ( Slot :: default ( ) , Epoch :: default ( ) )
1153
1153
}
1154
1154
}
@@ -1158,7 +1158,7 @@ mod tests {
1158
1158
use {
1159
1159
crate :: loaded_programs:: {
1160
1160
BlockRelation , ForkGraph , LoadedProgram , LoadedProgramMatchCriteria , LoadedProgramType ,
1161
- LoadedPrograms , LoadedProgramsForTxBatch , ProgramRuntimeEnvironment ,
1161
+ LoadedProgramsForTxBatch , ProgramCache , ProgramRuntimeEnvironment ,
1162
1162
ProgramRuntimeEnvironments , DELAY_VISIBILITY_SLOT_OFFSET ,
1163
1163
} ,
1164
1164
assert_matches:: assert_matches,
@@ -1178,8 +1178,8 @@ mod tests {
1178
1178
static MOCK_ENVIRONMENT : std:: sync:: OnceLock < ProgramRuntimeEnvironment > =
1179
1179
std:: sync:: OnceLock :: < ProgramRuntimeEnvironment > :: new ( ) ;
1180
1180
1181
- fn new_mock_cache < FG : ForkGraph > ( ) -> LoadedPrograms < FG > {
1182
- let mut cache = LoadedPrograms :: new ( 0 , 0 ) ;
1181
+ fn new_mock_cache < FG : ForkGraph > ( ) -> ProgramCache < FG > {
1182
+ let mut cache = ProgramCache :: new ( 0 , 0 ) ;
1183
1183
1184
1184
cache. environments . program_runtime_v1 = MOCK_ENVIRONMENT
1185
1185
. get_or_init ( || Arc :: new ( BuiltinProgram :: new_mock ( ) ) )
@@ -1220,7 +1220,7 @@ mod tests {
1220
1220
}
1221
1221
1222
1222
fn set_tombstone < FG : ForkGraph > (
1223
- cache : & mut LoadedPrograms < FG > ,
1223
+ cache : & mut ProgramCache < FG > ,
1224
1224
key : Pubkey ,
1225
1225
slot : Slot ,
1226
1226
reason : LoadedProgramType ,
@@ -1231,7 +1231,7 @@ mod tests {
1231
1231
}
1232
1232
1233
1233
fn insert_unloaded_program < FG : ForkGraph > (
1234
- cache : & mut LoadedPrograms < FG > ,
1234
+ cache : & mut ProgramCache < FG > ,
1235
1235
key : Pubkey ,
1236
1236
slot : Slot ,
1237
1237
) -> Arc < LoadedProgram > {
@@ -1254,7 +1254,7 @@ mod tests {
1254
1254
unloaded
1255
1255
}
1256
1256
1257
- fn num_matching_entries < P , FG > ( cache : & LoadedPrograms < FG > , predicate : P ) -> usize
1257
+ fn num_matching_entries < P , FG > ( cache : & ProgramCache < FG > , predicate : P ) -> usize
1258
1258
where
1259
1259
P : Fn ( & LoadedProgramType ) -> bool ,
1260
1260
FG : ForkGraph ,
@@ -1302,7 +1302,7 @@ mod tests {
1302
1302
}
1303
1303
1304
1304
fn program_deploy_test_helper (
1305
- cache : & mut LoadedPrograms < TestForkGraph > ,
1305
+ cache : & mut ProgramCache < TestForkGraph > ,
1306
1306
program : Pubkey ,
1307
1307
deployment_slots : Vec < Slot > ,
1308
1308
usage_counters : Vec < u64 > ,
@@ -2574,28 +2574,28 @@ mod tests {
2574
2574
let tombstone = Arc :: new ( LoadedProgram :: new_tombstone ( 0 , LoadedProgramType :: Closed ) ) ;
2575
2575
2576
2576
assert ! (
2577
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2577
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2578
2578
& tombstone,
2579
2579
& LoadedProgramMatchCriteria :: NoCriteria
2580
2580
)
2581
2581
) ;
2582
2582
2583
2583
assert ! (
2584
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2584
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2585
2585
& tombstone,
2586
2586
& LoadedProgramMatchCriteria :: Tombstone
2587
2587
)
2588
2588
) ;
2589
2589
2590
2590
assert ! (
2591
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2591
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2592
2592
& tombstone,
2593
2593
& LoadedProgramMatchCriteria :: DeployedOnOrAfterSlot ( 0 )
2594
2594
)
2595
2595
) ;
2596
2596
2597
2597
assert ! (
2598
- !LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2598
+ !ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2599
2599
& tombstone,
2600
2600
& LoadedProgramMatchCriteria :: DeployedOnOrAfterSlot ( 1 )
2601
2601
)
@@ -2604,28 +2604,28 @@ mod tests {
2604
2604
let program = new_test_loaded_program ( 0 , 1 ) ;
2605
2605
2606
2606
assert ! (
2607
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2607
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2608
2608
& program,
2609
2609
& LoadedProgramMatchCriteria :: NoCriteria
2610
2610
)
2611
2611
) ;
2612
2612
2613
2613
assert ! (
2614
- !LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2614
+ !ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2615
2615
& program,
2616
2616
& LoadedProgramMatchCriteria :: Tombstone
2617
2617
)
2618
2618
) ;
2619
2619
2620
2620
assert ! (
2621
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2621
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2622
2622
& program,
2623
2623
& LoadedProgramMatchCriteria :: DeployedOnOrAfterSlot ( 0 )
2624
2624
)
2625
2625
) ;
2626
2626
2627
2627
assert ! (
2628
- !LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2628
+ !ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2629
2629
& program,
2630
2630
& LoadedProgramMatchCriteria :: DeployedOnOrAfterSlot ( 1 )
2631
2631
)
@@ -2638,28 +2638,28 @@ mod tests {
2638
2638
) ) ;
2639
2639
2640
2640
assert ! (
2641
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2641
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2642
2642
& program,
2643
2643
& LoadedProgramMatchCriteria :: NoCriteria
2644
2644
)
2645
2645
) ;
2646
2646
2647
2647
assert ! (
2648
- !LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2648
+ !ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2649
2649
& program,
2650
2650
& LoadedProgramMatchCriteria :: Tombstone
2651
2651
)
2652
2652
) ;
2653
2653
2654
2654
assert ! (
2655
- LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2655
+ ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2656
2656
& program,
2657
2657
& LoadedProgramMatchCriteria :: DeployedOnOrAfterSlot ( 0 )
2658
2658
)
2659
2659
) ;
2660
2660
2661
2661
assert ! (
2662
- !LoadedPrograms :: <TestForkGraph >:: matches_loaded_program_criteria(
2662
+ !ProgramCache :: <TestForkGraph >:: matches_loaded_program_criteria(
2663
2663
& program,
2664
2664
& LoadedProgramMatchCriteria :: DeployedOnOrAfterSlot ( 1 )
2665
2665
)
0 commit comments