Evolving concurrency, like memory management did

As processors become faster and multiprocessor systems become cheaper, the need to take advantage of multithreading in order to achieve full hardware resource utilization only increases the importance of being able to incorporate concurrency in a wide variety of application categories.

In this article we are evaluting a new approach to the concurrency.
In the last five years computers are becoming even more parallel.
Intel is pushing multi-core achiteture also on commodity personal computers.
Neverless the computing power is ofter not well used: one again, hardware is a step head of our day-by-day software development.
Remember when the 80286 came into light.
The 286 was able to provide a multi-programming architecture but without memory management protection.
We had to wait 386 hardware to see software working on preemptive multi-tasking, because software cannot cope with unprotected memory. In one word, it costs too much to develop a operating system without the new features the 80386 bring to us.
What about concurrent programming? Can we look similarities in the  concurrency field?

Continue reading “Evolving concurrency, like memory management did”

Java HttpClient and Load Balancer bad interactions

Working for a very big customer, I found a very nasty interaction between Sun HttpClient (JDK 1.4) and Http  Load Balancers.

In a complex network environment, sometimes you can experience low level TCP/IP comunication errors, because sometimes HttpClient get confused and hangs.

The bad behavior of Sun HttpClient is well known: some guys suggested me to use the Axis Web Client. Anyway you can solve the issue adding these three parameters to the JVM launch line

-Dsun.net.client.defaultConnectTimeout=5000
-Dsun.net.client.defaultReadTimeout=5000
-Dhttp.keepAlive=false

The first two parameters set globally the socket timeout to 5 seconds.
The last parameter forces the JVM to avoid reusing http connections when doing http request.

To be honest, http.keepAlive=false is not always effective and could have huge performance impacts, so be very carful adopting it.

But if you stick on the two sun.net.client.default*  properties (doing some tests) you can solve the issue.

References

From Java Plug-in Control Panel:

[…]
Networking properties description:

sun.net.client.defaultConnectTimeout

sun.net.client.defaultReadTimeout

These properties specify, respectively, the default connect and read timeout values for the protocol handlers used by java.net.URLConnection. The default values set by the protocol handlers is -1, which means there is no timeout set.

sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example, for http connections it is the timeout when establishing the connection to the http server. For ftp connections it is the timeout when establishing the connection to ftp servers.

sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from an input stream when a connection is established to a resource.

For the official description of these properties, see Networking Properties.

[…]

April 0.2 Application Performance Framework

April (Application Performance Framework) is a super-light application framework based on Spring, featuring:

  • An Aspect Oriennted Programing Performance Monitor, which try to increase performance on the fly
  • A super-light XML-RPC communication framework

April first commitment is “be lite, be pluggable” and do not re-invent the wheel.
I am happy to describe here how it works the Beta 0.2, called “Fat Cat” by friends.

Getting Started with April

April is a self-contained package, you can download here:

[download id=”3″]

April project has been developed under Eclipse Ganymede, which is higly recommended. Anyway an ant build script is provided.

The project binary results in a webapp (war) you can deploy under your preferred application server.

How it works

The april demo is composed of a FileMonitor utility used to monitor file changes across a file system.

The core of April is the PerformanceMonitor, which is an aspect configured via Spring: take a look to the aopMonitor.xml located under april/war/WEB-INF/spring/ folder.

The performance monitor will start measuring the performance of every methods defined in the pointcut. When one method is too slow, the Performance Monitor will check if the method belongs to a class implementing the “AutoTune” interface.

If the AutoTune interface is implemented, the PerformanceMonitor will ask to the object if it can be opttimized via a call to

public boolean canBeOptimized();

If the method returns true, Performance Monitor will begin the optimization phase.

The optimization phase

The Performance monitor will invoke the following method of the AutoTune interface

public Runnable split() throws Exception

Is up to the implementation to return a new runnable object, which will do a part of the work.
The returned object need not to be of the same type of the AutoTune implementor  (ATI).

The idea behind

The idea is to find bottleneck based on how much time a method takes to run. The monitor then asks to a slow instance to spawn another thread.

This approach cannot solve every issue, but it seems effective on some scenarios, because it can “follow”  the bottlenecks when they change position.

The call is performed before the return statement of the “slow” method, and a global lock is used to guarantee only one spawn request at the time.

The post-optimization phase (speculation)

This phase is fired via the AutoTune method

public void mergeWith(AutoTune candidate2);

but it is still unfinished and unstable, so it is disabled for the meantime.
I am evaluting different approaches, and every comment is welcome.

Do you like April? Do you have an idea for improving it? Leave a comment below!

Release History

  • April 0.2 is the first full english release.
  • April 0.1 was a “request for comments” release, published in this italian article. It was released on April 8th , 2009

Asus EEE-PC better then Mac Air?

Finally I managed to buy a Asus EEE PC 700  this week. I would thanks a lot Next Store and its kindly clerks, which I will prefer in future to Mediaword :)
If you are at Milan and you plan to buy it, Next Store is a good choice.

There are a lot of sites and articles around the net about the EEE-PC, because it is a very new article in the IT consumer world.

The EEE PC is the First  full featured PC sold at 300 euros. The Register tries also to compare it with the Mac Air, and we'll see why this is not a so crazy idea.
In these days in Italy was launched an overpriced version (320 euros) with Windows XP preinstalled. We are waiting also the more powerful version (EEEPC 900) at 400 euros. Anyway, what do the product is the 300 euro price: powerful and richer model at an higher price are no so stunning as the EEE PC 700.

Introduction: the hardware

The Asus EEE PC come with 3-usb 2.0 ports, and one SD Card reader. It is expandable a lot, considering it has the same usb ports of my Lenovo Thinkpad R60.  It has no DVD reader, but it is very small and tight. The  battery charger is similar to that of a GSM phone, and it sounds great because of its reduced weight.
The screen is tiny, but very very bright, so it can work if you are not too much greedy as me.

Even if the keyboard is too small, and the fan is noisy, for the rest EEEPC looks well.
With an external monitor&keyboard attached,  your trouble are reduced, at least at home.
You can compare it to a Mac Mini, sold at 600 euros, which has a similar but powerful hardware: so having half the ram for the EEEPC is not a surprise.
But the EEEPC 701 is easy to expand, and on Internet some guys managed to install 2Gb of RAM.
And it is not shipped by deafult with windows but with a linux operating system… another big news, isn't it?

 

Games
I code every day. So in my spare time, at home, I have two priorities: my girlfriends, and games.
And EEE-PC come with some funny games like Frozen Bubble, so it is definitively a very good machine.

 Vodafone & EEE-PC

In Italy, Telecom Italia sells a branded version of EEE-PC, with its USB connect key. If you have a Vodafone Connect Key, I have found an italian article to try to connect it. I will do some tests, and then translate it in English if it is worth of it.

The Software…

The operating system is a commercial version of Linux. Anyway it is well packaged, and it is reasonable fast. The File Manager does not start in a snap, but it could be worst.

…the ideas

Because ObjectsRoot.com is  heavly focused on software development, I am searching a set of article to how build a small cluster of EEE-PC, for doing small distributed computing. The cluster should be easy to set up, with no installation of new operating system, and should have decent performance.
I will report  my experiments in the next month.

Hacking it [Update on 11 june 2008]

Ubuntu has relased a specilized version of ubuntu linux

Conclusion: Why it is great

All these stuff fit in about 300 euros, and there is no decent PDA  at this price…even a good Nokia GSM phone is difficult to find for a such price. The EEE-PC weights less then 1 Kg, and it is very easy to carry on. The webcam is good if you have sufficient light to give it, and you can record at 44.1 khz your voice.
Skype comes preinstalled, giving you a lot of freedom with its VoiceOverIP technology.