How to tune java performance on low end machines?
I'm looking for hints as to how I can speed up a java program I'm writing.
I'm doing a little personal project to put on my NAS for which I was hoping to use java. The box is a 500MHz ARM based box running Debian and using openjdk-6-jre-headless for the JVM.
I'm having difficulties with performance which seem to be atributed to the fact that I'm using Java (perhapse it's the specific JVM but the SUN JVM doesnt appear to be available for ARM).
The stub that I've built so far compares a table of known files (stored in a PostgreSQL database) with actual files on the box comparing timestamps and filesizes as well as checking for new and removed files. It then batch updates the database as apropriate. For ~6000 files this takes ~2 minutes.
The same task done in C takes ~5 seconds.
I'm aware that Java can often be slower but this is serveral orders of magnitude slower.
The algorythm is simple enough:
- Select everything from the database which should be found in the directory we're scanning. (Using JDBC).
- Add the result set to a Map (Hash or Tree makes little difference)
- Recurse the directory tree removing from the map
- If a file is not found in the map then insert a new row
- If a file is found but with different stats then update the row
- Delete the row for anything left in the map at the end.