Posts

LinuxSys Probe Utility

I’ve published a new small GNU/Linux system probe utility to: read cgroups information (cpusets and memory) read /proc information probe CPU affinity and memory allocation The detailed description and usage could be found on the aforementioned link. Let me here describe a couple of use-cases as an intruduction. Probe CPU affinity and memory allocation Setting CPU affinity and allocating memory could silently fail (e.g. if cgroups control them). The utility uses those failures to find the boundaries: docker run -it --rm -v ` pwd ` :/opt \ --cpuset-cpus = "2-4" --memory = "100m" alpine \ /opt/linuxsys-probe -d 10MiB -r probe probe.cpu::affinity [0] = [*2, 3, 4] probe.cpu::affinity [1] = [*2, 3, 4] probe.cpu::affinity [2] = [*2] probe.cpu::affinity [3] = [*3] probe.cpu::affinity [4] = [*4] probe.cpu::affinity [5] = [*2, 3, 4] probe.cpu::affinity [6] = [2, *3, 4] probe.cpu::affinity [7] = [2, 3, *4] probe.cpu::affinity ...

Primes generation (algorithms vs real code)

Image
Primes is a quite useful tool and have many applications. They are an essential part of RSA cryptography, and while elliptic curve algorithms are gaining dominance nowadays, RSA is still widely used. Plus there are other applications like rolling hash functions, i.e. assigning an unique prime to each character in the required alphabet and multiplying them (and implementing rolling by dividing to the number corresponding to the previous character, and multiplying to the number corresponding to the new character). There are several algorithms (or even families of algorithms) to calculate primes, and recently I’ve stumbled upon a new one: A new explicit algorithmic method for generating the prime numbers in order . It’s been looking promising, and I’ve programmed it, but unfortunately it wasn’t fast enough as the real code. Authors compared it with sieves of Eratosthenes and Sundaram using their unified framework, and got nice results. However the implementations do not necessar...

Testing with multi-arch Docker images

Testing with multi-arch Docker images With the introduction of Docker Buildx CLI plugin it became quite easy to test various platforms using single Dockerfile without any QEMU static builds. In this tutorial we’re going to use a multistage build with the simple C++ program that tests features of various platforms. First, we need to register QEMU handlers. Please note that the handler registration won’t survive a reboot. $ docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64 There is no latest alias for the docker/binfmt and it’s recommended to grab the proper tag on their homepage: https://hub.docker.com/r/docker/binfmt/tags?page=1&ordering=last_updated The code to detect the platform endianness and its sizes for the basic types: #include <iostream> #ifndef PLATFORM #define PLATFORM "N/A" #endif void platform () { std :: cout << "Platform: " << PLATFORM << std ...