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

Implement a graph with garbage collection #267

Merged
merged 6 commits into from Dec 26, 2022

Conversation

HeinrichApfelmus
Copy link
Owner

Overview

This pull request implements a type GraphGC that represents a graph whose vertices are subject to garbage collection.

Eventually, we will use GraphGC to represent a network of Pulse: The vertices are Pulse, and the edges between them are dependencies. The function walkSuccessors allows us to walk the Pulse in dependency order — with early exit (Stop), but still with the guarantee that no vertex will be visited before its dependencies.

Comments

  • Garbage collection is tricky, hence we use a pure Graph to tests the GraphGC against (In fact, we use it for most of the implementation as well, except for the actual garbage collection). We implement an ordinary function collectGarbage on the pure graph and use QuickCheck to test that real garbage collection produces the same results.
  • Garbage collection will mark garbage for collection, but not remove it outright. In order to remove edges from the GraphGC, one has to call removeGarbage explicitly — this makes it easier to reason about which vertices are in the graph, because we no longer have to deal with the concurrency of garbage collection.
  • Using the pure Graph data type in the implementation of GraphGC also has the advantage that the correctness of walkSuccessors can be checked on the pure data type.

@HeinrichApfelmus
Copy link
Owner Author

… and the failing CI indicates that testing garbage collection with QuickCheck is harder than I thought. It worked locally! 😂

… in order to be able to test garbage collection
@HeinrichApfelmus HeinrichApfelmus merged commit 4f0911d into master Dec 26, 2022
@HeinrichApfelmus HeinrichApfelmus deleted the HeinrichApfelmus/graph-gc branch January 21, 2023 22:35
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.

None yet

1 participant