If you’ve ever wondered how much memory a process uses, you’ve probably used a form of task manager or system monitor. System monitors can be useful to identify resource hogs, but are often less versatile if you want more details about just one process. If you’ve ever faced this problem, then [Fabien Sanglard]’s Space-Time explorer is for you!
The wonderfully punny Space-Time tool records physical memory usage, time spent in user space vs. kernel space and even threads and subprocesses created. These words may not mean much to some readers, so let’s quickly go over them: Physical memory usage is the actual amount of RAM given (not always the same as requested). The kernel (which lives in kernel space) is the supervisor to all processes on a computer. In contrast, every process lives in it’s own “user space”, a way of protecting the kernel. Finally, a subprocess (or “child process”) is simply a process started by another process (the “parent”).
In their blog post, [Fabien] starts with a simple test program: allocating 1 GiB and setting each byte individually. What would seem like a simple task that shouldn’t take much more than 10ms actually takes over a second and [Fabien] explains that the kernel doesn’t actually immediately give 1 GiB, but actually waits until the memory gets used. [Fabien] also compares the Space-Time footprints of hello world programs in C and C++ (both clang and GCC), Rust, Java and Go, which yields surprising results. [Fabien] also tries some more “real-world” tasks like a browser (chromium), curl, wget and even a compiling a “medium-size” project (Git) from source. Finally, [Fabien] finishes off by briefly explaining how Space-Time explorer works and why what pushed them to create the tool in the first place.
If you’re looking to improve you Linux arsenal, how about building a better ls?
for windows I still use some of the old systinternals routines, now over at microsoft – https://learn.microsoft.com/en-us/sysinternals/downloads/
Fabien Sanglard is the author of the very famous “game engine black book – wolfenstein 3D” and similar books (doom, arcade systems). You oughta mention that !
You said that!
And I add: few books inspired me to fire up again my C-skills as the “Doom Engine Black Book” did. If you want a really intriguing book, between the historical and the technical, this is a must!
It needs to be for c.£50!
For clarification, the blog post doesn’t compare hello world programs, it compares *compiling* hello world programs. It’s comparing the performance of the build tools, not the performance of the hello-world executable build products.
Correct, but one can use it to do just that.
BTW a interresting read.!
There are often two versions of “time” installed on Linux machines. Bash has its own version which gives real, user, and system time spent on the process (posix compliant output). There’s also a stand-alone version (/usr/bin/time on Ubuntu) which will show much more (files used, memory usage, stack usage, context switches, page fault, etc.)