Performance Comparison of mmap() versus read() versus fread()

I recently read in Computers are *fast*! by Julia Evans about a comparison between fread() and mmap() suggesting that both calls deliver roughly the same performance. Unfortunately the codes mentioned there and referenced in bytesum.c for fread() and bytesum_mmap.c for mmap() do not really compare the same thing. The first adds size_t, the second adds up uint8_t. My computer showed that these programs do behave differently and therefore give different performance.

I reprogrammed the comparison adding read() to fread() and mmap(). The code is in GitHub. Compile with

cc -Wall -O3 tbytesum1.c -o tbytesum1

For this program the results are as follows:

Continue reading

2015 in review – report generated by WordPress

See the fireworks Elmar Klausmeier’s Weblog created by blogging on WordPress.com. Check out their 2015 annual report.

Here is an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 14,000 times in 2015. If it were a concert at Sydney Opera House, it would take about 5 sold-out performances for that many people to see it.

There were 47 pictures uploaded, taking up a total of 425 MB. That’s about 4 pictures per month.

The busiest day of the year was January 2nd with 93 views. The most popular post that day was Three Free Invites For the OnePlus One.

Source: My 2015 annual report.

nginx: 413 Request Entity Too Large – File Upload Issue

I got above error message in nginx. Stackoverflow post 413 Request Entity Too Large – File Upload Issue had all information to resolve the issue. The solution was written by User Arun.

One has to edit /etc/nginx/nginx.conf

client_max_body_size 15900M

and /etc/php/php.ini

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 15900M

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 6900M

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 25900M

Besides editing /etc/nginx/nginx.conf and /etc/php/php.ini I had to stop nginx and php-fpm:

systemctl stop nginx
systemctl stop php-fpm

so the changes take effect.

After starting the two services then check with phpinfo().

Small Scale Computing

Below is a short overview of small scale computers for use in embedded computing.

  1. Intel Galileo, single core Quark/Pentium, ca. 100 USD, <15 W
  2. Intel Edison, dual core Atom Silvermont, 500 MHz, ca. 100 USD, <1 W
  3. Raspberry Pi, single core ARM, 700 MHz, ca. 35 USD, ~1 W
  4. Arduino series, e.g., Intel Quark/Cortex, 32 MHz, ca. 15 USD, ~1 W
  5. ESP8266 (spec), single core Tensilica Xtensa LX106, 80 MHz, 7 USD, 1 mW

On the other end of the spectrum there are Mini PCs.

  1. Intel NUC, quadcore Intel i5/i7, ca. 400 USD (no SSD+no RAM), 6-60 W
  2. Apple Mac Mini, Intel i5/i7, ca. 500 USD, 6-85 W
  3. Apple Mac Pro, Intel 3.5 GHz 6-Core Intel Xeon E5, ca. 4,000 USD, <450 W

Now comes the fun part: connecting many small scale computers to a cluster.

Connecting 64 Raspberry Pi running MPI and putting them all into a Lego frame, see Raspberry Pi at Southampton.

Clustering 48 PandaBoards and putting this all into an industrial trashcan, see Phoronix: Building A 96-Core Ubuntu ARM Solar-Powered Cluster.

Clustering ten Intel NUCs each with 10GB RAM: Orange Box, see The Orange Box: Cloud for the Free Man, motto: Most planes fly in clouds…this cloud flies in planes!

Mac Pros are offered in the cloud, see Dedicated Mac Pro server hosting.

Working with Windows Junctions in Python

I had to detect Windows junctions (similar but not identical to symbolic links) in Python. On stackoverflow.com I read the following Python code given by a user named eryksun for handling them, as os.islink() does not work for junctions.

The routines access Windows functions CreateFileW(), DeviceIoControl(), CloseHandle() in kernel32.

Continue reading