I gave a talk about performance profiling in golang, the 5th November in Paris, at La paillasse, organized by the Golang Paris meetup.
I really like performance subjects in Golang, as you may have seen in some previous publications.
Slides (link) :
Thomas Solignac
Entrepreneur – Cofounder at Golem.ai (Paris, France)
I enjoy sharing Golang interesting patterns, experiments and tips.… Read more
Author: Thomas Solignac
Entrepreneur – Cofounder at Golem.ai (Paris, France)
I enjoy sharing Golang interesting patterns, experiments and tips.
2 tricky behaviors of “defer”
When discovering Golang, “defer” seems at first a little exotic.
Here is 2 situations with no obvious behavior. …
Here is 2 situations with no obvious behavior. …
Function calling a function in defer
If you want to time a function, at first sight, that may be a good idea to do :package main import ( "fmt" "time" ) func main() { start := time.Now() defer fmt.Println(time.Since(start)) time.Sleep(100 * time.Millisecond) }and… wrong.… Read more
2 gotchas about string, runes and slices
Even after practicing Golang for years, I can be surprised by some elementary features.
Today, I fixed a bug by taking cognizance of two peculiarities of Golang. Let me tell you. …
Today, I fixed a bug by taking cognizance of two peculiarities of Golang. Let me tell you. …
Size of a string
If you don’t work with special characters, that may not interest you.… Read moreWhy you should teach Go
I have been teaching programming for a while, and recently, I started teaching to web students.
After a few months of teaching, I proposed to add Go to the program. And it’s not because I want them to be Go programmers.… Read more
After a few months of teaching, I proposed to add Go to the program. And it’s not because I want them to be Go programmers.… Read more
Add Websocket to your TCP service with minimal changes
Offer your users the possibility to connect by websocket ! It allows them to use your service from javascript code :
* Javascript is very popular and lets you build prototypes very quickly
* It’s more easy to build a GUI with HTML than most desktop languages
* You can offer a true demonstration of your service directly on your website and… let me convince you that it’s very low-cost.… Read more
* It’s more easy to build a GUI with HTML than most desktop languages
* You can offer a true demonstration of your service directly on your website and… let me convince you that it’s very low-cost.… Read more
Network proxy in 20 lines
Authentication, load balancing… You need a proxy ? Let’s do it in an idiomatic way.
It’s surprisingly easy ! …
1- The User connects to the Proxy
2- The Proxy connects to the Server
3- The Proxy sent messages from the Client to the Server, and from the Server to the Client (transparently) We don’t speak about the specific treatment of the proxy (authentication, load balancing …) you wish to do.… Read more
It’s surprisingly easy ! …
Needs
We need to handle 2 connections : the User and the Server. Story :1- The User connects to the Proxy
2- The Proxy connects to the Server
3- The Proxy sent messages from the Client to the Server, and from the Server to the Client (transparently) We don’t speak about the specific treatment of the proxy (authentication, load balancing …) you wish to do.… Read more
Regexp : Presentation, optimization, goroutines
Golang has it own regexp implementation. It’s really useful to check syntax and extract values in just few lines. Let’s take a look !
…
-Name : john
-Domain : travolta
-Extension : com 1.… Read more
Basic example : Parsing an email
john@travolta.comLet’s catch :
-Name : john
-Domain : travolta
-Extension : com 1.… Read more
Understand CPU profiling graph
The CPU profiler provides very interesting graphs. However, they contain more information than it seems at first sight.
…
It means that your software is randomly stopped every X ms (it’s the frequency), and the profiler save in which function you are.… Read more
How does it works ? About sampling
The golang CPU profiling produce metrics by sampling.It means that your software is randomly stopped every X ms (it’s the frequency), and the profiler save in which function you are.… Read more
Unmarshal JSON to non-empty interface
When you’re filling a struct by calling :
json.Unmarshal(buff, &yourStruct)It is not uncommon that your struct contains a non-empty interface.
type IElement interface { GetBody() string } type Message struct { Name string Provider string Elements []IElement }And of course, json.Unmarshal can’t automatically find matching structs to fill that []IElement.… Read more