ARTS week 1
Algo
https://leetcode.com/problems/number-of-islands/
Simple DFS with a visited matrix, written in golang
Review
https://medium.com/naukri-engineering/garbage-collection-in-elasticsearch-and-the-g1gc-16b79a447181
Chose this article because it does a benchmark of G1GC (a new java gc impl) with ElasticSearch which demonstrated some promising stuff of G1GC.
A bit more context of this article, if you have worked with ElasticSearch, or if you have written enterprise Java code, hopefully you should already share the headache caused by GC. In production, even a short 2~3 seconds STW triggered by full GC can cause you some non-trivial problems because it essentially pauses your service while collecting garbage.
In case of ElasticSearch, I've seen STW causes a query to timeout, which gets propagated all the way up to api gateway, in this situation, if your services do not have proper timeout/circuit/retry protection, it could end up with something commonly referred to as an avalanche, where increasing large amount of threads / goroutines hang there waiting for slow queries to complete, causing resource spikes and even service outage if you are unlucky :)
This is why I'm personally very interested to see if better GC can be done for ElasticSearch. From this article, it looks like G1GC is now compatible with ES (previously there was some incompatibility with lucene), and GCG1 has an observable gain on GC pauses, at the cost of slightly increased CPU. Good stuff.
Tip
分享一个golang UT coverage的command alias, 它会跑当前目录下所有的testcase并生成一个带有coverage的html并打开,写UT的时候非常handy.
Share
https://www.infoq.cn/article/qzrGhlzq_HikN10xC5jC 聊到了学习Go时需要扭转的几个思维. 对于长期活在java c#世界中的人来说可能非常有意思.
评论