Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DO NOT MERGE: On disk cache #4963

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

DO NOT MERGE: On disk cache #4963

wants to merge 4 commits into from

Conversation

gzm0
Copy link
Contributor

@gzm0 gzm0 commented Mar 16, 2024

No description provided.

@gzm0
Copy link
Contributor Author

gzm0 commented Mar 16, 2024

Sharing a negative result: This PR attempts to cache printed trees on disk rather than in memory.

However, on the test suite, we save less than 30MB of residual memory on PrintedTree instances.

Baseline: 111MB
This PR: 85MB

Seems like most of the memory usage goes into SourceMapFragment. I guess the learning is to attempt and optimize that.

/cc @sjrd

@sjrd
Copy link
Member

sjrd commented Mar 16, 2024

Huh, that's bold. :P

I'm not really surprised that SourceMapFragments are the biggest culprit. For every few bytes worth of characters in PrintedTree buffers, there an entire instance of FragmentElement.Segment:

private sealed abstract class FragmentElement
private object FragmentElement {
case object NewLine extends FragmentElement
// name is nullable
final case class Segment(columnInGenerated: Int, pos: Position, name: String)
extends FragmentElement
}

It might be worth investigating a serialized form of Fragments, which would encode these instances as byte sequences inside a unique buffer per Fragment.

@gzm0
Copy link
Contributor Author

gzm0 commented Mar 16, 2024

It might be worth investigating a serialized form of Fragments, which would encode these instances as byte sequences inside a unique buffer per Fragment.

Yeah, I'll take a stab at this.

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.

2 participants