Skip to content

Instantly share code, notes, and snippets.

View rxin's full-sized avatar

Reynold Xin rxin

View GitHub Profile
@rxin
rxin / gist:37554d9f3e2e93220884
Last active August 29, 2015 14:05
Scala @inline final val impact on accessors
scala> class A {
| private[this] val abc = 1
|
| def print() = println(abc)
| }
# abc gets inlined by the compiler as a field
[[syntax trees at end of cleanup]] // <console>
package $line4 {
@rxin
rxin / snappy-framed-input-1k.dump
Created July 15, 2014 06:58
snappy framed vs non framed jmap
num #instances #bytes class name
----------------------------------------------
1: 6443 80317016 [B
2: 15102 1939472 <methodKlass>
3: 15102 1749784 <constMethodKlass>
4: 1029 1161976 <constantPoolKlass>
5: 1029 959320 <instanceKlassKlass>
6: 891 697312 <constantPoolCacheKlass>
7: 3680 245496 [C
@rxin
rxin / lzf-1k.dump
Created July 14, 2014 06:59
Compression codec buffer allocation
Every 1000 com.ning.compress.lzf.LZFOutputStream instances allocate 198976424 bytes.
Every 1000 org.xerial.snappy.SnappyOutputStream instances allocate 67660104 bytes.

I was curious about the results reported here, which reports that Scala's mutable maps are slower than Java's: http://www.infoq.com/news/2011/11/yammer-scala

In my tests, Scala's OpenHashMap equals or beats java's HashMap:

Insertion 100k elements (String keys) time in ms:

  • scala HashMap: 92.75
  • scala OpenHashMap: 14.03125
  • java HashMap: 15.78125
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*