Archive for April, 2008

Downtime due to WordPress 2.5 high CPU usage

Wednesday, April 30th, 2008

Sorry for the downtime guys. I have reached my CPU usage limit due to turning on automatic database backup feature in WordPress (or something else – not quite sure).

Lets hope from now on everything will be ok.

Update:

With my blog suspended for second time I got really pissed and investigated the reasons. My previous believes about buggy pluggins was not correct and with little googling I found out that WordPress 2.5.x has some serious problem with CPU usage. As I examined my load logs it is obvious that the PHP process is using more than 5 times as previous versions.

The solution is either to install WP Super Cache or to downgrade to the previous version before 2.5.

Howto Create Lossless Flash Screen Captures (Screencasts) for Free

Sunday, April 20th, 2008

Two weeks ago I started my search for free solution that can do cross-browser and cross-platform screen captures. After couple of days I understood that creating screencasts without using Camtasia is hard because I needed something that can do the following:

  1. Produce Flash Video (FLV) which is good for streaming
  2. Use a lossless codec for great quality
  3. Works under Windows XP
  4. Gives good quality/size ratio

The solution is Camstudio + Camstudio Lossless Codec + miniRec + FFmpeg

Camstudio is free open source screen capture software (in relatively mature state) with great set of features described on the official website ,blog and forum

Camstudio Lossless Codec is not really necessary because exporting in uncompressed video works too but requires alot more space. I tried other lossless video formats like MSU Screen Capture Lossless Codec but since I’m converting it in Flash Screen Video it doesn’t make much difference.

miniRec Audio Recorder is nice and very simple application for recording your voice while capturing the video stream. While Camstudio has build-in audio recording support I had too much troubles with it (the encoded FLVs had some strange bugs) so I’m just recording it separately.

FFMpeg – as usual the cherry of the pie now with support for the Flash Screen Video format (flashsv). With its help it is easy to produce high quality lossless FLVs with relatively small size.

How it all works out:

  1. Install Camstudio 2.5 Beta 1 – there are many tutorials on youtube about it and I’ll skip this step. Also you can check the official install screencast – http://camstudio.org/video/install/ which is for abit older version
  2. Install Camstudio Lossless Codec – it is quite easy, just download the archive, extract it somewhere, right click on the inf file and chose install
  3. Run Camstudio and click on Options –> Video Options. For me the best settings for getting as small as possible files are like this:
    Camstudio Settings

    (If you have any better suggestions please share with me)

  4. Download and install miniRec from here. I have not used any special settings since the voice is compressed by FFmpeg while merging the video and audio streams. My suggestion is to set a global shortcut key for both miniRec and Camstudio so it is possible to fire them almost simultaniously.
  5. Record all you want 🙂
  6. Get FFmpeg. There are versions both for linux and windows. I’m currently using SVN-r12810 but anything relativly recent should do the trick.
  7. The magic for converting your avi to flv is:
    ffmpeg -i input.avi -vcodec flashsv output.flv
    if you are joining with the audio use:
    ffmpeg -i input.avi -i input.wav -ar 22050 -vcodec flashsv output.flv
  8. And the result will be like this:
You do not have flash installed.

PS. The song that is used in the screencast is under Creative Commons and can be found here

Howto Optimize Rendering Speed of ASP.NET Ajax Websites

Monday, April 14th, 2008

A common case for most ASP.NET sites is slow frontend rendering due to many Javascripts. The typical requests graph looks like this:

ASP.NET Rendering Graph

All these AXD files are embedded Web Resources usually Javascripts and sometimes CSSs. The bad news about having many embedded Javascripts are:

  1. Many HTTP Requests (meaning generating more load to the web server)
  2. Poor rendering time because when the browser starts downloading a Javascript file it stops downloading(rendering) everything else (easily seen on the graph)
  3. Less chance for caching any of those files
  4. If HTTP compression is enabled in the IIS many files mean more load and worse compression ratio than one merged file.

The most common scenario for having many embedded Javascripts is either using AJAX or some commercial .NET controls.

The solution for merging AJAX AXDs in a single file is described in those two great posts:

Script combining made easy [Overview of the AJAX Control Toolkit’s ToolkitScriptManager]

and

Script combining made better [Overview of improvements to the AJAX Control Toolkit’s ToolkitScriptManager]

The recapitulation when with a friend of mine (Julian) tested out this technique was reducing the loading time with about 2 seconds on a quite clean and well build site. Also the better HTTP compression reduced the size a bit.

If you are using ComponentArt’s Web.UI version 2007.2 or later controls there is solution posted on their blogs too:

Optimizing Web.UI Client Script Deployment

And couple more general advices:

  1. If it depends on you merge all your Javascript and CSS files
  2. Load CSS at most top of you page
  3. Load Javascripts at most bottom of your page (if possible)
  4. Minify both Javascripts and CSSs
  5. Be smart 🙂

Update: Stefan Dobrev sent me a link for moving the AJAX Javascripts to the bottom (point 3 of the list above) which should improve rendering time too. Thanks Stefan

Howto Convert Vmware Windows XP IDE Disk to LSILogic SCSI

Sunday, April 13th, 2008

I quite often use my Windows XP VM running under Vmware Server 1.0.5 (Debian Unstable) and because I still don’t have RAID I am forced to try every possible performance optimizations.

Latest and greatest was when successfully converting my 10 GB preallocated IDE disk to LSILogic SCSI following procedure close to this one. (Try it on your risk !)

1.Create LSI Logic disk:

vmware-vdiskmanager -c -s 100mb -a lsilogic -t 0 tempDisk.vmdk

2. Add SCSI definitions in your VMX file:

scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
scsi0:0.present = "TRUE"
scsi0:0.fileName = "tempDisk.vmdk"

2. Boot the VM and install LSI Logic driver – use WHQL 1.20.18.00 (at least I could not install the latest version)

3. Make backup of the VM Disk !

4. Open the disk definition file (.vmdk). Get from there the disk size (sum of all extents)

# Extent description
RW 20971520 FLAT "WXP-flat.vmdk" 0

Then create another disk

vmware-vdiskmanager.exe -c -s 20971520 -a lsilogic -t 1 anotherTemp.vmdk

This one is only needed so you can get the new geometry and replace it in the original .vmdk

5. Replace old geometry with new from anotherTemp.vmdk. In my case I replaced this

ddb.adapterType = "ide"
ddb.geometry.sectors = "63"
ddb.geometry.heads = "16"
ddb.geometry.cylinders = "16383"

with this

ddb.geometry.cylinders = "1305"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"
ddb.adapterType = "lsilogic"

6. Update you VMX file so scsi0:0 points to the main disk image.  Also you can remove the old IDE definitions.

7. Boot your VM and have fun.

Couple of other performance suggestions:

1. Always defrag your guest operating system disk.

2. Use MemTrimRate = "0"

3. Use scsi0:0.mode = "independent-persistent"

4. Keep your guest operating system as light as possible. Turn off themes, effects, unneeded services etc.

Resources used:

http://sanbarrow.com/ide2scsi.html

http://communities.vmware.com/thread/50084