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

[Feature] Mark-and-sweep GC. #3504

Merged
merged 170 commits into from
Nov 7, 2023
Merged

[Feature] Mark-and-sweep GC. #3504

merged 170 commits into from
Nov 7, 2023

Conversation

ruseinov
Copy link
Contributor

@ruseinov ruseinov commented Sep 19, 2023

Summary of changes

Changes introduced in this pull request:

  • Introduces a mark-and-sweep garbage collector.

Reference issue to close (if applicable)

Closes #3072

Other information and links

This will require a 0.13.1 release due to a database migration needed to deprecate RollingDB.
Perhaps a good idea is to incorporate the CHANGELOG.md changes within this PR as well to simplify things.

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@ruseinov
Copy link
Contributor Author

@lemmih This design is not taking into account the AnyCar addition. I'm assuming we do want to traverse the reachable graph including the car storage, correct?

@ruseinov ruseinov changed the title sort out the hashes [Feature] Mark-and-sweep GC. Sep 19, 2023
@lemmih
Copy link
Contributor

lemmih commented Sep 19, 2023

@lemmih This design is not taking into account the AnyCar addition. I'm assuming we do want to traverse the reachable graph including the car storage, correct?

The CAR files contain read-only data. There's no need for the GC to traverse them. In the future, we do want to find unused CAR files but you can leave that for another PR.

@ruseinov
Copy link
Contributor Author

The CAR files contain read-only data. There's no need for the GC to traverse them. In the future, we do want to find unused CAR files but you can leave that for another PR.

Right, that makes sense.

@ruseinov ruseinov marked this pull request as ready for review September 25, 2023 15:46
@ruseinov ruseinov requested a review from a team as a code owner September 25, 2023 15:46
@ruseinov ruseinov requested review from hanabi1224 and elmattic and removed request for a team September 25, 2023 15:46
@ruseinov ruseinov marked this pull request as draft September 25, 2023 21:28
ruseinov and others added 5 commits November 3, 2023 15:38
Co-authored-by: David Himmelstrup <[email protected]>
Co-authored-by: David Himmelstrup <[email protected]>
Co-authored-by: David Himmelstrup <[email protected]>
@ruseinov
Copy link
Contributor Author

ruseinov commented Nov 3, 2023

Let's merge this PR as-is and see if we get the bandwidth to improve the tests later.

Sounds good!

src/db/gc/mod.rs Outdated
///
/// * `db` - A reference to the database instance.
/// * `get_heaviest_tipset` - A function that facilitates heaviest tipset retrieval.
/// * `depth` - The number of state-roots to retain.
Copy link
Contributor

Choose a reason for hiding this comment

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

What should depth be initialized to? In the associated issue we're speaking of a number of 2 x chain_finality, here we're taking max of chain_finality and recent_state_roots.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not garbage collector's concern, the decision is made by the caller. But it's a good catch, and I will comment and fix it to be 2x chain_finality.

src/db/gc/mod.rs Outdated Show resolved Hide resolved
@elmattic
Copy link
Contributor

elmattic commented Nov 6, 2023

Should this new implementation of GC fix our long-standing send issue? (#3645)
I would really like to run my script, but it would not be possible without a way to trigger your GC.

Eventually, let's try to uncomment the test in calibnet_wallet_check.sh and see what happens.

@ruseinov
Copy link
Contributor Author

ruseinov commented Nov 6, 2023

Should this new implementation of GC fix our long-standing send issue? (#3645) I would really like to run my script, but it would not be possible without a way to trigger your GC.

Eventually, let's try to uncomment the test in calibnet_wallet_check.sh and see what happens.

Manual GC is deprecated, it makes no sense with the current approach.

@ruseinov ruseinov enabled auto-merge November 6, 2023 13:44
@ruseinov ruseinov disabled auto-merge November 6, 2023 15:14
@ruseinov ruseinov enabled auto-merge November 6, 2023 15:14
@lemmih
Copy link
Contributor

lemmih commented Nov 6, 2023

@ruseinov You probably have to update the branch before the CI checks will run.

@ruseinov
Copy link
Contributor Author

ruseinov commented Nov 6, 2023

@ruseinov You probably have to update the branch before the CI checks will run.

so it seems!

@ruseinov ruseinov added this pull request to the merge queue Nov 7, 2023
Merged via the queue into main with commit defce38 Nov 7, 2023
25 checks passed
@ruseinov ruseinov deleted the ru/feature/mark-and-sweep branch November 7, 2023 08:45
LesnyRumcajs added a commit that referenced this pull request Nov 7, 2023
ruseinov added a commit that referenced this pull request Nov 8, 2023
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.

Implement a mark-and-sweep garbage collector
4 participants