Introducing Acme, the Bell Labs Text Editor

Since I was talking about Vim, the Acme Text Editor written by Rob Pike for Plan 9 in the early 1990s is another favorite. Nothing but yellowish windows and blue bars with a focus on the job to be done.

Acme combines several aspects of window systems, shells, and editors. Designed to support software development but not a true programming toolkit. Instead, it is a self-contained program; more like a shell than a library, that joins users and applications.

From the perspective of the application e.g. compiler, browser, etc., it provides a universal communication mechanism based on familiar Unix or GNU - Linux file operations, that permits your small applications even shell procedures to exploit the graphical user interface of the system and communicate with each other.
For the user, the interface is extremely spare, consisting only of text, scroll bars, one simple kind of window, and a unique function for each mouse button. There are no widgets, no icons, not even pop-up menus.
Despite these GUI limitations, Acme is still an effective environment in which to work and, particularly, to program.

It’s rather difficult to explain how it works without seeing it though, so I added a screencast from Russ Cox’s Golang page showing a brief programming session.

Watch the video

PS. Each time people tell me today’s Acme users are borderline insane, I send them the above link and they usally shut up.

Casting spells in the Vim language

For the past three years I used Vim almost exclusively to become efficient with it.
I wrote code, countless articles and documentation. Me and Vim we were ok till I watched this video and realized I had been living in blissful ignorance, relying on plugins, a 200 lines long .vimrc file that completely changes how Vim works, and bad advise given by people who know nothing about VI.

Watch the video

Please note that Chris Toomey is ‘flying’ through commands and concepts, which makes it quite difficult to follow for Vim newbs and regular users alike.

Goyo, distraction free writing in Vim

Can’t believe I’ve never mentioned Goyo, one of my most used Vim plugins ever.

It adds a distraction free mode that helps me focus while writing by centering the content and hiding all other elements.

Other nice features are the support of console ANSI-sequences for curl, httpie or wget; HTML for web browsers; or PNG for graphical viewers.

Usage

Toggle Goyo:
:Goyo

Turn on and resize Goyo to the dimension 100x50:
:Goyo 100x50

Turn off Goyo:
:Goyo!

My configuration changes

The plugin works just fine as is, but I did change the text area in my vimrc config file (as seen in the image above), as I find that to be a better fit for my eyes:
let g:goyo_width=100
let g:goyo_height=50

Finally, as piece de resistance, I added a shortcut by bounding the toggle feature to the key g:
map <C-g> :Goyo<CR>

Note

Are you interested in trying Vim? I can highly recommend checking out this link. Trust me, it’s by far not that hard as many people want you to believe. :)

Optimizing Ubuntu 22.04.1 Jammy Jellyfish

These tips are meant for Ubuntu systems, but in general any Debian based distro should be ready to go. Keep in mind that, as everything in life, nothing comes for free. Every optimization has its own pricetag and you must decide how much you are willing to pay for it.

Burning my disk, no more …

The Firefox sessionstore

Sessionstore is responsible for caching which pages were already opened should Firefox suddenly crash. While this is a great feature (you reopen all lost tabs and continue browsing), it causes a lot of writes to your SSD.

Disabling is really easy. Type about:config in de addressbar and press Enter. Click on agree and look for sessionstore. Double-click on browser.sessionstore.interval and change 15000 (15 seconds) to 15000000. Press OK, restart Firefox.

Swappiness (dismiss when having more than 16 Gb RAM)

When working with limited RAM, Ubuntu will aggressively try to free memory to enlarge the caches aka swapping. This again will lead to large quantities of write actions on your SSD which in their turn slow down your system and chip away at the disk’s total lifetime.

To change Ubuntu’s standard swap_tendency weight, open a terminal and query the current swappiness value by typing:

$ cat /proc/sys/vm/swappiness

Probably swappiness wil return a value of 60 which is too high for normal use. Let’s edit the configuration file:

$ gedit admin:///etc/sysctl.conf

The text editor app will open. At the end type:

# Lower swap_tendency
vm.swappiness=25

and save. To activate the new setting, restart the computer.

Faster, faster, performance is key!

Move /tmp to tempfs

Another trick to make a machine run faster is moving /tmp to tmpfs. Temporary files will no longer be placed on the physical disk but in a virtual RAM disk.

Open a terminal and type:

$ sudo cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
$ sudo systemctl enable tmp.mount

Reboot the computer.

Should you experience issues, you can always undo the change by typing:

$ sudo rm -v /etc/systemd/system/tmp.mount

Activate the zram system kernel function

If your PC has enough memory, zram could be used to replace the /swap.img file altogether.

Enabling zram causes conflicts with zswap, which is activated by default. Disable it by typing the following command in your terminal:

$ echo 0 > /sys/module/zswap/parameters/enabled

Now we can load the zram module:

$ modprobe zram

We should find a device node named /dev/zram0. Let’s allocate a size for it:

$ echo 1024M > /sys/block/zram0/disksize # change size to your liking.

Format that new device as if it was just a normal disk partition we designated for swap:

$ mkswap --label zram0 /dev/zram0
$ swapon -p 100 /dev/zram0

To set zram permanently, once again run gedit and add or change following lines in /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFULT=""
GRUB_CMDLINE_LINUX="zswap.enabled=0"

Save the file and run:

$ update-grub 

to update the bootloader config files.

Now, we make sure the zram module is loaded at boot, and knows the number of devices we need (if we were also using zram for other tmpfs directories like /tmp, we’d have to increase the number):

$ echo "zram" > /etc/modules-load.d/zram.conf
$ echo "options zram num_devices=1" > /etc/modprobe.d/zram.conf

Create a udev rule so that the device node is formatted automatically as swap:

$ sudo -i
$ [sudo] password for **my username**:
$ root@yourmachinename:~# cat > /etc/udev/rules.d/99-zram.rules KERNEL=="zram0", ATTR{disksize}="1024M" RUN="/usr/sbin/mkswap -L zram0 /dev/zram0", TAG+="systemd"

Add the device to /etc/fstab. Additionally, we can give the pri=value as an option to the swap entry:

$ sudo -i
$ [sudo] password for **my username**:
$ root@yourmachinename:~# printf "/dev/zram0\tnone\tswap\tdefaults,pri=100\t0\t0\n" >> /etc/fstab
$ root@yourmachinename:~# tail /etc/fstab # to check the output.

Reboot and verify that the swap device is active:

$ history | tail -n 2
$ swapon

Lower the pressure on the inode cache

If your PC has has enough free RAM available, you can also achieve a little more performance by lowering the tendency on reclaiming the memory which is used for caching of directory and inode objects.

Warning, clearing cache less frequently can impact new processes trying to load (bad_address or address_in_use).

Open your terminal and type:

$ gedit admin:///etc/sysctl.conf

Our text editor opens. Add following lines to the config file:

# Customize cache management
vm.vfs_cache_pressure=50

and save. This setting will be activated after rebooting your computer.

These are just some tips I think are useful. Should something be missing or you have an item that belongs in this list, please let me know by mail.

Ref: Web: zram: Compressed RAM based block devices - Kernel.org.

To-do's when upgrading Ubuntu EOL 20.10 to 22.04.1

Warning for non-experienced users

General recommendation from Canonical is making a backup and re-install your system should you run a non-secure EOL release. Their advice is sound and often proves to be the safest way. So, if you still decide to give my post a try, don’t dare yelling at me when your system goes bonkers. I told you so.

List of commands

$ sudo apt-get update                   
[sudo] password for lgeurts:
# You should see output similar to this.
E: The repository 'http://old-releases.ubuntu.com/ubuntu groovy Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://old-releases.ubuntu.com/ubuntu groovy-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://old-releases.ubuntu.com/ubuntu groovy-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

# Next test, spewing more jibberish.
$ sudo do-release-upgrade
Please install all available updates for your release before upgrading.

# Clean the apt cache.
$ sudo rm -rf /var/lib/apt/lists/*

# Remove old kernels and all automatically installed dependencies that are no longer needed by any package.
$ sudo apt --purge autoremove

# Replace entries in sources files. 
$ sudo sed -i "s/old-releases/archive/g" /etc/apt/sources.list /etc/apt/sources.list.d/*.list

# These 3 echo commands are for making sure you really have the correct entries even the above should have done the trick.
# Can also use any editor you want if that makes you feel more comfy.
$ echo "[deb http://old-releases.ubuntu.com/ubuntu/ groovy main restricted universe multiverse]" | sudo tee -a /etc/apt/sources.list
$ echo "[deb http://old-releases.ubuntu.com/ubuntu/ groovy-updates main restricted universe multiverse]" | sudo tee -a /etc/apt/sources.list
$ echo "[deb http://old-releases.ubuntu.com/ubuntu/ groovy-security main restricted universe multiverse]" | sudo tee -a /etc/apt/sources.list

# Kick it.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade # do-release does this again.
$ sudo apt install update-manager-core
$ sudo do-release-upgrade

Final remarks

When finished, clean up (sudo apt autoclean | sudo apt autoremove), check those non apt installed apps, and renew your custom PPAs.

The advantage of serverless computing for CIOs & CFOs

Back in the days, a company had to buy expensive physical servers, set those up somewhere in rooms that were outfitted with peripheral subsystems for cooling, ventilation, fire suppression, etc., and then configure each server in order to run their applications. They also had to hire engineers to maintain these bare-metal servers and troubleshoot any issues that could occur along the way.

This entire process of deploying servers, or any other devices, could take days to complete, and required properly allocating capacity since you can’t dynamically add and remove CPUs, RAM, disks, etc. For those living on the bleeding edge the server-based model often proved to be quite inconvenient, very labor-intensive, and entailing high costs (CAPEX vs OPEX).

Starting 2016, cloud computing ushered the era of on-demand virtual machines that you can use to launch online solutions in a matter of minutes instead days or weeks. A bare-metal server runs the host OS and a virtualization layer which produces tens or hundreds of virtual machines. This pool of virtual machines is sharing the CPU cores, RAM, network bandwidth, and disks that are attached to the host computer.

Since a VM has its own OS, it also has its own kernel which provides for a secure boundary over other VMs running in our host computer. It takes time to launch all of these instances due to the different components that the hypervisor must virtualize and allocate. Moreover, you will have to pay the costs of running your VMs, including idling time when a resource isn’t used at all. And let’s not forget that virtual machines are running a guest operating system that needs updates.

Next step was a smaller virtualized entity called container (Docker, Kubernetes pods). Containers share the physical server’s OS system kernel but do not run a guest OS with its own kernel, unlike a VM. They are primarily used to virtualize and run application libraries and dependencies.

Although a container provides a significantly reduced startup time over a VM, it still has operating costs that you have to cover. The burden of paying active and idle time remains, even if no one is using your containerized application at all.

This is where serverless kicks in. Serverless is in essence a combo of a VM and a container, but in contrast to containerization, serverless uses a small optimized kernel virtualized on top of a kernel-based virtual machine (MicroVM).

Serverless let’s you run code, manage data, even integrate business applications without managing any servers because the CSP will handle these tasks for you.

Speaking about fees, in contrast with VMs and/or containers, serverless services don’t run continuously. A serverless setup will only start when it is invoked, and will afterwards release all computing capacity. This is the reason why serverless architectures are the most cost-effective since you don’t pay for idle time.