Tal Weiss

Posts Twitter

Tal is the CEO of Takipi. Tal has been designing scalable, real-time Java and C++ applications for the past 15 years. He still enjoys analyzing a good bug though, and instrumenting code. In his free time Tal plays Jazz drums.

Breakdance Supercharged jstack: How to Debug Your Servers at 100mph

A guide for using jstack to debug live Java production servers

jstack is like U2 – it’s been with us since the dawn of time, and we can’t seem to be rid of it. Jokes aside, jstack is by far one of the handiest tools in your arsenal to debug a live production server. Even so, I still feel it’s deeply underused in terms of its ability to pull you out of the fire when things go bad, so I wanted to share a few ways in which you can supercharge into an even stronger weapon in your war against production bugs.

Continue Reading…

Blog Trash 1 Garbage Collectors Serial vs. Parallel vs. CMS vs. G1 (and what’s new in Java 8)

 

The 4 Java Garbage Collectors – How the Wrong Choice Dramatically Impacts Performance

The year is 2014 and there are two things that still remain a mystery to most developers – Garbage collection and understanding the opposite sex. Since I don’t know much about the latter, I thought I’d take a whack at the former, especially as this is an area that has seen some major changes and improvements with Java 8, especially with the removal of the PermGen and some new and exciting optimizations (more on this towards the end).

When we speak about garbage collection, the vast majority of us know the concept and employ it in our everyday programming. Even so, there’s much about it we don’t understand, and that’s when things get painful. One of the biggest misconceptions about the JVM is that it has one garbage collector, where in fact it provides four different ones, each with its own unique advantages and disadvantages. The choice of which one to use isn’t automatic and lies on your shoulders and the differences in throughput and application pauses can be dramatic.

Continue Reading…

Blog key Java 8 StampedLocks vs. ReadWriteLocks and Synchronized

Synchronized sections are kind of like visiting your parents-in-law. You want to be there as little as possible. When it comes to locking the rules are the same – you want to spend the shortest amount of time acquiring the lock and within the critical section, to prevent bottlenecks from forming.

The core language idiom for locking has always been the synchronized keyword, for methods and discrete blocks. This keyword is really hardwired into the HotSpot JVM. Each object we allocate in our code, be it a String, Array or a full-blown JSON document, has locking capabilities built right into its header at the native GC level. The same goes for the JIT compiler that compiles and re-compiles bytecode depending on the specific state and contention levels for a specific lock.

The problem with synchronized blocks is that they’re all or nothing – you can’t have more than one thread inside a critical section. This is especially a bummer in consumer / producer scenarios, where some threads are trying to edit some data exclusively, while others are only trying to read it and are fine with sharing access.

Continue Reading…

Blog treasure box 10 Features in Java 8 You Havent Heard Of

Lambdas lambdas lambdas. That’s all you ever hear about when talking about Java 8. But that’s just one part. Java 8 has a lot of new features – some are powerful new classes and idioms, while others are just things that should have been there from the get-go.

I wanted to go over ten new features which I consider to be little gems definitely worth knowing about. There are bound to be at least one or two you’d like to try, so let’s get going!

1. Default Methods

A new addition to the Java language, you can now add method bodies to interfaces (called default methods). These methods are implicitly added to every class which implements the interface.

This enables you to add functionality to existing libraries without breaking code. That’s definitely a plus. The flip side is that this seriously blurs the line between an interface, which is meant to serve as a contract, and a class which serves as its concrete implementation. In the right hands this can be an elegant way to make interfaces smarter, avoid repetition and extend libraries. In the wrong hands, we’ll soon be seeing interface methods querying this and casting it to a concrete type. Shivers….

Continue Reading…

blog boat 1 The 7 Log Management Tools Java Developers Should Know

Splunk vs. Sumo Logic vs. LogStash vs. GrayLog vs. Loggly vs. PaperTrails vs. Splunk>Storm

 

Splunk, Sumo Logic, LogStash, GrayLog, Loggly, PaperTrails – did I miss someone? I’m pretty sure I did. Logs are like fossil fuels – we’ve been wanting to get rid of them for the past 20 years, but we’re not quite there yet. Well, if that’s the case I want a BMW!

To deal with the growth of log data a host of log management & analysis tools have been built over the last few years to help developers and operations make sense of the growing data. I thought it’d be interesting to look at our options and what are each tools’ selling point, from a developer’s standpoint.

Splunk

As the biggest tool in this space, I decided to put Splunk in a category of its own. That’s not to say it’s the best tool for what you need, but more to give credit to a product who essentially created a new category.

Pros

Splunk is probably the most feature rich solution in the space. It’s got hundreds of apps (I counted 537) to make sense of almost every format of log data, from security to business analytics to infrastructure monitoring. Splunk’s search and charting tools are feature rich to the point that there’s probably no set of data you can’t get to through its UI or APIs.

Continue Reading…

Blog sheeps Java 8 LongAdders: The Right Way To Manage Concurrent Counters

I just lOvE new toys, and Java 8 has a bunch of them. This time around I want to talk about one of my favourites – concurrent adders. This is a new set of classes for managing counters written and read by multiple threads. The new API promises significant performance gains, while still keeping things simple and straightforward.

As people have been managing concurrent counters since the dawn of multi-core architectures, let’s take a look and see what are some of the options Java offered up until now, and how they perform compared to this new API.

Dirty counters – this approach means you’re writing / reading from a regular object or static field across multiple threads. Unfortunately, this doesn’t work for two reasons. The first is that in Java, an A += B operation isn’t Atomic. If you open up the output bytecode, you’ll see at least four instructions – one for loading the field value from the heap into the thread stack, a second for loading the delta, a third to add them and the fourth to set the result into the field.

If more than one thread is doing this at the same time for the same memory location, you run a high chance of missing out on a write operation, as one thread can override the value of another (AKA “read-modify-write”). There’s also another nasty angle to this which has to do with the volatility of the value. More on that below.

Continue Reading…

15 Must Read Java 8 Tutorials

By Tal Weiss —  April 9, 2014 — 4 Comments

Blog Green Board 15 Must Read Java 8 Tutorials

 

Java 8 was released last month and is just chock-full of new features and behind-the-scenes optimizations. The internet has been doing quite a good job covering all these new additions – both the good and the bad. I thought it’d be good to do a round-up of what we think are some of the best tutorials out there, to help you get you quickly up-to-speed on what’s new and what you need to know.

Java 8 New Features List

Let’s start with the basics – the official OpenJDK list of new features in the Java 8 core library, JVM and the JDK. This is a must read.

The OpenJDK 8 new features list

Lambda Expressions

Hailed as the biggest change to the language in the last decade, Java 8’s Lambda expressions finally deliver core elements of functional programming that have been made popular with languages such as Scala and Clojure right to your doorstep.

This is really one of those cases where I suggest going with the official documentation and tutorials first –

The official Java Lambda expressions tutorial

An extensive Lambda expressions tutorial with examples

Continue Reading…

Blog socks03 New Parallelism APIs in Java 8: Behind The Glitz and Glamour

I’m a great multi-tasker. Even as I’m writing this post, I can still find room to feel awkward about a remark I made yesterday at a party that had everyone looking at me strange. Well, the good news is I’m not alone – Java 8 is also pretty good at multi-tasking. Let’s see how.

One of the key new features introduced in Java 8 is parallel array operations. This includes things like the ability to sort, filter and group items using Lambda expressions that automatically leverage multi-core architectures. The promise here is to get an immediate performance boost with minimal effort from our end as Java developers. Pretty cool.

So the question becomes – how fast is this thing, and when should I use it? Well, the quick answer is sadly – it depends. Wanna know on what? read on.

Continue Reading…

blog lambada 2 The Dark Side Of Lambda Expressions in Java 8

This post may not make me any new friends. Oh well, I was never really popular at school anyway. But let’s get to the point. Java 8’s biggest feature in terms of the language is undoubtedly Lambda expressions. It’s been a flagship feature for functional languages such as Scala and Clojure for a few years, and now Java has finally joined in.

The second biggest feature (depending of course on who you ask) is Nashorn – the new JVM JavaScript engine that’s supposed to bring Java up to par with other JS engines such as V8 and its node.js container.

But these new features have a dark side to them.

I’ll explain. The Java platform is built out of two main components. The JRE, which JIT compiles and executes bytecode, and the JDK which contains dev tools and the javac source compiler. These two components are fairly (but not fully) decoupled, which is what enables folks to write their own JVM languages, with Scala rising to prominence in the last few years. And therein lies some of the problem.

Continue Reading…

Duke 8 copy 5 Features In Java 8 That WILL Change How You Code

Java 8 is packed full of some really exciting features at both the JVM and language level. While some of the features initially envisioned for this release got scoped out or pushed out to release 9, there are literally dozens of new features. Many of the new additions are under-the-hood improvements either at the compiler, JVM or help-system level. As such, while we may benefit from them, there’s nothing we need to actively do (other than install Java 8 of course) to enjoy them.

Having said that, let’s look at 5 features that we feel are an absolute must for you to know about:

1. Lambda expressions

Even if we really didn’t want to go mainstream here, there’s little doubt that from a developer’s perspective, the most dominant feature of Java 8 is the new support for Lambda expressions. This addition to the language brings Java to the forefront of functional programming, right there with other functional JVM-based languages such as Scala and Clojure.

We’ve previously looked into how Java implemented Lambda expressions, and how it compared to the approach taken by Scala. From Java’s perspective this is by far one of the biggest additions to the language in the past decade.

Continue Reading…