HTTP/1.1 vs. HTTP/2

HTTP 1.1 In January 1997, HTTP/1.1 version was released, only half a year later than version 1.0. It further improved the HTTP protocol and has been used to this day 20 years later, and is still the most popular version. Main optimization points: Support long connection by default HTTP/1.1 supports persistent connections and request pipelining. Persistent connections reuse established TCP connections and avoid repeating the RTT cost of the three-way handshake.

Inside Go's Channel Runtime

Channel is a very important type in the Go language and is the first object in Go. Through channels, Go implements memory sharing through communication. Channel is an important means of transferring data and synchronizing between multiple goroutines. Note: All source code analysis in this article is based on Go1.13.3. Different versions may have different implementations. channel syntax The syntax for declaring a channel is as follows:

Implementing the Raft Protocol in Go (1)

Introduction  The implementation idea comes from: MIT 6.824 course Lab 2: Raft  Before doing the experiment, you should read the raft paper carefully, here it is: raft paper raft translation Recommended reading: Students’ Guide to Raft Raft Understandable Distributed Consensus lab content  In this lab, you will implement most of the Raft design described in Extended Paper, including saving persistent state and reading it after a node fails and then restarts.

Translation: Contiguous Stacks

Contiguous stacks original address  Allocate a continuous stack memory space for each go coroutine. When the memory is used up, it will be reallocated/copied and grown. Why? The current stack splitting mechanism has a “hot split” problem - if the stack space is almost full, calling the function will trigger the forced allocation of a new stack block. When the calling function returns, the new stack block will be released.

Inside Go's Main Goroutine Scheduler (2)

9. Enter runtime/proc.go and scheduler initialization 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 func schedinit() { // raceinit must be the first call to race detector.

Why Is Quicksort Used More Often Than Merge Sort?

What is honey to you is arsenic to another. Quick sort: 1 2 3 * Worst-case time complexity: O(n^2) * Best-case time complexity: O(n log n) * Average time complexity: O(n log n) Merge sort: 1 * Worst-, best-, and average-case time complexity: O(n log n) Since the time complexity of merge sort is >= the time complexity of quick sort in different situations, why are the sorting algorithms we use in actual programming quick sort instead of merge sort?

Inside Go's Main Goroutine Scheduler (1)

Under the compilation, all traces are revealed. 1.go program entry_rt0_amd64_linux: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // The TEXT instruction defines the symbol _rt0_amd64_linux, the global data symbol is declared with DATA, and GLOBL defines the data as global. // SB SB virtual register: saves the starting address of the program address space; the value saved by this SB register is the starting address of the TEXT segment, which is mainly used to locate global symbols.