ikvm icon indicating copy to clipboard operation
ikvm copied to clipboard

Performance degradation when switching from 8.1 to 8.10 version

Open buko1234 opened this issue 6 months ago • 6 comments

I have created simple java application covering standard library operations, translated it with both versions and noticed that 8.10 version works visibly slower. The application covers:

  1. List operations - add, remove
  2. Set operations - add, remove
  3. String and StringBuilder operations - append, substring, deleteCharAt
  4. System.identityHashCode() method

Results(miliseconds):

JAVA List: 1426 Set: 1206 String: 15009 Identity: 2075 ALL: 19718

.NET IKVM 8.1 List: 6978 Set: 5339 String: 29609 Identity: 2730 ALL: 44657

.NET IKVM 8.10 List: 9385 (+34% comparing to 8.1 version) Set: 11611 (+117%) String: 66506 (+125%) Identity: 18215 (+567%) ALL: 105718 (+137%)

As I am aware of time degradation after translating jar into dll, it seems there is big difference after version update.

buko1234 avatar Jun 26 '25 13:06 buko1234

I can't say anything about this without access to the benchmarks and methodology.

wasabii avatar Jun 26 '25 13:06 wasabii

pack.zip

Steps to recreate:

  1. Create simple java project with one class(attached IkvmTest.java)
  2. Run attached a.sh script to create java jar and translate it into dlls(paths in script have to be updated)
  3. Create .NET solution with two projects, each of them referencing different dll. Add attached Program.cs file to both projects and run it.

buko1234 avatar Jun 26 '25 15:06 buko1234

So the biggest difference seems to be the System.identityHashCode implementation. In one of the passes to rely more fully on OpenJDK, it was changed back to it's default implementation, which is in native code in libjvm. That means a JNI entry/exit. So, it appears pretty high in the results of a profiler.

I made an adjustmnet to the 'develop' branch which should eliminate that.

Not sure there's much else though. The biggest hit is StringBuilder.deleteCharAt. That method involves a char[] array copy. It looks completely inlined, though, so it should just be a Buffer.BlockCopy. Which is the same as it was back in 8.1.

wasabii avatar Jun 26 '25 17:06 wasabii

My biggest question and concern is about changes between 8.1 and 8.10 versions. It seems that almost everything(e.g. simple Set add / remove) works more than 2 times slower, so probably it is not the issue of fixing one / couple of methods. Do you have any idea what could cause such performance degradation?

buko1234 avatar Jun 27 '25 06:06 buko1234

Oh. No idea. Why don't you profile it?

wasabii avatar Jun 27 '25 07:06 wasabii

Additional analysis have shown that this performance degradation occurred between 8.1 and 8.2 versions, and next releases are pretty stable. Also, I was not able to narrow it down to any subset of methods which work slower - profiler says that pretty much every method called works slower than in 8.1.

buko1234 avatar Jul 07 '25 10:07 buko1234