Comments…

every line of code should be commented Easy. 10 lines, no comments. After writing a couple of million lines of code, the more code I write, the more I unwind it. Somewhere along the line, adolescent programmers got the idea that jamming all your logic into as few unreadable lines as possible is the fastest…

Read more

Use only max 8KB IO buffer?!?

When wondering strange performance issues in socket IO, I peeked into native code in input stream, and noticed that logic is following: 1) If buffer is smaller (or equal) to 8KB then use stack 2) If not then malloc() Since memory allocation is not ever free, it sounds possible that such memory allocation can cause…

Read more

String Magic

Trie Update: 20.12.2009 1. Characters vs. Bytes 2. On Character Strings 3. Yooster (from: Text Encoding) Update: 21.12.2009 Busting java.lang.String.intern() Myths How Hotspot Decides to Clear SoftReferences Presenting the Permanent Generation Update: 12.1.2010 Memory usage of Java Strings and string-related objects

Read more

More compact XML parsing?

Any java developer who has touched standard java DOM parser, knows that this default XML parser coming with JDK is extreme memory hog. And this boils down into bad overall performance (yes, memory allocation is still not free in java). On that basis following API sounds interesting: VTD-XML: The Future of XML Processing. Interesting point…

Read more

Custom RMI?

RMI has lot of overhead, but even worse part is how it operates as ”black box”. Thus various mechanisms are hidden deeply inside framework, there ain’t any finetuned control over how, for example, sockets are pooled and such. So is there alternatives? For simplicity lets ignore all alternatives, which are not supporting standard Java Serialization….

Read more

NIO + SSL + ServerSocket == wtf?!?

Okey, This (SSLServerSocketChannel) actually looks promising starting point… Appears to be part of larger API/framework called Tammi. However, I’m not so sure that all points mentioned on this FAQ are really covered. As summary: Making NIO to work with SSL (in server side sockets) is big-pain-in-the-ass. Some references: SSLEngine Using SSL with Non-Blocking IO Tricks…

Read more

NIO as cache buffer

Interesting idea: If there is need to (due to performance) to cache large number of objects in memory, what if, instead of using java heap to keep objects, elements would be stored in NIO native byte buffer. In theory that should (a) reduce java heap usage, (b) allow better usage of process memory space (i.e….

Read more

Synchronization and Serialization

One thing to be noted from RMI serialization, like any serialization in java is that serialization of the object doesn’t automagically ensure transactional consistency. In other words, if there is some object, which is modified by the background worker thread, and this same object instance is passed via RMI call to client, then it’s possible…

Read more

Java Strangeness

Interesting knowledge about JIT: Is Your JIT Telling You Lies? Especially interesting is how micro benchmarks lie, which means that trying to trick JIT compiler to do compilation in such small benchmark, can actually give rather misleading results.

Read more