In the last few years, the use of containers has increased significantly. The concept of containers have been around for several years, but it was Docker’s easy-to-use command line that started to popularize containers among the developer from 2013.
In this series I am trying to demonstrate how containers work underneath and how I did develop the vessel.
vessel is an educational-purpose project of mine which implements a tiny version of Docker to manage containers. It does not use either containerd or runc, it uses a set of the Linux features to be able to create containers.
vessel is neither production ready nor well-tested software. It’s just a simple project to learn more about containers. …
Go is a programming language often used for applications in which performance matters. Optimizing your code based on assumptions is not a best practice of course. You need to have insights about your code performance and bottlenecks to be able to optimize it efficiently.
Profiler is a dynamic performance analysis tool that provides critical execution insights in various dimensions which enable resolving performance issues, locating memory leaks, thread contention and more.
To err is human, to forgive divine.
— Alexander Pope
These are mistakes that I’ve made writing Go. Although these might not cause any sort of error but they can potentially affect the software.
There are several ways to make a mess inside a loop which you need to be aware of.
Due to efficiency, the loop iterator variable is a single variable that takes different values in each loop iteration. It might lead to unwitting behavior.
The result will be:
Values: 3 3 3
Addresses: 0xc000014188 0xc000014188 0xc000014188
As you can see all elements in
out slice are 3. It is actually easy to explain why this did happen: in every iteration we append the address of
v to the
out slice. As mentioned before
v is a single variable which takes new values in each iteration. So as you can see in second line of the output, addresses are the same and all of them are pointing to the same value. …
I encountered a problem in Go Garbage Collection inside a project of mine recently. A massive amount of object were allocated repeatedly and caused a huge workload of GC. Using
sync.Pool I was able to decrease the allocations and GC workload.
One of the highlights of Go 1.3 release was sync Pool. It is a component under the
sync package to create a self-managed temporary retrieval object pool.
We want to keep the GC overhead as little as possible. Frequent allocation and recycling of memory will cause a heavy burden to GC.
sync.Pool can cache objects that are not used temporarily and use them directly (without reallocation) when they are needed next time. …