Skip to content

Improve performance of tuple operations #7689

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

Merged
merged 32 commits into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0dd6ec7
Add benchmarks for map and zip
Nov 11, 2019
57177ba
Kept the improvments from tuple-tweaks-01
Oct 12, 2019
45044d3
Rename class for consistency
Oct 13, 2019
1dc4027
Special cased dynamicCons and dynamicTail
Oct 16, 2019
9fd94e5
Special cased some more code
Oct 17, 2019
5e32838
Improve tuple cons by removing a useless array copy
Oct 23, 2019
0d0735c
Fix invalid size in DynamicCons
Oct 24, 2019
2fdc0d4
Remove the tuple22 special case from tupleCons
Nov 3, 2019
3090540
Report the changes of tupleCons to tupleConcat and tupleTail
Nov 4, 2019
bfde674
Fix error in DynamicTuple
Nov 4, 2019
bf81b5d
Fix a problem with parameter type in dynamicCons
Nov 4, 2019
fc6a694
Use iterators concatenation
Nov 5, 2019
78a3211
Try yet another tweak
Nov 5, 2019
d4e8ebe
Try to improve the performance in edge cases (n = 22 or n = 23)
Nov 6, 2019
a681098
Remove unnecessary dynamicFromIArray (replaced by TupleXXL.fromIArray)
Nov 6, 2019
3286379
Add some benchmarks in tupleCons
Nov 6, 2019
fe4eaa4
Trying to see if tupleCons is too big for optimizations
Nov 7, 2019
18fe0c8
Try to reduce function bodies so that the JIT compiler optimizes them…
Nov 9, 2019
e1a01d2
Try to optimize dynamicMap
Nov 13, 2019
86ca325
Try to improve even more tupleCons and tupleTail by making them reall…
Nov 14, 2019
f517abe
Trying to improve tupleZip
Nov 14, 2019
3248227
Add a new folder for test files
Nov 14, 2019
20f7f39
Add tests for tupleConcat
Nov 14, 2019
036683d
Add some tests to all current tuple operations
Nov 14, 2019
4d47151
Make the tuple tests independent for better granularity
Nov 20, 2019
6ee2edb
Factorize code in tuple concat
Nov 27, 2019
3cabf84
Replace itToArray by Iterator.copyToArray(...)
Nov 27, 2019
348a448
Rebase and comment
Dec 5, 2019
646caa4
Fix issue in dynamic map
Dec 7, 2019
025e91f
Add necessary method for bootstrapped compilation
Dec 7, 2019
b1977cb
Remove unintentionnal comments
Dec 12, 2019
08613cb
Move unit cases to improve performance
Dec 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bench-run/inputs/map.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
size:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
1 change: 1 addition & 0 deletions bench-run/inputs/zip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
size:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class Concat {
var sizes: String = _
var tuple1: Tuple = _
var tuple2: Tuple = _
var array1: Array[Object] = _
var array2: Array[Object] = _

def tupleOfSize(n: Int): Tuple = {
var t: Tuple = ()
Expand All @@ -26,17 +24,10 @@ class Concat {
val size2 = sizes.split(' ')(1).toInt
tuple1 = tupleOfSize(size1)
tuple2 = tupleOfSize(size2)
array1 = Array.fill(size1)("elem")
array2 = Array.fill(size2)("elem")
}

@Benchmark
def tupleConcat(): Tuple = {
DynamicTuple.dynamicConcat(tuple1, tuple2)
}

@Benchmark
def arrayConcat(): Array[Object] = {
array1 ++ array2
}
}
16 changes: 12 additions & 4 deletions bench-run/src/main/scala/dotty/tools/benchmarks/tuples/Cons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class Cons {
@Param(Array("0"))
var size: Int = _
var tuple: Tuple = _
var array: Array[Object] = _
var array1: Array[Object] = _
var array2: Array[Object] = _

@Setup
def setup(): Unit = {
Expand All @@ -17,7 +18,8 @@ class Cons {
for (i <- 1 to size)
tuple = "elem" *: tuple

array = Array.fill(size)("elem")
array1 = new Array[Object](size)
array2 = new Array[Object](size + 1)
}

@Benchmark
Expand All @@ -26,7 +28,13 @@ class Cons {
}

@Benchmark
def arrayCons(): Array[Object] = {
DynamicTuple.cons$Array("elem", array)
def createArray(): Array[Object] = {
new Array[Object](size + 1)
}

@Benchmark
def consArray(): Array[Object] = {
System.arraycopy(array1, 0, array2, 1, size)
array2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.openjdk.jmh.annotations._
import scala.runtime.DynamicTuple

@State(Scope.Thread)
class ArrayOps {
class Conversions {
@Param(Array("1"))
var size: Int = _
var tuple: Tuple = _
Expand Down
Loading