Carlos Ballesteros Velasco
2017-05-16 23:17:08 UTC
Hello. I'm creating a conversor from JVM bytecode to Dart. In fact, it
works already. And now I'm trying to optimize it as much as I can in this
stage.
https://github.com/jtransc/jtransc/tree/master/jtransc-gen-dart
Things that I'm able to optimize right now:
https://github.com/jtransc/jtransc/blob/8eca4a98c43f35a7a692851f0dcb5bd74e6d78bf/jtransc-rt/resources/dart/Base.dart
I was generating pure JS already. And My benchmark tells me that JS version
is faster.
In JS when performing int32 operations I'm doing the |0 trick: ((a+b)|0)
In Dart I'm using the function N.I(a+b) ----- static int32 I(int v) {
return (v & 0x7fffffff) - (v & 0x80000000); }
Has Dart intrinsics to optimize that kind of int32 operations?
Also shift is unoptimized too because dart doesn't handle negative
shifts: https://github.com/jtransc/jtransc/blob/8eca4a98c43f35a7a692851f0dcb5bd74e6d78bf/jtransc-rt/resources/dart/Base.dart#L56
In order to run this benchmark:
git clone https://github.com/jtransc/jtransc.git
pushd jtransc
./gradlew install
popd
git clone https://github.com/jtransc/jtransc-benchmark.git
pushd jtransc-benchmark/benchmark
./gradlew rundart
./gradlew runjs
popd
If required, I can put here the .js file (running with node-v8 -v6.10.0)
and dart file running with (Dart VM version: 1.23.0 (Fri Apr 21 03:13:00
2017) on "windows_x64")
They both are generated from the same AST, so the structure is identical.
------------
My results to ilustrate (bad performance highlighted):
Benchmark source code:
https://github.com/jtransc/jtransc-benchmark/blob/9ecdf7bb060fb7087509dfa06ae08b900961d70e/benchmark/src/Benchmark.java
JTransc 0.5.16 - dart
Java 1.8.0_51 - 25.51-b03 - 1.8.0_51-b16
Benchmarking:
plain loops...24.0
*left shift...73.0*
*right shift...76.0*
*right unsigned shift...79.0*
call static mult...49.0
call instance mult...50.0
call instance div...141.0
instanceof classes...87.0
arraycopy int...10.0
write byte[]...41.0
write short[]...36.0
write char[]...34.0
write int[]...45.0
write float[]...43.0
write double[]...55.0
String Builder 1...66.0
String Builder 2...28.0
long arithmetic...157.0
simd mutable...41.0
simd immutable...219.0
simd mutable matrix mult...149.0
StringBuilder1...83.0
StringBuilder2...83.0
Create Instances1...2.0
Create Instances2...2.0
Create Instances with builder...256.0
*Java's CRC32...462.0*
*jzlib's CRC32...178.0*
*compress java's Deflate...2882.0*
*compress jzlib...2945.0*
---------------
JTransc 0.5.16 - js
Java 1.8.0_51 - 25.51-b03 - 1.8.0_51-b16
Benchmarking:
plain loops...9.167123
*left shift...18.907874*
*right shift...17.907579*
*right unsigned shift...21.689226*
call static mult...15.011354
call instance mult...14.997497
call instance div...94.273156
instanceof classes...378.080885
arraycopy int...13.711299
write byte[]...32.97181
write short[]...34.282805
write char[]...33.745643
write int[]...35.28383
write float[]...42.055787
write double[]...38.582287
String Builder 1...128.865203
String Builder 2...27.21437
long arithmetic...189.857672
simd mutable...97.261278
simd immutable...132.938952
simd mutable matrix mult...520.873637
StringBuilder1...64.82517
StringBuilder2...65.545762
Create Instances1...9.613116
Create Instances2...7.370748
Create Instances with builder...156.698057
*Java's CRC32...104.484334*
*jzlib's CRC32...95.406556*
*compress java's Deflate...159.09942*
*compress jzlib...160.694131*
Thanks in advance. And congratulations for the dart project!
works already. And now I'm trying to optimize it as much as I can in this
stage.
https://github.com/jtransc/jtransc/tree/master/jtransc-gen-dart
Things that I'm able to optimize right now:
https://github.com/jtransc/jtransc/blob/8eca4a98c43f35a7a692851f0dcb5bd74e6d78bf/jtransc-rt/resources/dart/Base.dart
I was generating pure JS already. And My benchmark tells me that JS version
is faster.
In JS when performing int32 operations I'm doing the |0 trick: ((a+b)|0)
In Dart I'm using the function N.I(a+b) ----- static int32 I(int v) {
return (v & 0x7fffffff) - (v & 0x80000000); }
Has Dart intrinsics to optimize that kind of int32 operations?
Also shift is unoptimized too because dart doesn't handle negative
shifts: https://github.com/jtransc/jtransc/blob/8eca4a98c43f35a7a692851f0dcb5bd74e6d78bf/jtransc-rt/resources/dart/Base.dart#L56
In order to run this benchmark:
git clone https://github.com/jtransc/jtransc.git
pushd jtransc
./gradlew install
popd
git clone https://github.com/jtransc/jtransc-benchmark.git
pushd jtransc-benchmark/benchmark
./gradlew rundart
./gradlew runjs
popd
If required, I can put here the .js file (running with node-v8 -v6.10.0)
and dart file running with (Dart VM version: 1.23.0 (Fri Apr 21 03:13:00
2017) on "windows_x64")
They both are generated from the same AST, so the structure is identical.
------------
My results to ilustrate (bad performance highlighted):
Benchmark source code:
https://github.com/jtransc/jtransc-benchmark/blob/9ecdf7bb060fb7087509dfa06ae08b900961d70e/benchmark/src/Benchmark.java
JTransc 0.5.16 - dart
Java 1.8.0_51 - 25.51-b03 - 1.8.0_51-b16
Benchmarking:
plain loops...24.0
*left shift...73.0*
*right shift...76.0*
*right unsigned shift...79.0*
call static mult...49.0
call instance mult...50.0
call instance div...141.0
instanceof classes...87.0
arraycopy int...10.0
write byte[]...41.0
write short[]...36.0
write char[]...34.0
write int[]...45.0
write float[]...43.0
write double[]...55.0
String Builder 1...66.0
String Builder 2...28.0
long arithmetic...157.0
simd mutable...41.0
simd immutable...219.0
simd mutable matrix mult...149.0
StringBuilder1...83.0
StringBuilder2...83.0
Create Instances1...2.0
Create Instances2...2.0
Create Instances with builder...256.0
*Java's CRC32...462.0*
*jzlib's CRC32...178.0*
*compress java's Deflate...2882.0*
*compress jzlib...2945.0*
---------------
JTransc 0.5.16 - js
Java 1.8.0_51 - 25.51-b03 - 1.8.0_51-b16
Benchmarking:
plain loops...9.167123
*left shift...18.907874*
*right shift...17.907579*
*right unsigned shift...21.689226*
call static mult...15.011354
call instance mult...14.997497
call instance div...94.273156
instanceof classes...378.080885
arraycopy int...13.711299
write byte[]...32.97181
write short[]...34.282805
write char[]...33.745643
write int[]...35.28383
write float[]...42.055787
write double[]...38.582287
String Builder 1...128.865203
String Builder 2...27.21437
long arithmetic...189.857672
simd mutable...97.261278
simd immutable...132.938952
simd mutable matrix mult...520.873637
StringBuilder1...64.82517
StringBuilder2...65.545762
Create Instances1...9.613116
Create Instances2...7.370748
Create Instances with builder...156.698057
*Java's CRC32...104.484334*
*jzlib's CRC32...95.406556*
*compress java's Deflate...159.09942*
*compress jzlib...160.694131*
Thanks in advance. And congratulations for the dart project!
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.