JVM seems to include few new intesting optimization options -XX:+UseCompressedStrings -XX:+OptimizeStringConcat -XX:+UseStringCache Why these sounds interesting. Well, simply because strings are among the biggest memory consumers, and string manipulations like concat tends to be relatively slow. Update: OptimizeStringConcat is in JDK 1.6.0_18 References: The Virtual Machinist: -XX:+UseCompressedStrings explained Google Groups: Description of -XX:+OptimizeStringConcat ? Stackoverflow:…
Read morePremature Optimization: Chapter ”Class is the root of all evil”
It’s interesting question of how different constructs perform in code. And in java world and very often encountered construct is discussion about what should be used as param (or return value) in API methods. From API maintainability, extensibility, clearness etc. point of view, answer is 101% clear. Using interfaces make APIs more generic, by leaving…
Read moreAnalyzing thread time usage
Without any testing, just seeing that it compiles, following code snippet should allow embedding periodic thread time usage analysis into application. [code lang=”java”] import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** * Thread time usage analyzer */ final class Analyzer extends Thread { /** * Accuraracy of measurement; coarse timing is enough,…
Read moreAnalyzing Byte Cote
So lets see how we can test for ”param is valid type”. Bar [code lang=”java”] public class Bar { } [/code] Test [code lang=”java”] public class Test { private static final Class CLS = Bar.class; public static void test1(Object a) { if (a instanceof Bar) { int x = 0; } } public static void…
Read moreHidden cost of initialization
Trick question: What is difference between these: Sample Code 1 [code lang=”java”] class FooBar { private int x = 0; [/code] Sample Code 2 [code lang=”java”] class FooBar { private int x; [/code] Q: What is difference? I.e. aren’t those pieces of code by definition exactly same, thus it doesn’t matter what you write. A:…
Read moreReal UML
My interest (after trying lots of different tools, Objecteering, ArgoUML, BoUML) into real UML tools was arised with this one: UMLet UMLet allow nice user friendly concept of editing properties of elements direcly as plain text, instead of clumsy dialogs like every other tools what I’d tried so far. However, appetite grows, and this sounds…
Read moreDuh, Don’t, now keep going on…
Seemingly there is eeny-weeny little things what could be optimized in Log4J. Re: Proposed synchronization changes log4j-dev Re: log4j multithreading performance Proposed synchronization changes By quickly looking, changes make sense, only one detail strikes me as potential problem: new logic is causing re-allocation of StringBuffer iin PatternLayout, everytime when formatting of layout is done (==…
Read moreDriving java with handbreak on
Do you driver your car with handbreak on? Doesn’t it feel a bit cumbersome? Well, concurrent programming with java can easily turn into equivalent situation, simply due to fact that some synchronization is required between threads. And sad fact is that there isn’t actually clear workaround for this since correctness of program requires usage of…
Read morenice
The measures of programming
Read moreRunning with breaks on
While not being expert in web server maintenance it came as surprise to me that seemingly still in year 2011 default configuration of apache2 (nor tomcat6) isn’t enabling compression by default. Instead some manual tweaking is required. So steps are: Step 1: [code] vim /etc/sysconfig/apache2 [/code] Append following into file [code] APACHE_MODULES=”… jk deflate” vim…
Read more