Copy hostname from chrome address bar rather than whole url

I often copy hostname from chrome address bar to shell, but it always with some prefix like “http://” . Search “chrome copy without http” in Google and you will 208,000,000 results, there is a bug reported in tracker but status is “Won’t fix”. Luckily some body developed this extension: https://chrome.google.com/webstore/detail/hostcopy/ebnjnkfienhcidbgmifkjkkidheihcpj there are some others has […]

colored tail -f with /var/log/messages

Vim has beautiful color profile for messages: But I usually use tail -f to monitor my logs, while it can not use vim color profile, so I installed grc. Clone and run ./install.sh, try grc tail -f /var/log/messages and you will see: Oh, that’s not what I want. Luckily grc can easyly customize profile, so […]

pyroute2 is not so fast

接上篇。 由于发现了 subprocess.popen() 的线程泄露问题,我们对这个调用加了线程锁,最简单的绕过这个问题,与此同时我将一些频繁调用的地方从 bash 调用改成 linux 系统调用(比如直接使用 read,而避免 bash 调用 cat),在很多场景有了不错的性能提升。 于是我怀疑 kvmagent 的一些性能问题和我们的 bash 的有些滥用有关系,我们知道 pyroute2 是直接调用 netlink 的,因此我做了这个测试: 可以看到 read 最快,bash+cat 次之,pyroute 居然最慢。 考虑到 pyroute 可能初始化的 workload 更大,我们可以试试先初始化好 import 和必要的初始化工作: so, pyroute2 is not so fast.

subprocess.popen() is not thread safe

这几天陆续一直在调查生产环境一个调用会随着时间的推移变得越来越慢的问题。 从好几个角度尝试解决,怀疑点众多,目前认为是 python 2.7 subprocess 的 bug,参考这里: https://stackoverflow.com/questions/21194380/is-subprocess-popen-not-thread-safe 和这里: https://github.com/google/python-subprocess32