-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
[js][java] Performance lost #8040
Comments
I'm 80% sure it's all the redundant casting going on, but of course we need to look into the generated code and the profiler output. Thanks for the benchmark, we'll look into it as Java target is getting some love for Haxe 4.1 |
Here is more results for Haxe targets :
What is strange for me is Javascript. According this library https://www.npmjs.com/package/bcrypt , JS should produce 2-3 hashes/sec ( with rounds=12 ) , but it fails with only 1.5 hashes / sec. I think JS should be same as Java i.e about 0.40 seconds ( for pure java code) So what can be wrong ?
One solution will be to test the current Haxe js implementation VS npm bcrypt . The other will be to convert haxe code to JS manually without using Haxe compiler |
According these tests ( https://github.com/dcodeIO/bcrypt.js/wiki/Benchmark ) bcryptjs should run for 0.40 seconds ( similiar to hashlink , java ) . Here is test for 12 rounds ( they compare native C++ with JS )
|
If you want to achieve anything with this issue you'll have to profile the generated code to figure out why it's slow. It's Java so I assume there's good tooling for that. |
Yeah, looks like it's the int boxing being a bottleneck... |
Looks like nadako was right. |
By the way, I think we've been here before, but you should really use Vector instead of Array for this kind of stuff. That should actually make a huge difference on Java because it can use the non-boxing native array types. |
Which would mean you'd not only lose the value boxing but also the entire Array layer. |
I will close this issue. My conclusion at the moment for replacing Array with Vector:
So each target should be tested separately using Array or Vector and in the code should be use many compiler flags ( #if java , #if javascript , etc ) to reach good performance. |
Uhm, that's something we should check. How does the generated code differ? Given that |
I replace all Array with Vector and use ```Vector.fromArrayCopy`` for init the Vector .
|
That's what I don't understand. If it's represented as Array then how can it be slower than the Array version? Could you diff the generated code? |
Vector generation created Vectro function . Here is both files ( left is with vector , right is with array) |
Maybe the problem is with blit(). Vector use self created function |
Yes I think js can join the |
Current implementation of import haxe.Timer;
import haxe.ds.Vector;
class Main {
static var tmp:Int;
static public function main() {
var it = new Vector(0xFFFFFF);
// var it = [for(i in 0...0xFFFFFF) i];
Timer.measure(() -> {
for (item in it) {
tmp = item;
}
});
}
} With array created via
With array explicitly populated with integers:
10x speedup on array access for identical generated js (except array init): //Vector init
var it = new Array(16777215);
haxe_Timer.measure(function() {
var _g = 0;
while(_g < it.length) Main.tmp = it[_g++];
return;
} //Array init
var _g = [];
var _g1 = 0;
while(_g1 < 16777215) _g.push(_g1++);
var it = _g;
haxe_Timer.measure(function() {
var _g2 = 0;
while(_g2 < it.length) Main.tmp = it[_g2++];
return;
} |
Changing vector constructor to
|
Moved this to 4.1 as it doesn't seem urgent. |
1,5x slower is still better that 10x. I think the only way to archive same array access performance is changing api to |
I like the idea. And I think we can do it for 4.0 |
That's crazy talk... and let's keep this at 4.1. |
I created two identical files - Haxe and java source - and after that compile Haxe to Java target and run via JVM . There is significant difference between Haxe generated java classes and those write on Java . At example :
Here is all sources and test vectors:
The text was updated successfully, but these errors were encountered: