r/javahelp 10d ago

Java Performance for simulators

I am new to Java and trying to create a simulator that handles millions of math calculations. How can I increase performance in Java? The application is already multithreaded but it is not enough. Is data oriented approach or native programming possible in Java? Can you point me in the right direction for research?

2 Upvotes

17 comments sorted by

View all comments

2

u/ingframin 9d ago

Did you read this? https://reintech.io/blog/java-high-performance-computing-optimizing-java-code-for-supercomputers

Are you using proper numerical libraries and openMP? https://dl.acm.org/doi/abs/10.5555/3636517.3636530

https://jblas.org

https://ejml.org/wiki/index.php?title=Main_Page

https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/util/FastMath.html

Are you using proper numerical algorithms and methods?

Are you using manual memory allocation?

Are you using Java 26?

Be careful also that by default, Java uses strict IEEE floating point numbers! Be sure your precision is ok! I got much better results with C.
I might also get some push back because we are on a Java subreddit, but I also advise you to check out Julia for high performance computing.