Installing Perf-tools on nixOS Latest

Perf-tools is a set of performance analysis tools for Linux aimed at sysadmins, developers, and performance engineers. It is available on GitHub and supports various Linux distributions, including nixOS. This tutorial will guide you through the process of installing Perf-tools on nixOS Latest.

Prerequisites

Before installing Perf-tools, make sure your nixOS system is up-to-date. You can update your system by running the following command:

$ sudo nix-channel --update
$ sudo nixos-rebuild switch

Installation

  1. Open a terminal window and navigate to the directory where you want to clone the Perf-tools repository. For example, you can create a new directory called perf-tools in your home directory and navigate to it using the following command:
$ mkdir ~/perf-tools && cd ~/perf-tools
  1. Clone the Perf-tools repository using the following command:
$ git clone https://github.com/brendangregg/perf-tools.git
  1. Change the directory to the newly created perf-tools folder using the following command:
$ cd perf-tools
  1. Install the required dependencies to build Perf-tools. Run the following command to install the dependencies using the nix package manager:
$ nix-shell -p autoconf automake boost git pkgconfig zlib gcc
  1. Run the build script to compile and install the Perf-tools binaries. Run the following command:
$ sudo ./build.sh
  1. Once the build process is complete, you can verify that Perf-tools is properly installed by running the ls command in the bin directory. The directory should contain various Perf-tools executables.
$ cd bin && ls

Usage

Perf-tools provide many useful tools for system performance analysis. To get started with Perf-tools, you can use the top tool. The following command will show you the top processes consuming CPU.

$ sudo ./top

You should see a list of processes with their CPU consumption.

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND            
 2812 root      20   0   50.5m   5.5m   3.5m R   6.1  0.4   0:01.66 Xorg               
 6047 user1     20   0   640.8m  47.4m  13.4m S   4.4  3.1   0:22.03 firefox            
 6523 user1     20   0   264344  42020  15888 S   3.3  2.7   0:08.64 gnome-terminal-    
 4631 root      39  19       0      0      0 R   2.2  0.0   0:00.37 kworker/0:1H-kbl+ 
 6461 user1     20   0   550360  13700  10396 S   2.2  0.9   0:00.28 gnome-terminal-    
 6714 root      20   0       0      0      0 S   1.1  0.0   0:01.58 kworker/1:1-events
 6280 user1     20   0  1015.2m 305.0m  61912 S   1.1 19.8   1:50.38 Web Content        
 6343 user1     20   0   801.5m  85.5m  23.8m S   1.1  5.6   0:56.87 Web Content        

These tools are very powerful and require proper usage. You can view the official documentation and tutorials to learn how to use different Perf-tools.

Conclusion

In conclusion, we have successfully installed Perf-tools on nixOS Latest. You can now use these tools to analyze system performance and optimize the performance of your Linux system.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!