Simple case of profiler usage in golang

So I was solving Construct Binary Tree from Inorder and Postorder Traversal and I got myself more less working solution that got accepted. But it was not the fastest one. But then I though — how do I profile buildTree function and see what actually takes time in my program? Golang has an excellent set of tool available, just check an output of go tool. One of the items in a list you’ll see is pprof which is a Golang profiler....

December 28, 2021 · 32 min · 6674 words

Notes on System Design

These are hectic notes on a book “System design interview” by Alex Xu. chapter 1 read-through cache strategy — check if we have a response cached, if we do return it, if not then fetch data from a database, cache it and return result GeoDNS is a patch for BIND DNS server software that allows for geographical split horizon A few words about caching strategy. Your caching strategy depends on your data access patterns....

October 30, 2021 · 10 min · 2039 words

Golang concurrency tricks and patterns

Concurrency is the composition of independently executing computations. Goroutines are not threads, but it is not wrong to think about goroutines as threads. In fact in runtime goroutines are multiplexed onto threads that are created as needed in order to make sure no goroutine ever blocks. Generator Multiplexer nil channel trick Worker pool Confinement Error handling Goroutines Generator. Function that returns never closed channel. Basically generate func returns unbuffered channel that is never closed and hence returns ever increasing counter....

September 4, 2021 · 6 min · 1240 words

Notes on 'Go in action' book

Slice takes 24 bit of memory — 8 bit for pointer, 8 for len and 8 for capacity. Passing a slice between functions is okay, since it is copied BUT in the copied version we still have the correct pointer. Reference types in Go: string slice map channel interface function The decision to use value or pointer receiver should not be based on whether method is mutating given value or not....

July 18, 2021 · 3 min · 456 words

Milestone notes

How it went: I did manage to escape sucky job at Pentalog. What a relief! My wife Tatiana was looking through local job ad board and found an ad for Go. I managed to land it, yay! It is an interesting project and I like it. Teams seems to be strong and much saner. There is a lot of stuff to do. And I’m writing Golang which is amazing! It is a little dream that came true....

December 31, 2020 · 2 min · 421 words