Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Use a Drop trait to keep track of lifetimes for recycled objects. #1275

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

aeyakovenko
Copy link
Member

  • Move recycler instances to the point of allocation
  • sinks no longer need to call recycle
  • Remove the recycler arguments from all the apis that no longer need them
    update for recyclering #1250

* Move recycler instances to the point of allocation
* sinks no longer need to call `recycle`
* Remove the recycler arguments from all the apis that no longer need them
@aeyakovenko aeyakovenko requested a review from garious September 19, 2018 22:32
@garious
Copy link
Contributor

garious commented Sep 19, 2018

Results of my research with the lifetime-aware recycler:

  • On it's own, it works extremely well, but requires lifetime-aware thread handles (i.e. crossbeam::ScopedJoinHandle).
  • crossbeam gotcha 1: Unlike ScopedJoinHandle, can't pass its JoinHandle across thread boundaries. That's an artificial dependency in our codebase (we spin up a separate thread for each Fullnode to workaround Fullnode not starting asynchronously) but still a red flag. How is the standard library ahead of crossbeam in that regard?
  • crossbeam gotcha 2: When I changed BankingStage to use ScopedThreadHandle, some tests would hang, suggesting the lifetime of Fullnode could be extended in surprising subtle ways, presumably by referencing a parent scope (maybe borrowing a string?).
  • Rust gotcha: Once you add an explicit lifetime, it's lifetimes all the way up. You can't tuck it away in just the parent struct. It needs to be added to its parent struct and so on.

My vote is that we move forward with this PR - that implementing the Drop trait is the best bang for the buck. Some next steps might include:

  • Removing the Arc and RwLock from Recyclables. The RwLock probably isn't needed at all and you should only mutate the recyclable after its moved out of the landfill. After that, all our uses of them should be readonly. The Arc is probably only needed before adding the Recyclable to a window. It should hold one reference, and the downstream stage should hold the other. The order those stages drops Recyclables is nondeterministic, so an Arc is the right tool for the job - it just doesn't need to be part of the Recycler!

@garious
Copy link
Contributor

garious commented Sep 19, 2018

Merging this sooner than later because of the rebasing that'd be needed otherwise.

@garious garious merged commit 431692d into solana-labs:master Sep 19, 2018
yihau pushed a commit that referenced this pull request May 14, 2024
…ation phase (backport of #1199) (#1275)

* Fix - Reloading of unload entries after finishing the recompilation phase (#1199)

* Differentiate entries by environment instead of adjusting the effective slot.

* Adds comments inside ProgramCache::assign_program().

* Adds reproducer to test_feature_activation_loaded_programs_epoch_transition.

* Fixes env order in test_feature_activation_loaded_programs_recompilation_phase().

* Syncs both tests with master.

---------

(cherry picked from commit 979f619)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
yihau pushed a commit to yihau/solana that referenced this pull request May 15, 2024
…ation phase (backport of solana-labs#1199) (solana-labs#1275)

* Fix - Reloading of unload entries after finishing the recompilation phase (solana-labs#1199)

* Differentiate entries by environment instead of adjusting the effective slot.

* Adds comments inside ProgramCache::assign_program().

* Adds reproducer to test_feature_activation_loaded_programs_epoch_transition.

* Fixes env order in test_feature_activation_loaded_programs_recompilation_phase().

* Syncs both tests with master.

---------

(cherry picked from commit 979f619)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants