### Antlr (Another Tool for Language Recognition)

Antlr是一个可以根据输入自动生成语法树并可视化的开源语法分析器，最近工作中有使用到，非常强大好用，所以简单做个介绍。

Antlr可以用在很多需要对输入语法做解析的场景，比如SQL的解析，Hive、Pig所使用的语言，Hibernate中HQL语言等等，它可以自动帮我们将输入的语言按照语法文件的定义去解析为AST抽象语法树，我们可以再去实现它生成的接口去进行相关AST处理的业务逻辑。

### 为什么Redis Pipline会这么快

##### It's not just a matter of RTT

Pipelining is not just a way to reduce the latency cost associated with the round trip time, it actually greatly improves the number of operations you can perform per second in a given Redis server. This is because without using pipelining, serving each command is very cheap from the point of view of accessing the data structures and producing the reply, but it is very costly from the point of view of doing the socket I/O. This involves calling the read() and write() syscall, that means going from user land to kernel land. The context switch is a huge speed penalty.

When pipelining is used, many commands are usually read with a single read() system call, and multiple replies are delivered with a single write() system call. Because of this, the number of total queries performed per second initially increases almost linearly with longer pipelines, and eventually reaches 10 times the baseline obtained without pipelining.

——西格蒙德.弗洛伊德

——爱丽丝.米勒

### 文章推荐

《火星救援》中你应该知道的5个高可用系统故障恢复原则

Metrics For Your Web Application's Dashboards

Finding Time to Become a Better Developer(寻找时间成为一名更优秀的程序员)

make it work, make it right, make it fast。这个是不错的口头禅但这里有一个陷阱：right并不意味着完美，fast也不是说越快越好。

Q.E.D.

Talk is cheap, show me the code.