Latest Content
Perceiving The Effects Of Cache Coherency In Spin Locks
The "test-and-test-and-set" algorithm is a fairly well-understood solution to reducing latency in spin locks. In particular, the algorithm is often employed to reduce the latency exhibited in the similar "test-and-set" algorithm. Understanding how and why a seeming-superfluous read results in lower latency is rather interesting. ... read moreDowncasting Longs To Ints On x86
Last week, my esteemed colleague and close friend asked a remarkably straight-forward question about downcasting along
to an int
in Java. I'll admit the question caught me off guard. While the JLS offered the correct answer, I couldn't help but ponder what's actually happening in the machine. ... read more
Finally, Rollback Your Transaction
Lately, I've been working with code that exhibits a fairly poor practice: programmatic transactions (namely Spring) don't always get committed or rolled-back, even though the code appears correct. Consider the following contrived scenario: ... read moreEnum Hash Codes Are Non-Deterministic
An annoying discovery: JavaEnum
objects have non-deterministic hash codes. Specifically, a hash code is the Enum
's identity (or memory address). ... read more
No ConcurrentHashSet? No Problem
The JDK provides several concurrentSet
classes, each with their own application, but it does not provide a ConcurrentHashSet
. Using the Collections
utility class, however, such a structure may be created. ... read more
Using @cache_page With Django's Feeds
When returning adjango.contrib.syndication.Feed
from a view function, the @cache_page
decorator does not seem to work as expected. Briefly inspecting the source of Feed
explains why: Feed
is not an HttpResponse
. Truly, this isn't a bug: it's a documentation (if not comprehension) issue. Because the view function is expected ... read more
The Concurrency Of ConcurrentHashMap
Java'sConcurrentHashMap
is an excellent point of study when learning about Java's Memory Model. It employs numerous techniques to provide lock-free reads while still guaranteeing safe publication of objects. This article represents my attempt to take the magic out of the ConcurrentHashMap
implementation. ... read more
Escape Analysis & Stack Allocated Objects
In 1999, a paper, Escape Analysis For Java was to appear in the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications. This paper outlined an algorithm to detect whether an object,O
, escaped from the currently executed method, M
, or current thread, T
. This paper ... read more
Impact Of Local Variable Declaration Location
Does the location of a local variable's declaration result in performance changes of a method? For example, will aString
variable, s
, declared outside of a loop exhibit "better" performance than when declared inside a loop? In Java, looking at a class' bytecode explains, irrefutably, why the answer is ... read more