2015-03-20

Techempower Framework Benchmark 10 Preview 6

New framework benchmark preview has been published, still C++ on top, JavaScript second, followed by Scala, Nimrod, Dart and Go. There are no quite significant changes with previous benchmark.



But as I stated before, performance is not everything. It won't be really good if the writing/compiling/debugging process took too much time.

2015-03-16

Techempower Framework Benchmark 10 Preview 5

New framework benchmark preview has been published, still C++ on top, JavaScript second, followed by Scala, Nimrod, Dart and Go. HHVM no longer on top because of some technical error. I think other benchmark seems not realistic enough '___')



But as I stated before, performance is not everything. It won't be really good if the compiling/debugging process took too much time.

2015-03-13

Manga Downloader on Linux

There are plenty of options to automate manga download on Linux, for example: AnyMangaDownloaderBatotoDownloader, LinuxMangaDownloader, HakuNeko, MangaTux, MangaEdenBatchDownloader, MangaDownloader (command line), MangaCrazy (jar), and Zenbu. And of course you can look for another alternatives on github.

MangaTux required you to give the URL manually (you cannot search within the program), it support some Spanish and English manga site (MangaHead, MangaFox, MangaShare, MangaReader, Animea) even 4chan, zerochan, danboru and pown.it. On ArchLinux, you can install and run using this command:

yaourt --needed --noconfirm -S --force mangatux
mangatux



With Hakuneko you can search within MangaReader, MangaHereMangaFox, Batoto, and KissAnime (doesn't work). The interface are quite straightforward. You can install and run using this command:

yaourt --needed --noconfirm -S --force hakuneko
hakuneko



MangaEdenBatchDownloader also similar to MangaTux. You can install and run using this command:

yaourt --needed --noconfirm -S --force mangaedenbatchdownloader
java -jar /opt/edenbatchdownloader/EdenBatchDownloader.jar

BatotoDownloader exactly similar to MangaEdenBatchDownloader, You can install and run using this command:

yaourt --needed --noconfirm -S --force batotodownloader
java -jar /opt/batotodownloader/Batoto.jar


To read manga (cbz, cbr, cbt, cba, cb7rar, zip, tar, ace, 7z, etc) you can use MComix, the install and run command:

yaourt --needed --noconfirm -S --force mcomix
mcomix

I think the best one for now is Hakuneko.

2015-03-04

Monitorix: System Resource Monitoring for Linux

Monitorix is a daemon that enables you to monitor your Linux server/system resources. It has built-in web server, and developed using Perl. To install the daemon on ArchLinux, use this command:

yaourt --needed --noconfirm -S --force monitorix
sudo systemctl enable monitorix
sudo systemctl start monitorix

The configuration file can be found on /etc/monitorix/monitorix.conf, for example you can enable the built-in webserver and change the port, change the network interface's to be monitored or enable and disable sensors, just find the key and change it, for example:

<httpd_builtin>
  enabled = y
  host = 127.0.0.1
  port = 8081
  user = nobody
  group = nobody
  log_file = /var/log/monitorix-httpd
  hosts_deny =
  hosts_allow =
  <auth>
    enabled = y
    msg = Monitorix: Restricted access
    htpasswd = /var/lib/monitorix/htpasswd
  </auth>
</httpd_builtin>

<graph_enable>
  system  = y
  proc    = y
  fs  = y
  net  = y
  user  = y
  netstat = y
</graph_enable>

<net>
  list = enp2s0, wlp3s0
  <desc>
  enp2s0 = Gigabit LAN, 0, 10000000000
  wlp3s0 = Wireless LAN, 0, 100000000
  </desc>
  gateway = enp2s0
</net>


After changing the configuration file, you  may want to create a password so no other user can see the web, for example to create a new user named test with password youMayNotKnow:

sudo htpasswd -bcd /var/lib/monitorix/htpasswd test youMayNotKnow

after that, don't forget to restart the service:

sudo systemctl restart monitorix

Then you can see the result by visiting http://127.0.0.1:8081/monitorix.








2015-03-03

Prime Number Generator Benchmark

Today we're gonna benchmark about prime number generator (without sieve and prime library). The spec is generating all prime number below 10 million and outputting every 100k-th prime found. As usual, the source can be found on my dropbox (folder: prime). The benchmark performed on 64-bit Linux, i3-4150, 16GB RAM and non-SSD disk.

# desired output:
1299721
2750161
4256249
5800139
7368791
8960467

$ g++ --version
g++ (GCC) 4.9.2 20150204 (prerelease)
$ time g++ -std=c++11 prime.cpp
CPU: 0.20s      Real: 0.23s     RAM: 50232KB
$ time ./a.out
CPU: 2.94s      Real: 2.95s     RAM: 6592KB
$ time g++ -O2 -std=c++11 prime.cpp
CPU: 0.21s      Real: 0.23s     RAM: 51912KB
$ time ./a.out
CPU: 0.85s      Real: 0.85s     RAM: 6616KB

$ clang++ --version
clang version 3.5.1 (tags/RELEASE_351/final)
$ time clang++ -std=c++11 prime.cpp
CPU: 0.19s      Real: 0.23s     RAM: 46792KB
$ time ./a.out
CPU: 2.93s      Real: 2.94s     RAM: 6488KB
$ time clang++ -O2 -std=c++11 prime.cpp
CPU: 0.20s      Real: 0.22s     RAM: 50484KB
$ time ./a.out
CPU: 0.84s      Real: 0.84s     RAM: 6636KB

$ go version
go version go1.4.1 linux/amd64
$ time go build prime.go
CPU: 0.11s      Real: 0.12s     RAM: 30364KB
$ time ./prime
CPU: 2.48s      Real: 2.49s     RAM: 20412KB

$ javac -version
javac 1.7.0_75
$ time javac prime.java
CPU: 0.73s      Real: 0.44s     RAM: 47464KB
$ time java prime
CPU: 1.21s      Real: 1.18s     RAM: 104580KB

$ javac -version
javac 1.8.0_40
$ time javac prime.java

CPU: 0.96s      Real: 0.45s     RAM: 59860KB
$ time java prime
CPU: 1.23s      Real: 1.19s     RAM: 104716KB

$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
$ time ruby prime.rb
CPU: 20.97s     Real: 20.99s    RAM: 14388KB

rbx --version
rubinius 2.5.2.c85 (2.1.0 e8a24276 2015-02-23 3.5.1 JI) [x86_64-linux-gnu]
$ time rbx prime.rb
CPU: 14.20s     Real: 14.15s    RAM: 54004KB

$ jruby --version
jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2015-02-24 2a3dc1f OpenJDK 64-Bit Server VM 24.75-b04 on 1.7.0_75-b13 +jit [linux-amd64]
$ time jruby prime.rb
CPU: 38.79s     Real: 36.41s    RAM: 298688KB

$ node --version
v0.10.36
$ time node prime.js
CPU: 1.61s      Real: 1.62s     RAM: 24796KB

$ pacman -Qo `which jsc-3`
/usr/bin/jsc-3 is owned by webkitgtk 2.4.8-1
$ time jsc-3 prime.js
CPU: 2.30s      Real: 2.31s     RAM: 22008KB

js24 --help| grep Version
Version: JavaScript-C24.2.0
$ time js24 prime.js
CPU: 1.19s      Real: 1.24s     RAM: 15488KB

$ echo | rhino
Rhino 1.7 release 4 2014 07 01
$ time rhino prime.js
CPU: 56.23s     Real: 55.72s    RAM: 873048KB

$ echo | jjs -version
nashorn 1.8.0_40

$ time jjs prime.js
CPU: 23.36s     Real: 22.28s    RAM: 448144KB

$ php --version
PHP 5.6.5 (cli) (built: Jan 22 2015 18:29:09) 
$ time php prime.php
CPU: 36.70s     Real: 36.77s    RAM: 111488KB

$ hhvm --version
HipHop VM 3.5.0 (rel) Compiler: 1422366928_067131079
$ time hhvm -v Eval.Jit=true prime.php 
CPU: 5.92s      Real: 11.14s    RAM: 98288KB

$ python --version
Python 3.4.2
$ time python prime.py
CPU: 78.33s     Real: 78.51s    RAM: 33476KB

$ pypy --version 
Python 2.7.8 (10f1b29a2bd2, Feb 05 2015, 16:50:17) [PyPy 2.5.0 with GCC 4.9.2 20141224 (prerelease)]
$ time pypy prime.py
CPU: 3.66s      Real: 4.14s     RAM: 84180KB

$ lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
$ time lua prime.lua
CPU: 22.16s     Real: 22.19s    RAM: 18628KB

$ luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
$ time luajit prime.lua
CPU: 6.64s      Real: 6.65s     RAM: 10360KB

$ mcs --version
Mono C# compiler version 3.12.0.0
$ time mcs prime.cs
CPU: 0.35s      Real: 0.36s     RAM: 39704KB
$ time mono prime.exe 
CPU: 1.78s      Real: 1.79s     RAM: 16368KB

$ dart --version
Dart VM version: 1.8.5 (Tue Jan 13 12:44:14 2015) on "linux_x64"
$ time dart prime.dart
CPU: 1.37s      Real: 1.38s     RAM: 31604KB

$ crystal --version
Crystal 0.6.1 [0162f84] (Mon Mar 16 15:22:20 UTC 2015)
$ time crystal prime.cr
CPU: 2.53s      Real: 2.62s     RAM: 28552KB
$ time crystal prime.cr --release
CPU: 1.18s      Real: 1.23s     RAM: 36784KB

$ julia --version
julia version 0.3.6
$ time julia prime.jl
CPU: 3.09s      Real: 3.12s     RAM: 71576KB

$ nim --version
Nim Compiler Version 0.10.2 (2014-12-31) [Linux: amd64]
$ time nim c prime.nim
CPU: 0.66s      Real: 0.69s     RAM: 44728KB
$ time ./prime
CPU: 7.65s      Real: 7.67s     RAM: 12224KB
$ time nim c -d:release prime.nim
CPU: 1.36s      Real: 1.36s     RAM: 55376KB
$ time ./prime
CPU: 2.44s      Real: 2.45s     RAM: 12160KB

$ rustc --version
rustc 1.0.0-dev (built 2015-02-23)
$ time rustc prime.rs
CPU: 0.36s      Real: 1.76s     RAM: 95960KB
$ time ./prime 
CPU: 3.75s      Real: 3.76s     RAM: 6196KB
$ time rustc -O prime.rs
CPU: 0.34s      Real: 0.38s     RAM: 96764KB
$ time ./prime 
CPU: 1.03s      Real: 1.04s     RAM: 6224KB

$ gnatmake --version
GNATMAKE 4.9.2 20150304 (prerelease)
$ time gnatmake prime.adb
CPU: 0.40s      Real: 0.44s     RAM: 51540KB
$ time ./prime
CPU: 5.85s      Real: 5.86s     RAM: 5488KB
$ rm prime prime.o prime.ali; time gnatmake -O2 prime.adb
CPU: 0.86s      Real: 0.91s     RAM: 57084KB
$ time ./prime
CPU: 1.27s      Real: 1.27s     RAM: 5348KB

$ fpc -version
Free Pascal Compiler version 2.6.4 [2014/03/12] for x86_64
$ time fpc prime.pas
CPU: 0.01s      Real: 0.02s     RAM: 10636KB
$ time ./prime
CPU: 3.42s      Real: 3.42s     RAM: 6688KB
$ time fpc -O2 prime.pas
CPU: 0.01s      Real: 0.02s     RAM: 10568KB
$ time ./prime
CPU: 3.00s      Real: 3.02s     RAM: 6688KB

And the summary:

Compiler / InterpreterLanguageCompile DurationCompile RAMRuntime DurationRuntime RAMTotal Duration
g++C++20050232294065923140
g++ (-O2)C++2105191285066161060
clang++C++19046792293064883120
clang++ (-O2)C++2005048484066361040
goGo110303642480204122590
javac, javaJava7304746412101045801940
rubyRuby209701438820970
rbxRuby142005400414200
jrubyRuby3879029868838790
nodeJavaScript1610247961610
jsc-3JavaScript2300220082300
js24JavaScript1190154881190
rhinoJavaScript5623087304856230
jjsJavaScript2336044814423360
phpPHP3670011148836700
hhvmPHP5920982885920
python3Python 3783303347678330
pypyPython 23660841803660
luaLua221601862822160
luajitLua6640103606640
mcsC#350397041780163682130
dartDart1370316041370
crystalCrystal2530285522530
crystal (--release)Crystal1180367841180
juliaJulia3090715763090
nimNimrod660447287650122248310
nim (-d:release)Nimrod1360553762440121603800
rustcRust36095960375061964110
rustc (-O)Rust34096764103062241370
gnatmakeAda40051540585054886250
gnatmake (-O2)Ada86057084127053482130
fpcObjectPascal1010636342066883430
fpc (-O2)ObjectPascal1010568300066883010

Note #1: PH7 failed to give any output within 1 minute.
Note #2: IO failed to give complete output within 2 minutes.
Note #3: Nimrod caches the compile process, so the second time compile are less than 100ms
Note #4: Potion failed to give complete output within 2 minutes.
Note #5: Gnatmake caches the compile process, so the second time compile are less than 10ms, but it doesn't overwrite when different flag used (-O2 for example).
Note #6: Some languages can be compiled, and some other can be executed directly using certain command, but I choose one that I learned first (but I will benchmark both method when I have much free time)
Note #7: Compile cache deleted before every (3) benchmark run, the value taken are the median.

Changelog:
2015-03-03: benchmark published
2015-03-xx: Lua, C# (mcs), and Dart added
2015-03-17: Crystal, Julia, and Nimrod (nim) added
2015-03-18: ObjectPascal (fpc), Ada (gnat), and Nashorn (jjs) added








2015-02-27

Old String Set/Map Data Structure Benchmark (2012)

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: The Software Container

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:

# install stable version
$ yaourt --needed --noconfirm -S --force docker

# or latest git version
$ yaourt --needed --noconfirm -S --force docker-git

# start and enable the service
$ sudo systemctl enable docker
$ sudo systemctl start docker

# allow your user to access docker, refresh session
$ sudo gpasswd -a `whoami` docker
$ newgrp docker

# show information
$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
Execution Driver: native-0.2
Kernel Version: 3.18.7-1-ARCH
Operating System: ArchLinux
CPUs: 4
Total Memory: 15.49 GiB
Name: zzz
ID: 5SDJ:LPNU:UAR4:ULRJ:REZF:4V3W:6ES6:KJTW:DETH:765Y:XP4I:IZZZ

WARNING: No swap limit support

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:

$ docker pull l3iggs/archlinux
$ docker pull kampka/archlinux
$ docker pull codekoala/arch

$ docker pull logankoester/archlinux 
Pulling repository logankoester/archlinux
88d601db3077: Download complete 
511136ea3c5a: Download complete 
9b0516337e5a: Download complete 
dce0559daa1b: Download complete 
ff4d9d90bf08: Download complete 
7207641fe7f8: Download complete 
Status: Downloaded newer image for logankoester/archlinux:latest

To list all docker images, type docker images, find the image's REPOSITORY or IMAGE ID, then you can run any command on that docker using docker run for example:

$ docker run 88d601db3077 ls -al
...

docker run -t -i logankoester/archlinux /bin/bash
exit

$ docker run logankoester/archlinux pacman -Rdd --noconfirm dirmngr

Packages (1): dirmngr-1.1.1-2

Total Removed Size:   0.49 MiB

:: Do you want to remove these packages? [Y/n] 

removing dirmngr...

$ docker run logankoester/archlinux pacman -Syu --noconfirm
:: Synchronizing package databases...
downloading core.db...
downloading extra.db...
downloading community.db...
:: Starting full system upgrade...
:: Replace dirmngr with core/gnupg? [Y/n] 
:: Replace lzo2 with core/lzo? [Y/n] 
resolving dependencies...
looking for inter-conflicts...

Packages (77): archlinux-keyring-20150212-1  bash-4.3.033-1  ca-certificates-20140923-9  ca-certificates-cacert-20140824-2  ca-certificates-mozilla-3.17.4-1  ca-certificates-utils-20140923-9  coreutils-8.23-1  cracklib-2.9.1-1  curl-7.40.0-1  db-5.3.28-2  dbus-1.8.16-2  device-mapper-2.02.116-1  dhcpcd-6.7.1-1  dirmngr-1.1.1-2 [removal]  e2fsprogs-1.42.12-1  expat-2.1.0-4  file-5.22-1  filesystem-2015.02-1  gcc-libs-4.9.2-3  gettext-0.19.4-1  glib2-2.42.1-1  glibc-2.21-2  gmp-6.0.0-2  gnupg-2.1.2-1  gnutls-3.3.12-1  gpgme-1.5.3-1  grep-2.21-1  hwids-20150129-1  inetutils-1.9.2-2  iproute2-3.18.0-1  kbd-2.0.2-1  kmod-19-1  krb5-1.13.1-1  less-471-1  libarchive-3.1.2-8  libassuan-2.1.3-1  libcap-2.24-2  libdbus-1.8.16-2  libffi-3.2.1-1  libgcrypt-1.6.2-1  libgpg-error-1.18-1  libidn-1.29-1  libksba-1.3.2-1  libldap-2.4.40-2  libsystemd-218-2  libtasn1-4.2-1  libtirpc-0.2.5-1  libunistring-0.9.4-1  libutil-linux-2.25.2-1  linux-api-headers-3.18.5-1  logrotate-3.8.8-2  lz4-127-1  lzo-2.09-1  lzo2-2.08-1 [removal]  mpfr-3.1.2.p11-1  ncurses-5.9-7  netctl-1.10-1  nettle-2.7.1-1  npth-1.1-1  openresolv-3.6.1-1  openssl-1.0.2-1  p11-kit-0.22.1-3  pacman-4.2.1-1  pacman-mirrorlist-20150205-1  pcre-8.36-2  perl-5.20.2-1  pinentry-0.9.0-1  procps-ng-3.3.10-1  shadow-4.2.1-2  systemd-218-2  systemd-sysvcompat-218-2  tar-1.28-1  texinfo-5.2-3  tzdata-2015a-1  usbutils-008-1  util-linux-2.25.2-1  xz-5.2.0-1

Total Download Size:    62.40 MiB
Total Installed Size:   264.78 MiB
Net Upgrade Size:       26.52 MiB


:: Proceed with installation? [Y/n] 

:: Retrieving packages ...
...

The previous changes of each run is not saved until you call docker commit, find out the last run ID first before committing:

$ docker ps -l 
CONTAINER ID        IMAGE                           COMMAND                CREATED             STATUS                     PORTS               NAMES
6d67ee44e7f5        logankoester/archlinux:latest   "pacman -Syu --nocon   11 minutes ago      Exited (0) 2 minutes ago                       stoic_meitner 

# docker commit ID your_username/your_repository
$ docker commit 6d67ee44e7f5 kokizzu/archlinux
5ab1562ea89959c54b8da4462abf086c91434524ae741769dab869b8263d7c1b

To check more information about current dock, use docker inspect followed by image ID:

$ docker images 
REPOSITORY               TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
kokizzu/archlinux        latest              5ab1562ea899        28 seconds ago      640.6 MB
logankoester/archlinux   latest              88d601db3077        24 hours ago        282.9 MB
...

# docker inspect ID
$ docker inspect 5ab1562ea899


After you verify that your image is working, you can share it to others (create a repository first on your dashboard), for example:

# docker push ID your_username/your_repository

You can find more information on the cheatsheet and the documentation, and if you're tempted to install sshd read this first.