[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Netbeans 6.3 profiler and Jace: Now only uses 10% - 15% cpu!
On Friday, October 26, 2012 10:31:49 AM UTC-5, BLuRry wrote:
> The new version of Netbeans has better support for sampled profiling of Java apps, which means I was able to get better breakdowns on where Jace was slowing down so much. No 8-bit emulator should chew up a modern computer so much!
>
>
>
> I'm happy to say that I found the culprit: Memory synchronization. A few months ago, I changed memory access in Jace to be more synchronized. In the rare event that something outside the main thread is accessing memory, I wanted to ensure that it didn't collide with the main CPU thread. So I made all access synchronized (as well as halt the main CPU thread to avoid timing collisions.)
>
>
>
> There were very little cases where memory is being accessed outside of the main thread. In the majority of cases RAM is being accessed by one and only one thing at a time, since I structured the main loop to match the same way the real machine works.
>
>
>
> Removing all that synchronization overhead means that now Jace is using 10% cpu instead of 60%. I have more testing to ensure that no concurrent exceptions occur -- but I've learned my lesson. Concurrency and resource synchronization are EXPENSIVE! The concurrency is still there, but there's an additional parameter to the read/write methods where you specify if synchronization is required.
>
>
>
> Now that I've made this more efficient, I can finish tidying up other stuff. There's nothing about this CPU core that is so inefficient that it would perform poorly on a Snapdragon via Dalvik JVM. ;-)
>
>
>
> -B
Side note: I haven't posted the code changes to sourceforge yet but will do so after I've done more testing.