A brief overview of the computer boot process

I didn’t see a computer for the first time until I was in sixth grade. The most surprising thing to me at that time was the long start-up process it took. It would scroll across the screen and display various letters that I did not know. When I went to university, as I was not a computer science student, I only studied operating systems and programming languages, but not the principles of computer composition systematically.

Should I use RESTful?

Many people involved in web development are no stranger to RESTful APIs. Different projects have a variety of different interface forms, some claiming to use RESTful, but not actually fully compliant with the specification, which makes me think, should we use the RESTful API style or not? As an example, I believe you have seen many APIs in the following style: Scenes Request Method Routing Get a list of users GET /getUserList Get information about a user GET /getUserInfo?

Regular matching using recursion

A long time ago I read Brain’s article on how to write elegant code. In it, the author tells the story of Rob Pike, who implemented a simple regular matching function in a little over an hour, with just over 30 lines of code plus comments, and whose implementation is not only simple and elegant, but also demonstrates the power of recursive functions and pointers. Today, I’d like to share my understanding of it with you.

MPTCP: an overlooked new feature in Go 1.21

Go 1.21 will be released in two or three months, and many people have already summarised the new features in Go 1.21 to build up the momentum for the new Go release, but I haven’t seen anyone specifically cover one of the new features added to the net library in Go 1.21, so I’m dedicating a new article to it. There is a dedicated issue (#56539) to follow up and discuss this new feature of MPTCP.

async and await in Swift

This article is the first of my notes on Swift concurrent programming. It introduces the use and inner meaning of the async and await syntax keywords. async Methods that are modified with async are called asynchronous methods. The syntax is as follows: 1 2 3 func my_func() async { print("hello kanchuan.com") } If a method is both asynchronous and throwing, the async keyword needs to be written in front of the throws keyword.

A performance optimisation approach without code changes - PGO

Golang introduced PGO (Profile-guided optimization) in 1.20, which according to the official blog could achieve a 2%-7% performance improvement without changing the code. In the 1.21 Release Note, Golang upgraded this feature to GA and enabled PGO in its own builds, improving the performance of Golang’s own compiler by 2%-4%. PGO itself is a compiler optimisation approach, not language specific, and Golang has only very tentatively applied PGO so far; this article will explore how PGO works, possible optimisations, and an example of using PGO to optimise the Linux Kernel.

Go Developer's Guide to Using Apache Arrow: Data Types

1. Introduction to the Arrow Project According to the official description of the Arrow project: “Apache Arrow is a development platform for in-memory analytics. It contains a set of technologies that enable big data systems to process and move data quickly. It specifies a standardised language-independent columnar in-memory format for flat and hierarchical data, organised with efficient analytical operations for data on modern hardware in mind”. Apache Arrow has written a programming language-independent in-memory format specification (currently at v1.

Automatic core dump when Golang program crashes

I ran into a problem a while ago, the program somehow crashed and the stack didn’t show anything. Today, I changed a parameter to make the golang program core dump when it crashes. In fact, the core is to add an environment variable, GOTRACEBACK=1. But there are some other system-related issues, which I will briefly document in this article. After Golang 1.6, there have been some changes to the optional values of this environment variable, the new values are as follows:

Sleep and hibernation for Windows and MacOS

Usually I would stuff my laptop straight into my school bag when I left work. Sometimes I’d get it out when I got home and find it very hot, giving me the impression that the computer kept running even after the lid was closed, so I spent time researching the sleep and hibernation mechanisms under Windows. The official description of sleep and hibernation states Sleep Sleep uses very little power,

OrderedMap in golang

As we know, Go’s built-in map type does not maintain the order of insertion of elements, and is deliberately set to random when traversing. Therefore, if we want to keep the map in the order in which the elements are inserted, we need to use a third party library, and today we will introduce you to one such library, OrderedMap. In fact, there are similar data structures in other programming languages, such as LinkedHashMap in java and OrderedDict in python.

Debian 11 Bullseye Upgrade Debian 12 Bookworm

This article will guide you on how to upgrade Debian 11 Bullseye to Debian 12 Bookworm. Preparation Unless you are a physical server, and a KVM-built VPS and cloud host that has not used an oddly customized or modified kernel, there is a chance that upgrading to a major kernel update will cause Grub to fail to load, so remember to back up your important data! OpenVZ 6 and LXC architecture VPS cannot be upgraded because they do not have their own independent kernel.

Using cuda in a container

Using cuda in containers requires nvidia-container-toolkit in addition to newer drivers, an available container runtime (podman, docker, etc.). 1 2 pacman -S podman paru -S nvidia-container-toolkit Generate a CDI description file: 1 nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml You can then pull a cuda image and test whether cuda is available: 1 podman run --rm --device nvidia.com/gpu=all docker.io/nvidia/cuda nvidia-smi -L The installation logic outlined above is described in the Installation Guide - NVIDIA Cloud Native Technologies documentation, please refer to it for details.

Debian 12 / Ubuntu 22.04 Setting up SSH RSA KEY

This article will guide you on how to enable RSA Key login for SSH in Debian 12 and Ubuntu 22.04. Since OpenSSH 8.3, RSA Key login has been disabled by default and is considered insecure. So starting with Ubuntu 22.04 and Debian 12, if you need to use RSA Key login, you will need to enable it manually. Enabling RSA Key login Instead of modifying /etc/ssh/sshd_config, which is the default SSH configuration file, we just need to add a /etc/ssh/sshd_config.

Quickly building a Kubernetes development environment with Colima

When learning a new technology project, one of the most troublesome aspects is how to quickly install the relevant environment so that your teammates can get started quickly. Learning Kubernetes is no exception. To build a Kubernetes development environment in a local environment, you need to install Docker, Kubernetes, Minikube, Kubectl and other related tools, all of which are tedious to install and configure, and prone to errors. Is there a quick way to bypass these and quickly build a Kubernetes development environment on your own computer?

Make sync.Map support generic

Gradually, Go generics are being used more and more in Go’s standard library. Some standard library types such as container/heap, container/list, container/ring and math have the opportunity to support generics, but given Go’s backwards compatibility, these packages will probably not be modified directly, but will most likely be new concurrent packages, or placed in extension packages. This article will cover a relatively complex example, a modification to sync.Map that allows it to support generics.

Live Reload Practices in Golang Development

1. Live Reload vs Hot Reload When developing with Visual Studio Code as an IDE, hot reloading can be achieved with cosmtrek/air. air itself is a development aid implemented in Golang and its main features include listening for changes to files in the application folder and restarting the application customisation via configuration files the ability to set files to be ignored and other helper options The installation of the Air is fairly simple.

Golang control flow statements

In high-level programming languages, a control-flow statement is a class of statements used to control the flow of program execution, hereafter referred to as control statements. They can execute corresponding blocks of code according to conditions or loops, or jump to specified locations to execute code. Common control statements include: Conditional statements: execute different blocks of code according to conditions, such as if statements, switch statements, etc. Loop statements: Repeatedly execute the corresponding block of code according to the condition, such as for statement, while statement, etc.

Sockmap in Linux TCP

Sockmap is a tool for socket stitching on Linux that can reverse proxy traffic to other destinations directly in the kernel, without going through the application layer, which is an interesting and interesting application to explore for highly loaded web proxy applications. The reason for the name sockmap is that in eBPF, the data structure for passing data is called a Map. eBPF provides many maps, but sockmap is a relatively new one, created by John Fastabend, an engineer at Cilium.

Understanding the Timeline of a Time-Series Database

In today’s age of data explosion, time-series data have become an integral part of businesses and organisations. They include vast amounts of data from a variety of sources such as sensors, monitoring devices, logging systems and financial transactions, which are arranged chronologically and record the occurrence and changes of various events and activities. The analysis and processing of time-series data is critical to business decisions and operational efficiency in an organisation.

View the log before the pod crashes

When the pod is in a crash state, the container keeps restarting and the kubelet logs may not capture the logs. Workaround: The kubectl previous parameter works: If true, print the logs for the previous instance of the container in a pod if it exists. Single-container pods: 1 kubectl logs pod-name --previous Multi-container pods: 1 kubectl logs pod-name --previous -c container-name For example: 1 2 3 4 5 NAME READY