Skip to content
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

Refactor - Adds check that only loaded programs can be unloaded #35146

Merged

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Feb 8, 2024

Problem

Currently the only thing stopping a tombstone from being unloaded is that it never gets selected as a candidate by LoadedPrograms::get_flattened_entries().

Summary of Changes

Adds check that prevents anything but loaded programs from being unloaded.

@Lichtso Lichtso force-pushed the refactor/loaded_program_to_unloaded branch from 54af127 to 174023e Compare February 8, 2024 14:40
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (897adb2) 81.6% compared to head (6491692) 81.6%.
Report is 2 commits behind head on master.

❗ Current head 6491692 differs from pull request most recent head 6943b44. Consider uploading reports for the commit 6943b44 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #35146   +/-   ##
=======================================
  Coverage    81.6%    81.6%           
=======================================
  Files         833      833           
  Lines      224827   224830    +3     
=======================================
+ Hits       183523   183598   +75     
+ Misses      41304    41232   -72     

program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@Lichtso Lichtso force-pushed the refactor/loaded_program_to_unloaded branch 4 times, most recently from 8fd99d1 to 62b6d29 Compare February 12, 2024 12:32
program-runtime/src/loaded_programs.rs Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
@Lichtso Lichtso force-pushed the refactor/loaded_program_to_unloaded branch 2 times, most recently from e6ef4ec to 6491692 Compare February 13, 2024 18:01
@@ -2386,6 +2375,38 @@ mod tests {
assert!(match_missing(&missing, &program3, true));
}

#[test]
fn test_unloaded() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but we still don't have tests for the None path in
sort_and_unload and evict_using_2s_random_selection?

@Lichtso Lichtso force-pushed the refactor/loaded_program_to_unloaded branch from 6491692 to 1c46990 Compare February 14, 2024 11:31
for loaded_program_type in [
LoadedProgramType::FailedVerification(cache.environments.program_runtime_v1.clone()),
LoadedProgramType::Closed,
LoadedProgramType::DelayVisibility,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't go in the cache right? I would comment it and explicitly say that. It's weird if tests test things which aren't supposed to happen because then you can't use tests to learn an API.

let program_id = Pubkey::new_unique();
cache.assign_program(program_id, entry.clone());
cache.unload_program_entry(&program_id, &entry);
assert_eq!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check that stats.evictions is 1 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evictions only increments on successful unloading, not for attempts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should check that it goes up when expected? We must check both paths of to_unloaded somehow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@Lichtso Lichtso force-pushed the refactor/loaded_program_to_unloaded branch from 1c46990 to 42c5aa0 Compare February 14, 2024 11:50
@Lichtso Lichtso force-pushed the refactor/loaded_program_to_unloaded branch from 42c5aa0 to 6943b44 Compare February 14, 2024 12:03
@Lichtso Lichtso merged commit 1752202 into solana-labs:master Feb 14, 2024
35 checks passed
@Lichtso Lichtso deleted the refactor/loaded_program_to_unloaded branch February 14, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants