Cache locality in java

Not new, but still quite interesting to read: Caching and the Java Virtual Machine References: Thread scheduling implications in Java Use stack variables whenever possible Java bytecode: Understanding bytecode makes you a better programmer The Final Word On the final Keyword Premature Optimization Java theory and practice: Managing volatility How fast is Java Volatile? or…

Read more

Mysteries of Nimbus

About defaults in Nimbus: Nimbus Defaults (originates from: Nimbus UIManager UIDefaults) Misc Textarea background issue Update: 10.7.2010 Skinning a Slider with Nimbus

Read more

Beware of Antipatterns

Instead of having ”this proper way”, anti patterns tend to be even more useful by pointing out issues which are problematic. Java Anti-Patterns

Read more

Converting String to UTF8?

Lets see what happens when trying to convert random string into UTF8 using different methods. [code lang=”java”] package org.kari.test.string; import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.charset.Charset; import org.apache.log4j.Logger; import org.kari.log.LogUtil; import org.kari.util.DirectByteArrayOutputStream; /** * Test UTF8 conversion * * @author kari */ public class UTF8Test { public static final Logger LOG = LogUtil.getLogger(”utf8”); private static final…

Read more

Interactive javascript shell

Naive, but functional interactive javascript shell with Java 6. [code lang=”java”] package org.kari.test.script; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; import org.apache.log4j.Logger; import org.kari.log.LogUtil; /** * Test interactive javascript shell * * @author kari */ public class ScriptShell { public static final Logger LOG = LogUtil.getLogger(”script.shell”); private final…

Read more

”Must have” utility

Java Decompiler Best part is that there is also Eclipse plugin in addition to standalone utility, which seems to also work reasonably well with Eclipse 3.5.1.

Read more

Oops, I did it again….

Compressed oops in the Hotspot JVM Big Question is why to bother? And the answer is Cache. In other words, using shorter pointers allows fitting more data into processor caches, which improves performance considerably. References: 32-bit or 64-bit JVM? How about a Hybrid? <a href=”http://blog.juma.me.uk/2009/04/03/load-unsigned-and-better-compressed-oops/”>Load unsigned and better Compressed Oops

Read more

Reducing memory usage

Example 31-2. Setting fetch size to turn cursors on and off. PostgreSql, JDBC and large result sets Large ResultSet on postgresql query Is JDBC a big memory hog? Setting some reasonable fetch size might be meaningfull when working with results sets consisting from thousands of elements. Appearent difference is that with default fetch size, all…

Read more

Compact String Dictionary

If system needs to process lots of short strings, which actually quite often are same, then using some dictionary to map strings into compact unique identifiers can improve memory usage and performance quite a bit. [code lang=”java”] package org.kari.test.string; import gnu.trove.TObjectIntHashMap; import java.util.ArrayList; import java.util.List; /** * Dictionary mapping strings int compact identifiers * *…

Read more

Going to DB…

Open Source Database Engines in Java Hmm…. H2? When developing software with Java, why anyone would bother with non-Java DB, i.e. all the problems with native library compatibility and such (32bit/64bit, Linux/Windows/etc., M$XP/M$Vista/M$7/…)? Especially interesting sounds the possibility to embed DB into java process, thus avoiding having separate process and socket (or such) communication with…

Read more