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

Specialize Scala collections (Vector, in particular) #4495

Closed
scabug opened this issue Apr 19, 2011 · 6 comments
Closed

Specialize Scala collections (Vector, in particular) #4495

scabug opened this issue Apr 19, 2011 · 6 comments

Comments

@scabug
Copy link

scabug commented Apr 19, 2011

= problem =
Scala 2.9 RC1 has been released, and there are still no collections that have been specialized as far as I can tell from the source. Missing specialization for Vector in particular is a problem because the overhead of storing an Integer instead of an Int is about 5x on a 64 bit JVM, and Vector is the most performant collection we have.

I understand adding specialization everywhere would create code bloat, but just adding it to Vector alone (and not even IndexedSeqLike and such) would greatly reduce the memory consumption of these classes.

@scabug
Copy link
Author

scabug commented Apr 19, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4495?orig=1
Reporter: Joshua Hartman (jhartman)

@scabug
Copy link
Author

scabug commented Jul 31, 2011

Kipton Barros (kbarros) said:
It would also be nice to have a specialized ArrayBuffer

@scabug
Copy link
Author

scabug commented Aug 18, 2012

@rklaehn said:
Adding @specialized to Vector is probably a can of worms. If it was straightforward it would have been done already. But there are some collections where adding @specialized would be pretty straightforward. For example HashSet.HashSet1. That would reduce the number of objects used for a HashSet by about a factor of two.

@scabug
Copy link
Author

scabug commented Aug 18, 2012

@soc said (edited on Aug 18, 2012 12:47:00 PM UTC):
I'm not sure if it really counts as "specialization", but there are a few other array-based data-structures which would immensely benefit from allocating JVM's "specialized" primitive array instead of Array[AnyRef] for storing the elements internally.

This could be done without emitting specialized bytecode for primitive types, it would need a TypeTag instead.

@scabug
Copy link
Author

scabug commented May 22, 2013

Harshad (hrj) said:
I just had this idea. What if specialized collections were to be distributed as a separate modular library, in line with the 2.11 effort of modularization?

I (naively) imagine that this could be implemented by having a compiler flag called, say, --emit which can take three values: all, specialized-only, generic-only. The default would be all.

While compiling the scala standard library, the scripts would use generic-only in the first run, and then specialized-only in the second run.

For most other libraries, default would work fine.

@SethTisue
Copy link
Member

Out of scope for Scala 2

@SethTisue SethTisue closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants