Bits and Bytes

Categories

Archives

I just came across this set of slides on source code optimisation and I have to agree with the lesson to take away – that is to understand how your compiler works. I do this very often as I have to work with really low-level code at the microprocessor level. So, I need to understand how the compiler works in order to generate the correct sequence of codes.

I thought that I should share this piece of gem here.

The key thing to remember is that the compiler will always generate code depending on what it thinks you are trying to do. While early optimisation is the root of all evil, coders need to help the compiler along by writing code in such a way as to make it easy for the compiler to figure out what it is that we want it to do. If we left everything to be decided by the compiler, we would ultimately end up with code that works, but not optimally.

This is a particularly big problem in the embedded world.

The only way to learn how the compiler works is to decompile and disassemble code – not by reading the above slides only. I primarily work with GCC compilers and I always compile it with the -g flag turned on to generate debugging symbols. This makes it much easier for objdump -dSC to give me human read-able assembly output. Do this for different code paths and we will soon begin to understand how the compiler interprets our code.

Then, the only issue that matters is the purpose for optimisation – size, speed or power.

I thought that I should plug this WordPress plug-in. It is a PostgreSQL compatibility layer for WordPress. I have to say that it seems to work as advertised thus far – this blog runs on it.

I have been trying to find a useful compatibility layer for moving various web applications over to PostgreSQL for quite some time now. I experimented with SQLRelay and it seemed to work fine stand-alone but I had a lot of trouble trying to get it to work with FastCGI on Lighttpd. Setting the appropriate environment variables seemed to do nothing for it.

The reason for this switch is numerous, mainly due to standards compliance and stability. However, the recent takeover of Sun by Oracle did it for me. I do not see how MySQL is going to survive the exercise unscathed. I just hope that the compatibility layer works well enough to sustain this blog for a long time.

I have recently been approached by several people with regards to the licensing of open source software (OSS). Proprietary companies have no problems stealing open source software for their use but when it comes their turn to sell their solutions, they try to get away with hiding the OSS. This is not only wrong but is actually illegal.

I have been personally told to breach the GPL and I have pretty much told my boss – over my dead body. Just because it is an instruction from the top does not absolve me of the action. I will still be the one responsible for installing DRM onto our GPL derived product.

I have come to realise that most people have many misconceptions on OSS because they tend to lump all OSS together in one homogeneous fold. Unfortunately, there are over 60 different OSI approved open source licenses at the time of writing and they are as heterogeneous as can be. However, they all have exactly one thing in common and one thing only.

I need to make this one thing very clear – OSS licenses are all distribution licenses – they only come into effect when you decide to give away your product whether paid or otherwise.

On one extreme, you have the extremely permissive OSS licenses such as BSD and gang. What this license essentially means is that you are pretty much free to do whatever you want with it, including using it in commercial products without giving away your source code. However, you will need to mention in your product and documentation that you are using the BSD code and that the original authors are exempt from all liabilities.

This is one of the easiest OSS licenses to use in proprietary products. Just take the code, do what you need with it and then sell it. All you need to do is to mention that you have used that code and promise that you will never sue the original authors. That’s it!

On the other extreme, you have the extremely viral OSS licenses such as GPL and gang. This is the license that Steve Balmer calls a cancer because it is infectious. It is very clear in the language that any software that contains GPL code must be at least as free as the GPL and no distribution rights can be taken away from the customers.

This essentially means that if you use GPL code in your product, you cannot do anything that will prevent your customers from using that code in whatever way that they like. GPL3 has very specific language that nullifies patents and attacks digital rights management. In fact, you cannot even stop your customer from reselling your product ad verbatim if they want to.

One misconception that most people in Malaysia have is that OSS is a development license – meaning that if they do not make changes to the original code or develop it, there is no need to open source it. This is only true for LGPL and gang, which require all changes, modifications and additions to the original code to be given away as LGPL. However, it is untrue for either of the previous extremes.

The trouble with most proprietary businesses in Malaysia is that they do not comprehend OSS. OSS licences do not prohibit you from charging money for your products. In fact, you are encouraged to charge money for it so that you have clear proof of distribution, which means that the OSS license can be clearly enforced. You will find open source companies worth billions of dollars amongst the Fortune 500.

Professionally, I always recommend that my clients stay away from GPL code unless they know exactly what they want to do with their products. There is nothing wrong with GPL except that staying away from it gives us flexibility to decide on whether or not to distribute our source code later – once there is a clear business case for it either way.

I was recently told by a colleague that he was informed by legal that we should give away our GPL derived code but practically, we would not need to. That is the kind of legal-doublespeak that makes me hate lawyers.

I have recently been experimenting with Xen after spending a year with OpenVZ. I decided to try out XenServer instead of community Xen because of the commercial support available. XenServer is available for free but with certain limitations controlled by license.

However, I stumbled into problems activating the XenServer license. Turns out that if you wish to activate it, you can use the self-service page that they provided. Unfortunately, that page requires a certain file that can only be obtained by using XenCenter, which only runs on Windows.

It took a few days of looking for information on how to generate that file without XenCenter to no avail till I finally contacted Citrix on their forum and was asked to contact them directly. They told me that they will generate the license for me manually and they will put in a request to make available a non-XenCenter way of gathering the information required to generate the license.

I thought that it was pretty dumb for a virtualisation company to force its users to use Windows. However, since they were nice to me, I would give their product a chance. So, after waiting for a week, I finally received my license in the mail.

The license that they gave me is valid for a year and this buys me time because I think that I will move over to community Xen at some point. I do not wish to go through this hassle of generating manual licenses each year. This brings to mind the whole concept of licensing Open Source Software, which I shall write about later today.

Debian stable comes with Xen 3.2 at the moment while unstable has Xen 3.4, which has many more advanced features while XenServer comes with Xen 3.3. The next version of Debian is due to be released some time this year or early next year. So, I think that once Squeeze stabilises, I will migrate over to community Xen instead.

I think that controlling software distribution through licensing is dumb.