Taming Vortex

Progress monitors services are very useful in Eclipse. You use them to display progress of some long running operations to users. As I said very good. But like every other useful thing it can change to beast. This happened in Vortex too. Imagine that you want to report progress of project download to user.
 Easy no brain code:

void doDownload(IProgressMonitor monitor)
{
  monitor.beginTask("Downloading project...");
  try {
    // do the actual download here...
  }
  finally {
    monitor.done();
  }
}

Easy, nope? Now imagine that you call this function inside monitor.

public void doDownload(IProgressMonitor monitor)
{
  synchornized(lock) {
    doDownload(monitor);
  }
}

Ok, now you want to ask me what's wrong? The deal is that I'm using some other thread to do the actual download processing. This other thread executes some events to the listeners, and some of those listeners are running in UI thread updating some controls. So they use Display.asyncExec(...) function to run code in UI thread. Ok, so where is the problem? The problem is that some Eclipse progress displaying services are acquiring some other locks, and are executing some code with other locks they shouldn't. I explain this later.

The actual lock progress service use is RunnableLock. In comments of this class is that this is used that async and sync runnables do not interfere. They wait in asyncExec (in class Synchronizer) like this:

void asyncExec(Runnable runnable) {
  // Some code ...
  RunnableLock lock = new RunnableLock(runnable);
  synchronized(lock) {
    addToQueue(lock);
    while(lock.finished() == false)
     lock.wait();
}

And they are running the queue:

boolean runAsyncMessages(boolean all) {
  synchronized(lock) {
    lock.runnable.run();
    lock.setFinished(true);
  }
}

So let's summarize it. The background thread acquires our lock, then progress monitor beast acquires runnable lock, and waits. The UI thread acquires RunnableLock at first, and then it happens. There are apparently some UI event loop executed by these listeners which runs our event listeners that want to acquire our background thread lock.  And the deadlock is here. This deadlock happened twice today, and it's hard to reproduce, so I cannot give you any stack trace... [-;

The bug on eclipse for has been filled here. So please feel free to add some comments.

Morale of this story? Be carefull. [-; When dealing with threads, there are not only your locks.

Solution - I use my own version of AccumulatingProgressMonitor in all entries which are called by some progress services. In this class I just have replaced all syncExec()s with asyncExec()s.



As you might know, Java from version 1.4 does contain standard logging facilities for logging errors, debug messages, warnings, etc. Those classes reside in java.util.logging package, and are quite nice since you just use standard Java mechanism to log events, and you don't need any external library to do it. Lot of existing libraries are using these classes as well. So I have made a small addin for Tornado which transfers all java logging events to Tornado logs. Feel free to have a look at it, and send me some comments.

The packaged addin is here .

To run this addin copy the jar file to addins folder under your Tornado installation directory, and add "puakma.addin.log.LogAddin" to AddIns in puakma.config file, and reload server. I have done also testing addin: puakma.addin.log.TestLogAddin which is periodically sending some java logging events, so you might have a look how to use it.

Future - I want to make it better [-; I want to add some better configuration handling, and better formating since this is just hard coded stuff. Also maybe I will add support for Apache log4j library. But this is just the beginning.

I also have some links about java logging you might have a look at:



2006-12-17

I was doing some performance optimizations for soapdesigner, and I have found few things. The main message is that whenever possible, run Tornado on included hsqldb database. Really, don't use as system database anything external like mysql. Of course, the exception is when you run Tornado in cluster. In such case you need to run system database on external RDBMS. Anyway, I was measuring performance, and for me HSQLDB runs much faster. I did a simple test for measuring how fast does Vortex code get the snapshot of application's structure from the Tornado system database. So for mysql on my machine it was around 1200 ms, and on embeded hsqldb it was around 200 ms. Pretty big difference, what do you thing?

So you might tell me that my measurement is biased. Maybe true. A little bit. HSQLDB doesn't contain much applications, and my Mysql system database contains a lot. This might slow down hsqldb on the same data, but I think that what makes the difference is that Mysql connects to the external data source via TCP/IP network connection, and doesn't transfer data in memory like HSQLDB does. Also it might be different on other OS/configuration. My system is Apple Powerbook, CPU PowerPC G4 1.5, 2GB RAM, MacOSX 10.4.8, Apple JDK 1.5.

I was also trying to optimize soapdesigner application structure load time, but unsuccessfully. So what is the conclusion from my measuring here? Using DOM for generating xml doesn't affect performance that much in comparison to using just StringBuffer to generate xml. Maybe on bigger data I might be wrong, or even on higher load I might be wrong, but this is what I have seen. But apparently there is smaller memory usage since I don't create objects for every new xml node. Also executing more SQL selects when trying to save some time transferring less data is not always helping. It's the same to make one select for the whole application with the design object's source and data than to select application, and than to select only design object data, and source to get class and package name. Maybe for bigger databases I would see some difference, but not here. Sorry 1MB application is not apparently enough, and I doubt that anybody would make that much bigger application.

So that was the tip from today. Now it is the time for traditional Spanish christmas dinner which shows us our Erasmus coordinator Gustavo Taberner. And we will continue with fiesta somewhere in the center of Madrid. I will tell you what is traditional Spanish Christmas dinner later (Even I don't know what is tradition here). [-;



2006-11-27

Ok, this new feature is quick one [-; There is now ability to rename action. This was originally designed to be in the properties page in the editor of java source files (like for html or resource objects). But during the time it was quite obvious that this is not the way. Just editing java files in eclipse editor feels much better. Anyway there is some screenshot for those of you who want to see something [-;

RenameActionMenu.png 

Rename action menu 

RenameActionDlg.png

Rename action dialog


One of the things where Vortex had to catch up webdesigner is modification of the schedule scheduled actions. This is just fairly simple dialog, but I want to start the mini series about Vortex 1.1 with this one.

At first how to get to the dialog. This nicely illustrates the next image:

How to open scheduled action dialog

Next are some samples how the editing looks like. 

 SchedActYear.png

editing schedule which is supposed to be executed every year on the 1. of july at 0:00

Editing schedule which executes every 20 minutes every day in the week from 4:00 to 6:00

editing schedule which executes every 20 minutes every day in the week from 4:00 to 6:00 



Release of the version 1.1 of Vortex is closer and close every day. So now it's the time to introduce what cool new things you can expect from it. Today I will cover the overall changes, and in the next few days I will talk about each of the changes in detail.

What is the main message of the version 1.1? Webdesigner application is obsolete. [-; Well, not quite right, for small, last time fixes it's still great tool. But in version 1.1 there is nothing you could do in webdesigner, and not in Vortex. What was added from missing webddesigner features are:

  • database schema designer
  • sql query editor
  • scheduled action scheduling
  • action renaming

We have also added lot of things to make developer's life easier, and more productive. The major improvements are namely these:

  • javadoc context help for puakma.jar
  • blackbook integration in help system
  • new version of Eclipse IDE 3.2, which is itself huge step forward at least on Mac
  • improved html editor, new css, and javascript editors
  • enhanced uploader
  • new Tornado server command console view
  • and of course many speed improvements, consistency, and bug fixes



Last week I have found somewhere on the forums trick how to instantly grab a part of the screen on Mac OS X. It left in my memory, and I had no idea at that time how handy would this be. Just press Cmd-Shift-4, and  there appears a new cursor which allows you to select part of your screen, and saves that screenshot to png file on your desktop.

The second trick allows you to magnify part of the screen under your cursor. It is a new feature of 10.4.8. This was also very handy during the development of the new Vortex database editor. Just press ctrl, and scroll you mouse wheel. Screen smoothly zooms in and out.



2006-10-05

Yes, it's here. I finally moved to Madrid. Sorry for not letting know so long, but I was too busy with everything here, specially looking for flat, and I finally have some time to write at least some notice here.

Anyway, I should explain what I'm gonna to do here. I'm here to spend a year here studying at Universidad Politécnica de Madrid at Facultad de informática. I will stay here as student of European-wide university exchange program Erasmus with about other 40 foreign students at the faculty. Madrid seems to be nice place to spend year, and I'm really looking forward to see the life in Spain closer. I also would like to learn Spanish better, and make some new contacts among the people I meet here.

I also plan to make some site only about my stay here, and I have some more content to put on this site too, so stay tuned.



Today I finally added Vortex to the eclipseplugincentral.com site. Bit shame on me, because eclipseplugincentral.com is Eclipse's official site to post pugins on, and might have been done much sooner. Anyway you can find there almost all plugins ever done for Eclipse. We really hope that this brings us little bit more attention, and spreads out Puakma technology all around the world [-;

You can find site about Vortex at the address http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-675.html. So check it out, and please, vote for it.



Vortex 1.1 is also about polishing things, and make them working better. One of the features we wanted to improve the most is the pages editor. The one in 1.0 was pretty much xml editor with some tweaks to be able to handle Tornado tags. But this doesn't work in real world. For the real world you need a little bit more. So thus we adopted Eclipse Web Tools Platform project's HTML editor, and now I'm just beginning to customize to support specific Tornado templates in content assistance (when you press ctrl+space). There is a screenshot of the new editor. Don't be fooled that it fully works right at the moment. We are on the beginning of the way, and as I know Eclipse it knows to be very hard to customize, and it seems  to have almost no documentation, so cross fingers!


So what will this new editor know? It will know how to syntax highlight Tornado tags, HTML, but also JavaScript code and CSS inside your pages. Another new thing is hooking outline, so you will see structure of the file. You can see the outline on the left side on the top. Also new will be snippets which will contain some very useful pieces of code. Also there will be available editor of properties of every tag. Content assistance for Tornado tags, HTML, JavaScript, and CSS.



About me...
Hello, I'm Martin Novák, and I talk here about Puakma Technology, Java, Eclipse, and Mac OS X.

I work on Puakma Vortex at webWise Network Consultants Pty Ltd based in Sydney in Australia, but I live now in Madrid in Spain.

Contact: Martin Novák

I'm talking about

Recommended reads

Calendar
01020304050607
08091011121314
15161718192021
22232425262728

(c) 2006, Martin Novák, contact me at my email