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

Garbage collection of dirty keys #2263

Merged
merged 22 commits into from
Oct 30, 2021
Merged

Garbage collection of dirty keys #2263

merged 22 commits into from
Oct 30, 2021

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Oct 8, 2021

This runs a garbage collection process when a file is closed, releasing all the keys that remain dirty after a build of all the open files. Essential keys are not GC'ed to avoid information loss and inefficient rebuilds.

For example, if we have A, B and C open in the IDE and close A, the garbage collection will release all the keys that were specific to A, and preserve all the keys that are still needed by B and C.

I have been able to validate heap usage reductions after closing all the files in the editor and triggering a keys GC followed by a heap GC. So it does seem to do what we want.

TODO

  • Test
  • Measure improvement
  • Restore heap tracing code
  • Fix flaky tests
  • Think a bit more about GC strategy
  • GC seems to break diagnostics
  • Check plugins with custom rules
  • Break down in smaller PRs

EDIT: moved EKG to another PR since it introduces new deps that break the GHC 9 build

@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Oct 18, 2021

This is now ready for review and dogfooding, since I'm not sure whether the problem with GC breaking diagnostics still exists.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

great, this was really needed

@jneira
Copy link
Member

jneira commented Oct 21, 2021

Maybe we should wait to merge this after the next release?

@jneira
Copy link
Member

jneira commented Oct 22, 2021

Maybe related: #713, which is asking for garbage collect diagnostics from files not in or not linked to any actual file of interes

@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Oct 22, 2021

Thanks for linking it. That ticket is about cleaning up diagnostics, not related to this. But there's a comment by @mpickering on performing garbage collection only when the FOI set is modified that is very relevant.

@pepeiborra
Copy link
Collaborator Author

So beautiful:

image

@pepeiborra pepeiborra force-pushed the garbage-collection branch 2 times, most recently from e23f7c6 to 78ca34b Compare October 23, 2021 18:42
@wz1000
Copy link
Collaborator

wz1000 commented Oct 24, 2021

Looks good. However, I wonder if it would be neater to use an LRU datastructure to store the hls-graph database itself, instead of manually triggering garbage collection on idle.

@pepeiborra
Copy link
Collaborator Author

Looks good. However, I wonder if it would be neater to use an LRU datastructure to store the hls-graph database itself, instead of manually triggering garbage collection on idle.

Yesterday I changed the collection to trigger on file close, rather than on idle. We rely on dirtiness to inform on which keys are not relevant and can be deleted, so I'm not sure that LRU would be helpful. I have updated the PR description to reflect this.

@mpickering
Copy link
Contributor

I am dogfooding this MR @pepeiborra, thanks for working on it.

@pepeiborra
Copy link
Collaborator Author

Maybe we should wait to merge this after the next release?

Is this still the plan or should we go ahead and merge ?

@github-actions
Copy link

We are gonna [skip circleci]

@jneira
Copy link
Member

jneira commented Oct 30, 2021

Maybe we should wait to merge this after the next release?

Is this still the plan or should we go ahead and merge ?

i think we have to postpone the release so i would go ahead and merge

@pepeiborra pepeiborra merged commit 2204a16 into master Oct 30, 2021
pepeiborra added a commit that referenced this pull request Nov 2, 2021
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.

4 participants