Open i10416 opened 1 year ago
I confirmed that transfering array back and forth takes around 10 times longer in slinc 0.3.0 than slinc 0.1.1
Yes this is expected. The current versions of Slinc have focused on simplifying and refractor the code. Once I've implemented all the major features of java foreign API, optimization will be more of a focus.
The current plan for optimization will be more rigorous than Slinc 0.1.1. In that, optimal code was only generated for calls that are entirely compiletime knowable. This is unrealistic with C and it's types being very dependent on the platform the program is running on.
Slinc going forward will generate the optimal code at runtime using runtime multistage programming. This enables the optimal code to be generated based on runtime information.
Thanks! I'm looking forward to future optimization!
By the way, I feel Slinc is quite promising as Slinc will help interoperation between Scala JVM and Scala Native. In fact, it couldn't be easier to write Scala Native binding in Scala with Slinc!
PoC: https://github.com/i10416/slinc-examples/tree/main/scalanativeinterop
Considering
SimpleNativeCallBenchmarks.slincQSortWithCopyBack
becomes 597864.321 -> 1210048.181 (x2)SimpleNativeCallBenchmarks.slincQSortWithoutCopyBack
becomes 611254.382 -> 963393.420 (x1.5)SimpleNativeCallBenchmarks.slincQsortAllocCallbackForEachIteration
is almost the same (from 1672473.620 to 1623060.091),It seems there is a performance degradation for data transfer between 0.1.0 and 0.3.0.
slinc 0.1.1-110-7863cb, Scala 3.3.0-RC3
slinc 0.3.0, Scala 3.3.0-RC3
Env:
https://github.com/i10416/bench/blob/main/bench-0.3/src/test/scala/SlincBenchmark.scala