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

Fastutils wrapping benchmark #142

Merged
merged 1 commit into from
Jan 30, 2015
Merged

Conversation

szymonm
Copy link
Contributor

@szymonm szymonm commented Jan 30, 2015

No description provided.

@szymonm
Copy link
Contributor Author

szymonm commented Jan 30, 2015

When I run the code wrapped version of fastutils collection performs 50% worse than not wrapped:

time of pure map ops: 1862
time of wrapped map ops: 2678

This is possibly due to boxing.

pankajgupta added a commit that referenced this pull request Jan 30, 2015
@pankajgupta pankajgupta merged commit 9d6bef8 into twitter:master Jan 30, 2015
@pankajgupta
Copy link
Contributor

I verified on my computer as well, and it is indeed 50% slower on mine too...

@pankajgupta
Copy link
Contributor

Interestingly, I get the same results when I do
val easyMap = (new Int2IntOpenHashMap()).asInstanceOf[java.util.Map[Int, Int]]

So it is not the scala wrapping, but just the boxing/unboxing at java level.

Any suggestions, @szymonm ? esp. in the light of #139 where also we want to rethink InfoKeeper.

@szymonm
Copy link
Contributor Author

szymonm commented Jan 31, 2015

Yes, looks like using Int2IntOpenHashMap as Map[Int, Int] makes the methods boxed.

Right, we have go back with InfoKeepers.

And hope for efficient specialization in Scala one day.

@szymonm szymonm deleted the fastutilsBenchmark branch February 9, 2015 22:28
@szymonm
Copy link
Contributor Author

szymonm commented Feb 9, 2015

I'm afraid that this means whenever we use:

val nodes: Seq[Int] = new Array[Int](100)

then we have boxing...

@szymonm
Copy link
Contributor Author

szymonm commented Feb 9, 2015

scala> :paste
// Entering paste mode (ctrl-D to finish)

def time(b : => Unit) {
  val start = java.lang.System.currentTimeMillis()
  b
  print(s"Time: ${java.lang.System.currentTimeMillis() - start}")
}

// Exiting paste mode, now interpreting.

time: (b: => Unit)Unit

scala> import scala.util.Random
import scala.util.Random

scala> val arr = new Array[Int](1000000)
scala> (0 until 1000000).foreach{ i => arr(i) = i }

scala> var b = 0
b: Int = 0

scala> time {(0 until 1000000).foreach{ i => b = arr(i) * 7 }}
Time: 7
scala> val seq: Seq[Int] = arr
scala> time {(0 until 1000000).foreach{ i => b = seq(i) * 7 }}
Time: 19

@szymonm
Copy link
Contributor Author

szymonm commented Feb 9, 2015

@pankajgupta please have a look and check it too

@pankajgupta
Copy link
Contributor

Interesting indeed.

In general, in cassovary the desire has been to be first and foremost
efficient on storage (so native arrays) and then be as performant as
possible without getting too low level. This clearly shows that there are
opportunities to improve speed.

On Mon, Feb 9, 2015 at 2:38 PM, Szymon [email protected] wrote:

@pankajgupta https://github.com/pankajgupta please have a look


Reply to this email directly or view it on GitHub
#142 (comment).

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