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

Reduce memory consumption of Types.uniques by using WeakHashSet #7149

Closed
scabug opened this issue Feb 19, 2013 · 3 comments
Closed

Reduce memory consumption of Types.uniques by using WeakHashSet #7149

scabug opened this issue Feb 19, 2013 · 3 comments

Comments

@scabug
Copy link

@scabug scabug commented Feb 19, 2013

I experimented with making Types.uniques a weak hashset in this branch:
https://github.com/gkossakowski/scala/tree/weak-unique-types

I was using Yourkit to measure memory consumption (through strong references) after a few phases while doing quick.lib and quick.comp. Here are my results:

Phase		Regular		Optimized	Gain
typer		145			114	31 (21%)
erasure		241			179	62 (25%)
cleanup		281			217	64 (22%)

Numbers for quick.comp
======================
Phase		Regular		Optimized	Gain
typer		225			188	37 (16%)
erasure		329			275	54 (16%)
cleanup		370			319	51 (13%)

Optimized here means we used locker build out of the following commit:
gkossakowski/scala@85c8e26

which uses a copy of Java's WeakHashMap. The reason I had to copy the whole implementation of WeakHashMap is that we need an access to getEntry method which is package protected so there's no other option to just copy that class (and some of its dependencies) to our own package. That was meant just to try the idea.

It looks like we'll need to implement our own WeakHashSet one way or another. If we go down that route we might be able to squeeze a little bit more of memory because we don't need value field in Entry object for sets.

Implementing my own collection is a bigger task that I can spend time on right now so I just leave this ticket open were we have potential benefits documented.

@scabug
Copy link
Author

@scabug scabug commented Feb 19, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7149?orig=1
Reporter: @gkossakowski
Assignee: @JamesIry
Other Milestones: 2.11.0-M4

@scabug
Copy link
Author

@scabug scabug commented Jun 5, 2013

@scabug scabug closed this Jun 5, 2013
@scabug
Copy link
Author

@scabug scabug commented Sep 13, 2013

@retronym said:
Backported to 2.10.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant