The core Idea - Go Scheduler is a Key to an entire Go structure: std lib and an app architecture.
Long story short: I get into G/P/M model of the Go Scheduler, and found the back-bone model of the all Go programs: Separate Goroutine for each TCP connection. One Listening Goroutine with a "listening Socket", and bunch of others serving "connections Socket". Look at that model from the OS perspective and LRQ for P. Got aha moment of AUTO full-filling all CPU-cores with a Job and wrote the next post:
Eventually I feel the true Essence of Go
From the Scheduler mechanics I pick up the real essence of the TOOL - a server with multiple connections and automatic usage of all hardware-threads of a CPU cores. Only through the Scheduler I understood why the Go is really necessary. Go is a tool like an Axe, and I find what and how to chop wood by this axe. Go is a tool for creating a one executable file that starts well optimized server, and each connection to that server is handled by a light-weight UserSpace Thread.
The Idea of Go itself - to write a server that going to handle multiple TCP connections and automate the process of selecting next goroutine to be executed, and leaving for a while goroutines that stalled in waiting of Network response or any other kind of IPC activity. Here is a Root - to create a server where goroutine would handle a connection, and when to execute that goroutine the Go Runtime would decide, Scheduler if be precise.
This Idea become natural and could be literally touchable only after getting into the G/P/M model - where a Logical Processor P is an abstraction level between UserSpace Thread (a goroutine G) and OS Thread (M). Because each OS Thread M is halted/stopped when it waits for SystemCall to response, mean while P with it own G-swarm keep on "billowing". Thus Go - is a "swarm" or "club" of goroutings that pushed into CPU-cores by the Go Scheduler using P as middle slab abstraction of Logical Processor.
All essence of this model, all value of Go as a language is covered inside the Scheduler that allows bot NOT SO AWARE about how to handle new TCP connection cheap. As the algorithm minimize amount of expensive M (OS threads), substituting them by cheap G (Goroutines).
Go is not a modern C - how it use to be explained, Go is not a "Python". First of all Go is a cheap Goroutiens that are fit perfectly for serving HTTP requests. The aim of the Go is to reduce cost of a Concurrency Component on different platforms.
Uh... it was Tough! Love you mates. I love Go and William Kennedy and Kavya Joshi
Top comments (0)