2015-02-27

Just want to share some table from initial chapter of my thesis (early 2012), it's about modification (added lots of compression) of HAT-Trie for DNS suffix blocking. These tables are from chapter IV, since it's the only exciting part about it .__.)/||. That time I didn't know about Cedar yet (of course it's 2013 XD). This is the list of benchmarked data structure:

The data structure name that marked with "*" sign are those who can be set as nested per subdomain (that is should be a map/associative array). The strings tested are C++'s std::string, Qt's QString, csubdom (compressed subdomain), strcsubdom (compressed subdomain, stored in std::string), clabels (compressed full domain), strclables (compressed full domain name). Compressed in this term are packed characters (from 8-bit to 5/6-bit so it would use less memory). This benchmark performed on Ubuntu 64-bit Linux 3.2, GCC 4.6.3, AMD Phenom X9850, 8GB RAM and non-SSD disk, compile flag: g++ -c -m64 -pipe -O2 -Wall -W.

Notes about that table header "insert" is a benchmark about inserting 2.1 million blacklisted domain names, after it's completed, the data structure erased and the insert operation repeated until 30 seconds passes. The "misses" benchmark about checking if 68.4k domains that doesn't exists on the blacklist, the operation repeated until 2 seconds passes. The "exists" benchmark is about rechecking blacklisted domain names in sorted order, repeated until 8 seconds passes. The "random" benchmark is about checking random blacklisted items, repeated until 20 seconds passes. The value there are number of milliseconds required per domain name. Last column on the table is average bytes required to store one domain name.

2015-02-26

Docker is operating system-level virtualization, software container that enables sysadmin or software developer to deploy an isolated distributed Linux application almost anywhere without any hypervisor (but both can be combined). Docker is more resource friendly (efficient) than any hardware virtualization solutions, faster startup-shutdown time, and lower hardware requirement (it works as long as you have Linux kernel that support LXC). Docker can run on Mac OS X and Windows via boot2docker (or with Vagrant or any virtualization software). To install it on ArchLinux, type:

The docker service will create a network bridge interface (mostly docker0). You can use your own base image or download pre-built one. Make sure you have a lot disk space on your /var/lib/docker directory since docker store the images there. To create an ArchLinux base image, use any of these repositories, for example:

As I've written before, CombSort are quite good sort algorithm. Let's compare this algorithm when implemented in various programming language. The benchmark should not use any other built-in function other than array generation and printing. The benchmark uses AMD A8-6600K, 16GB RAM with Non-SSD disk.

Previously, we have benchmark CombSort algorithm implemented in various programming language for array of number. Let's compare this algorithm with addition integer to string conversion the language's built-in string library. The benchmark should not use any other built-in function other than string, integer conversion and array generation and printing. The benchmark uses AMD A8-6600K, 16GB RAM with Non-SSD disk.

The code can be found on my dropbox (folder: str-comb), and here's the summary:

Compiler / Interpreter

Language

Compile Duration

Compile RAM

Runtime Duration

Runtime RAM

Total Duration

g++ (debug)

C++

180

35868

19320

548912

19500

g++ (-O2)

C++

200

38184

13760

548816

13960

clang++ (debug)

C++

150

42240

18890

548868

19040

clang++ (-O2)

C++

200

45824

13870

548820

14070

javac, java

Java

1130

65324

48960

906652

50090

hhvm

PHP

89920

877468

89920

ruby

Ruby

114670

870612

114670

node

Javascript

17440

411144

17440

jsc-3

Javascript

60080

834744

60080

js24

Javascript

19270

735556

19270

go

Go

140

30428

11450

251628

11590

scala

Scala

83420

1093924

83420

python3

Python 3

121330

641844

121330

pypy

Python 2

14720

522080

14720

lua

Lua

98110

863880

98110

luajit

Lua

21300

511268

21300

dart

Dart

11920

497788

11920

Write down your opinion (or pastie if you found a bug on these source, or if you want to add more language implementation) on the comment section ^^)bNote #1: PHP 5.6.4, Rubinius 2.5.2, JRuby 9.0.0a1, Rhino 1.7, MCS 3.12 failed to end their execution within approx. 120s timeout

As usual, this is just a benchmark, happy programming experience is also important: available libraries, ease of coding -- writing and reading other people source codes, available editors/tools, great documentation, start-up/compile/test duration.

2015-02-24

Sometimes we plug and mount a portable harddisk or USB on Linux server and want to unplug it using command line :3 script ninja! You can use udisks comand to do this, just find which drive are your portable disk attached as, for example using lsblk, fdisk, or df command

Then just call udisks with --detach flag to safely remove the device, for example:

sudo udisks --detach /dev/sda

Or you can use this script, download/save then you can execute it, for example:

sudo sh suspend-usb-device.sh -v /dev/sda

now your portable disk can be removed safely.

Note: if you're using kernel newer than 2.6.32, there would be an error line 180: echo: write error: Invalid argument, change that script on line 180 from suspend into auto. And of course if you have Nemo (or maybe Nautilus too, but not for Thunar) installed you can always right click and then safely remove the drive without command line.