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

Add provisions to unload a program from the cache #31036

Merged
merged 6 commits into from
Apr 10, 2023

Conversation

pgarg66
Copy link
Contributor

@pgarg66 pgarg66 commented Apr 4, 2023

Problem

The program usage counts reset when it gets evicted from the cache.

Summary of Changes

  • Add a new type (Unloaded) for programs in the cache. When a program get evicted, it'll be replaced with this type. It'll keep track of program's usage count and other meta data.
  • Updated eviction logic to flatten the program cache, and unload the entries with the lowest usage count
  • Updated the unit test

Fixes #

program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Show resolved Hide resolved
runtime/src/bank.rs Outdated Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Outdated Show resolved Hide resolved
program-runtime/src/loaded_programs.rs Show resolved Hide resolved
@pgarg66 pgarg66 marked this pull request as ready for review April 8, 2023 01:57
@pgarg66 pgarg66 requested a review from Lichtso April 8, 2023 01:57
@codecov
Copy link

codecov bot commented Apr 8, 2023

Codecov Report

Merging #31036 (04e79b9) into master (4d0abeb) will increase coverage by 0.0%.
The diff coverage is 96.3%.

@@           Coverage Diff            @@
##           master   #31036    +/-   ##
========================================
  Coverage    81.4%    81.5%            
========================================
  Files         728      728            
  Lines      206240   206379   +139     
========================================
+ Hits       168079   168241   +162     
+ Misses      38161    38138    -23     

program-runtime/src/loaded_programs.rs 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
@pgarg66 pgarg66 requested a review from Lichtso April 10, 2023 10:16
@Lichtso
Copy link
Contributor

Lichtso commented Apr 10, 2023

Do we have tests that the transitions loaded -> unloaded and vice versa retain the usage statistics?

@solana-labs solana-labs deleted a comment from gitgobby Apr 10, 2023
@pgarg66
Copy link
Contributor Author

pgarg66 commented Apr 10, 2023

Do we have tests that the transitions loaded -> unloaded and vice versa retain the usage statistics?

Added a new test in the latest commit.

@pgarg66 pgarg66 requested a review from Lichtso April 10, 2023 15:38
@pgarg66 pgarg66 merged commit 12e3e8b into solana-labs:master Apr 10, 2023
@pgarg66 pgarg66 deleted the ghost-entry branch April 10, 2023 23:42
existing.usage_counter.load(Ordering::Relaxed),
Ordering::Relaxed,
);
second_level.swap_remove(entry_index);
Copy link
Member

Choose a reason for hiding this comment

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

for the record: this newly-added instance of .swap_remove() is fixed at #32973

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