Crazy 1.1 VM !! - How I solved my problem :)

Ok, nuff said about using 1.1, but I had a serious issue with the speed, and I finally solved it. For anyone else dealing with this, this may be useful to know (& it backs up some old posts I was reading from Jeff & other oldtimers):

My 3D software renderer was going well - wonderfully fast in 1.4, and then I tried it in 1.1. Eeek - It ran about 10 times slower!

So I busted out the VC debugger, and ran Explorer through it, paused the debugger and guess what I found…

The code was looking reading a either 1, 2, or 3 bytes via a byte pointer, then branching off on a DWORD pointer. For those that don’t know - this causes a ‘PPro stall’ which is very nasty. I had my suspicions, and lo & behold the bytes it was referencing was my bytecode. The JIT had decided not to bother compiling my renderer!

After trying (unsuccesfully) to change a few things, I came across a post saying ‘inlining could actually lose you performance’. Well I wasn’t inlining, but my function was quite large at 900+ bytecodes - thanks javap :wink:

So I took a small section of the loop, and put it into a little function (de-inlining, even though the code wasn’t inlined in the first place!)

Lo & behold - its running nice and fast again (200k+ textured tris a sec) - the JIT is doing its job again!

Moral of the story: Er, Im not sure, but big functions (i.e. self inlining) can definately screw up the MS 1.1 JIT.

Kudos to Sun, the 1.4 took it in its stride, so this probably doesn’t apply to most of you :slight_smile:

Howabout: if any of us who used to use 1.1 intensively could still remember our tricks and tactics we could probalby make a tidy sum writing a book “Fast and efficient: how to make java 1.1 fly”.

But, sadly, we’ve all worked so hard to eradicate those concepts from our minds, to stop ourselves from sub-consciously polluting our current code, that we probably can’t remember any of them ;).

Or howabout: “MS doesn’t just make crappy out-dated platforms; they also drag modern platforms down to their level (crappy and out-dated) even in the modern world” ;D. Sad, but true…

Thats some good detective work. Unlike some people around here (ahem) I think getting code to run on that pile-o-crap vm can be alot of fun (ie challenge); unfortunately, I wasn’t doing software rendering back in the ‘old days’ and I’d like to get my software renderer running fast on 1.1 someday…

A long time ago I had the same problem, but on the Sun 1.4 JRE. The code ran fast on the MSVM but dog slow on the Sun VM. I ‘de-inlined’ a really large function because it turned out to be interpreted instead of jitted. Afterwards it was fast again but still a bit slower than on the MSVM.
My problem with the MSVM is mainly that it’s very much outdated, and that it seemed to have helped to prevent widespread use of up to date VMs. Other than that it’s actually a quite fast, ‘lean and mean’ VM in my experience.