Skip to content

Conversation

BurntPizza
Copy link
Contributor

Don't know if it's not "in the spirit" of the bench, but struct-of-arrays is much faster then array-of-structs.
It's almost 2x for me.

If you want it to be more consistent with the design of the other impls, at least change Vec2 to be a static inner class, that's about 13% quicker than the existing impl.

Don't know if it's not in the "spirit" of the bench, but struct-of-arrays is way faster then array-of-structs.
It's almost 2x for me.
@nsf
Copy link
Owner

nsf commented Nov 12, 2014

Won't accept it, because it's cheating. If SOA vs AOS is indeed the reason for performance boost, I could apply the same for other implementations.

I'm not really comparing how fast you can implement perlin noise using given language, I'm comparing how well a language compiler can optimize the particular code. Minor tweaks such as inlining hints are allowed.

For example I know that if you switch everything in the code from float to double in C# implementation, it gives 30% improvement in performance (1.0s -> 0.7s) on mono. But I'm not sure if I should apply that change as well.

As for turning Vec2 into static inner class (whatever that means, I don't know java and it wasn't me who wrote the java implementation), make a pull request and I'll apply it.

@BurntPizza
Copy link
Contributor Author

Alright. I guess it's have to wait until Java 10 or whenever value types come in.
The reason why SOA is faster in Java's case is because currently Java can't turn small classes into structs, but the programmer can do the equivalent manually via that transformation, removing the indirection from indexing the array of objects to get to their fields and instead simply directly accessing the array of their fields. This will happen automatically once Java gets actual structs.
I sent in the other pull request.

@asterite
Copy link
Contributor

@BurntPizza Will Java get actual structs? When is that supposed to happen? Do you have a link?

@BurntPizza
Copy link
Contributor Author

@asterite Here's as good a link as any, although you can find more through googling "java value types" and "project valhalla"

http://cr.openjdk.java.net/~jrose/values/values-0.html

Also of note is a library by a friend of mine: https://github.com/riven8192/LibStruct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants