Maximum Zeal ~ Emphatic prose on indulged fascinations

Comparison of Linux compression commands

Recently I had to back up a virtual machine server I had in the US before decommissioning it. As I had a lot of large folders I realised that compressing them would take some time. Being the lazy administrator that I am I took some time out to find the fastest compression command on Linux before I began my backup process.

Here is what I found for a 117Mb folder.

bzip2

dhruba : /backup # time tar -cjf root.home.tbz /root/
real    0m34.600s
user    0m34.040s
sys     0m0.357s

gzip

dhruba : /backup # time tar -czf root.home.tgz /root/
real    0m6.255s
user    0m5.672s
sys     0m0.415s

lzop

dhruba : /backup # time tar --use-compress-program=lzop -cf root.home.tlzo /root/
real    0m2.624s
user    0m2.061s
sys     0m0.383s

The file sizes for the three commands were as follows.

dhruba : /backup # ls -lShr
-rw-r--r-- 1 root root 81M Dec 14 20:46 root.home.tbz
-rw-r--r-- 1 root root 83M Dec 14 20:43 root.home.tgz
-rw-r--r-- 1 root root 88M Dec 14 20:43 root.home.tlzo

As you can see lzop has by the fastest compression size but the largest compressed file size. If, like me, this is the trade-off you are looking for then lzop is your answer.

How to print assembly for your Java code in OS X

0. Write program. 1. Add JVM arguments to your program. -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly 2. Run your program. You will probably see the output below. Java HotSpot(TM) 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output Could not load hsdis-amd64.dylib; library not loadable; PrintAssembly is disabled Hello World! Process finished with exitContinue Reading

Upcoming Coursera course: Principles of Reactive Programming

Just a quick note to say that a new Coursera course begins on 4th Nov 2013 that looks very interesting indeed titled ‘Principles of Reactive Programming‘ taught by Martin Odersky, Erik Meijer and Roland Kuhn. It is intended as a follow on course from its precursor course ‘Functional Programming Principles in Scala‘ also taught byContinue Reading

Scala Cookbook: Tail recursive factorial

The direct port of a human readable description of the factorial algorithm may look as follows. However – this isn’t tail recursive and will fail for large inputs. Exception in thread “main” java.lang.StackOverflowError at java.math.BigInteger.getInt(BigInteger.java:3014) The classic nested accumulator helper function idiom can be used to make this tail recursive. So what’s going on here?Continue Reading

Scala Cookbook: Pattern matching on BigInt

Let’s take the factorial algorithm as an example. One might expect to convert this into a pattern matched equivalent as follows. In fact this will give you the error below. type mismatch; found : Int(0) required: BigInt Factorial.scala The reason is that BigInt is not a case class and does not have an unapply() methodContinue Reading