What make Docker so popular and long-lasting?
- Container is essentially OS level virtualization. Each application gets illusion of its own OS, having almost absolute control over it. Another advantage is that host OS knows about the container processes and hence can share its resources among hosted containers.
- The concept of containers was started by FreeBSD, refined by Solaris and re-implemented by Linux.
- Containers are better than two other levels of virtualization:
- ABI/platform level, where application integrates with the platform (Google App Engine), doesn’t scale well.
- Hardware level, where a virtual hardware runs the OS (e.g. virtual machines, hypervisors).
- Docker containers run close to the real hardware, and host OS has knowledge of resource usage. Hence it’s an optimal sweet spot for virtualization.
- Joyent SmartOS is built on OpenSolaris and provides Solaris features to Linux like Docker containers. It acheives that by allowing Linux APIs translated to Solaris APIs. Everything runs on the bare metal hence.
- SmartOS containers get ZFS, Dtrace by default 🙂
- SmartOS containers are very secure as they run in zones.
I hope to cover Smart OS design internals, Docker container on Linux details in next posts.
Tips to Improve Dynamic Memory Performance
Instead of using
memset() to initialize malloc()’ed memory, use
calloc(). Because when you call
memset(), VM system has to map the pages in to memory in order to zero initialize them. It’s very expensive and wasteful if you don’t intend to use the pages right away.
calloc() reserves the needed address space but does not zero initialize them unless memory is used. Hence it postpones the need to load pages in to memory. It also lets the system initialize pages as they’re used, as opposed to all at once.
Lazy allocation: A global(normal variable or a buffer) can be replaced with a static and a couple of functions to allow its access.
memcpy() & memmove() needs both blocks to be memory resident. Use them if size of blocks is small(>16KB), you would be using the blocks right away, if blocks are not page aligned, blocks overlap.
But if you intend to postpone the use, you would increasing the working set of the application. For small amount of data, use
To check heap dysfunctional behavior:
$ MALLOC_CHECK_=1 ./a.out
It’ll give an address related to each violation of dynamic memory routines.
Electric fence : Works very well with gdb
Libsafe: for libc routines
I upgraded my Ubuntu from 16.04 to 18. And the Internet stopped working. 😦
I tried rebooting
interface, adding a new interface to
ifconfig. But it did not help.
What helped was an answer on AskUbuntu
How it worked?
The answer is in how Ubuntu lookup domains like
Check the domain in the local DNS, also called a DNS stub.
If Step 1 fails (local DNS lookup is a
miss), it contacts a public DNS such as
126.96.36.199 also called Google Public DNS.
Since after the upgrade public DNS was not set, the internet seemed inaccessible!
How to Update Public DNS?
Written with StackEdit.I
tags: ‘shell, linux, command, development, grep,find’
I use the following command to find a string in a Go repo. The vendor directory is not needed, so skip it.
$ find . -type f |grep -v vendor|cut -d":" -f2|xargs grep -n my_search_string
The command find all files in current directory. Next, it removes all files that have vendor in their path.
cut command picks the filename and passed to
xargs. Each file is then processed by
grep for the search string.
Ever faced garbled screen on a terminal, text wrapping over and screen command string messed up!
It happens because the terminal is using default row and column value (e.g. columns = 80).
The following command fixes it (tested on Docker container’s terminal)
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -ti
How it Works?
Written with StackEdit.