<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>编程沉思录</title><description>我们采集的只是石头，却必须始终仰望着未来的大教堂。</description><link>https://cyhone.com/</link><item><title>「Nabeel S. Qureshi」</title><link>https://cyhone.com/posts/fermi-estimation/</link><guid isPermaLink="true">https://cyhone.com/posts/fermi-estimation/</guid><description>养成**费米估算**的习惯，主动查证关键数据，并运用上下限分析法。我注意到许多我认识的最聪明的人都会这样做：他们不会轻信任何说辞，而是自行验证其合理性。例如，听到某个事实时，他们会亲自查证以确保属实 —— 因为人们引用的内容常常存在虚假或片面性。

大多数人根本不这样做 —— 他们不进行 **“量化思考”**，结果很容易上当受骗。推特上时不时会流行这样的梗：“如果伊隆把造火箭的钱分给每个美国人，等</description><pubDate>Mon, 13 Jul 2026 10:00:00 GMT</pubDate></item><item><title>用 AI 做会议纪要为什么是 AI 转型最大的坑</title><link>https://cyhone.com/posts/mp-weixin-qq-com-s-b911pjswrve7jzdq-gskrq/</link><guid isPermaLink="true">https://cyhone.com/posts/mp-weixin-qq-com-s-b911pjswrve7jzdq-gskrq/</guid><description>1970 年，波音就已经引入了 CAD 电脑画图。但交付给下个部门的时候，却是把结果打印出来，让下一个部门的人用眼睛读、用脑子理解、再靠脑子去执行。

星巴克的咖啡师做咖啡的速度提高 100 倍，星巴克未必能多赚很多钱。星巴克的瓶颈不在做咖啡的速度，在于客流、选址、供应链管理。


同理，你们公司的瓶颈，大概率也不在于每个员工手头的任务完成速度。而在于部门和部门之间的信息流动，在于协调层。

那个</description><pubDate>Thu, 25 Jun 2026 18:08:04 GMT</pubDate></item><item><title>走近费曼丛书：别逗了，费曼先生！</title><link>https://cyhone.com/posts/weread-qq-com-web-reader-cd732d70718db043cd73bb3/</link><guid isPermaLink="true">https://cyhone.com/posts/weread-qq-com-web-reader-cd732d70718db043cd73bb3/</guid><description>&gt; 我在那些爸爸们中间坐了一会儿，但很快就烦了他们。全部的爸爸都是带着女儿来参加这个可爱的小小宴会的，但他们都在讨论股票的事儿——他们不知道怎么和自己的孩子说话，更不知道怎么和孩子的朋友们说话。



&gt; 别人认为你应该达到什么造诣，但你没有责任来满足他们的想当然。我没有责任成为他们指望我成为的东西。错误是他们犯下的；我无能，与此无关。
&gt; 
&gt; “高等研究院”以为我有那么好，就我这方面而言，这和</description><pubDate>Thu, 25 Jun 2026 04:12:28 GMT</pubDate></item><item><title>费曼经典：一个好奇者的探险人生</title><link>https://cyhone.com/posts/feiman-jingdian/</link><guid isPermaLink="true">https://cyhone.com/posts/feiman-jingdian/</guid><description>* 当我发现圣诞老人并不存在时，我没有感到难过，反而释然了，&lt;mark class=&quot;hl-yellow&quot;&gt;原来有一个更简单的说法可以解释为什么全世界那么多孩子会在同一天夜里收到礼物&lt;/mark&gt;。之前的故事太复杂了，我快想不透了

* 这是我从我父亲那里学来的：不尊重任何权威；不要管话是谁说的，但要关注他说的条件是什么，结论又是什么，然后问自己：“这合理吗”

&lt;!--more--&gt;
---

</description><pubDate>Wed, 24 Jun 2026 13:26:28 GMT</pubDate></item><item><title>微信读书 Skill 到底有多少花活?</title><link>https://cyhone.com/posts/weixin-reading-skill/</link><guid isPermaLink="true">https://cyhone.com/posts/weixin-reading-skill/</guid><description>* 基于我划线最密集、最认同的这 3 本书的核心主张，帮我找出与其观点完全对立、批判最狠的 5 本硬核书籍，给我做一次认知压力测试。
* 假设我以当前的阅读结构和速率继续读 5 年，推演那时的我会变成什么样的人，会形成哪些固化偏见，产生哪些知识盲区，错过哪些真正重要的问题，并指出现在必须立刻插入哪 5 本反向修正书来避免那个未来。
* 在我读过的所有书里，按现在的我重读它获得的认知增量最大排序，给</description><pubDate>Tue, 23 Jun 2026 12:36:39 GMT</pubDate></item><item><title>「《蝙蝠侠》」</title><link>https://cyhone.com/posts/what-i-do-defines-me/</link><guid isPermaLink="true">https://cyhone.com/posts/what-i-do-defines-me/</guid><description>&gt; 定义你的，不是你的本质，而是你的所作所为。

&lt;!--more--&gt;

- 虽然我做了坏事，但我内心是个好人。
- 是生活所迫，让我做了这个那个，但我本质上是这个那个，现在不是真正的我。但依然有很多人为了面临更大压力的时候也从未妥协。选择妥协的那个，就是真正的你</description><pubDate>Mon, 22 Jun 2026 10:00:48 GMT</pubDate></item><item><title>当 AI 拿走一切之后</title><link>https://cyhone.com/posts/ursb-me-posts-after-ai-takes-everything/</link><guid isPermaLink="true">https://cyhone.com/posts/ursb-me-posts-after-ai-takes-everything/</guid><description>* 一件事情，在大多数时候是没有确定性答案的。**认知不是从天上掉下来的，它是靠人不断推演、争论、交流，一点一点磨出来的——这个过程不能省略，因为这个过程就是人本身。** 如果认知直接由 AI 给到，且不论它是否全面、是否带着批判性，单是中间那段思考的缺席，就足以让主体性一寸一寸地退场，最后沦为珍妮机前面那个等待被淘汰的身影。
* 帕斯卡说，人是一根会思考的芦苇，宇宙无需武装就能碾碎他；但人依然比</description><pubDate>Wed, 17 Jun 2026 11:18:31 GMT</pubDate></item><item><title>Why I Don’t Vibe Code</title><link>https://cyhone.com/posts/jacobharr-is-personal-i-dont-vibe-code/</link><guid isPermaLink="true">https://cyhone.com/posts/jacobharr-is-personal-i-dont-vibe-code/</guid><description>* AI 的热潮确实让我想起早期低代码和无代码工具的突破。我不怀疑 AI 能成为开发者的有用工具，我知道有些任务它能作为更好的工具来辅助完成。但这些论点总让我再次思考偶然复杂性与本质复杂性的问题。

* 布鲁克斯在《没有银弹》一文中探讨了新工具对开发者生产力的影响。要像程序员一样思考，你必须理解现实世界的复杂性。编程最好被理解为在混乱的现实之上施加简化的表征——我们称之为_抽象_——通过降低复杂性</description><pubDate>Wed, 27 May 2026 04:11:29 GMT</pubDate></item><item><title>宝贵的人生建议</title><link>https://cyhone.com/posts/wisdom-i-wish-id-known-earlier/</link><guid isPermaLink="true">https://cyhone.com/posts/wisdom-i-wish-id-known-earlier/</guid><description>&gt; 养成习惯的好处是，在行动时，不必再进行内心的权衡。
&gt;
&gt; 不再消耗能量去思考是否要做这件事。
&gt;
&gt; 你只管去做。

---


&gt; 每个人都害羞。
&gt;
&gt; 其他人在等你做自我介绍；
&gt;
&gt; 他们在等你给他们发邮件；
&gt;
&gt; 他们在等你
&gt; 
&gt; 约他们出去。

&lt;!--more--&gt;

---

&gt; 探索还是优化？
&gt;
&gt; 你会优化你知道畅销的东西，还是探索新品？
&gt;
&gt; 在餐厅吃饭时，你</description><pubDate>Wed, 13 May 2026 19:25:00 GMT</pubDate></item><item><title>博客升级了~</title><link>https://cyhone.com/articles/blog-upgrade/</link><guid isPermaLink="true">https://cyhone.com/articles/blog-upgrade/</guid><description>基于Astro，从零重新实现</description><pubDate>Sat, 09 May 2026 13:30:19 GMT</pubDate></item><item><title>当我们在讨论 Harness 的时候，我们在讨论什么 | 深度对谈: Minimax × Hermes Agent - 十字路口Crossing | 小宇宙</title><link>https://cyhone.com/posts/xiaoyuzhoufm-com-episode-69e96b5b1e94ae6921ee3c2b/</link><guid isPermaLink="true">https://cyhone.com/posts/xiaoyuzhoufm-com-episode-69e96b5b1e94ae6921ee3c2b/</guid><description>* 在这样高密度、高复杂性的任务上，如果想 scale up, 那人在其中的占比一定要是少的，人只能是驾驭，否则这个效率就会很低，我们就做不出最有生产力最好的东西。
* 要改变视角，工作应该改造成以 ai 为中心，而非继续以人为中心。
* 不要想模型做不到，而且想模型能做到，我应该怎么配合模型做到。
* 如果一个 AI 公司不是以 AGI 为目标，那它就不应该存在。而 agent 是 AGI 之路</description><pubDate>Fri, 08 May 2026 21:37:29 GMT</pubDate></item><item><title>C++如何计算普通类型的 Hash 值：基于 gcc/clang 源码分析</title><link>https://cyhone.com/articles/hash-key/</link><guid isPermaLink="true">https://cyhone.com/articles/hash-key/</guid><description>当 int/long/float/指针/std::string 作为 `std::unordered_map` 的 key 时，C++底层是如何计算 hash 值的？

gcc/clang 作为使用最多的两种编译器和标准库，它们在这个问题的实现上略有差异。本文将基于二者的源码进行对比分析。
&lt;!--more--&gt;

## std::string
在深入讨论其他类型的 hash 实现之前，我们首先分</description><pubDate>Sat, 06 Sep 2025 21:08:06 GMT</pubDate></item><item><title>人要大量地表达自己</title><link>https://cyhone.com/posts/expression-yourself/</link><guid isPermaLink="true">https://cyhone.com/posts/expression-yourself/</guid><description>* 一方面，我越来越擅长自学，也养成了独立思考的能力；另一方面，我变得孤僻，不善与人建立连接。面对人群，我总是局促不安，不知如何表达真实的自己；我害怕袒露想法，总觉得无人理解，也无人愿意理解。

* 人必须与外部世界建立连接，而表达，就是这场连接中的第一道桥梁。
* 我才明白，表达不是可有可无的能力，而是一门人生的必修课

* 真正的表达，不是为了炫耀，也无关于技巧，而是一种自我的袒露。你越愿意将</description><pubDate>Wed, 20 Aug 2025 21:00:54 GMT</pubDate></item><item><title>People Die, but Long Live GitHub</title><link>https://cyhone.com/posts/long-live-github/</link><guid isPermaLink="true">https://cyhone.com/posts/long-live-github/</guid><description>如果你希望存储一段信息，让 100 年后的人也能访问，要怎么做？

三体中有类似的想法：如果人类灭亡，最好的保存文明的方式是什么？答案是：“刻在石头上”

但在一百年的时间尺度上，文章作者认为 GitHub 是存储信息的最好方式：

* Github 已经是全人类的互联网基础设施
* Git 能保存所有的 commit 历史
* Git 是分布式存储的，即使 Github 被黑客侵入数据丢失，只要</description><pubDate>Wed, 20 Aug 2025 21:00:52 GMT</pubDate></item><item><title>怎样当好一名师长</title><link>https://cyhone.com/posts/how-to-be-a-good-division-commander/</link><guid isPermaLink="true">https://cyhone.com/posts/how-to-be-a-good-division-commander/</guid><description>tk 教主分享在微博上的文章：&quot;粉丝群有人问有没有关于怎么带团队的书。我觉得把《怎样当好一名师长》看明白就够了。这也是我非常推崇的一篇文章。&quot;

1. 要勤快：应该自己干的事情一定要亲自过问，亲自动手。
2. 要摸清上级的意图：对上级的意图要真正理解，真正融会贯通，真正认识自己所领受的任务在战役、战斗全局中的地位和作用。这样，才能充分发挥自己的主观能动性，才能打破框框，有敢于和善于在新情况中找到新</description><pubDate>Wed, 20 Aug 2025 21:00:51 GMT</pubDate></item><item><title>「《武士建筑师》」</title><link>https://cyhone.com/posts/tadao-ando-creative-body/</link><guid isPermaLink="true">https://cyhone.com/posts/tadao-ando-creative-body/</guid><description>&gt; 要锻炼出创造性的身体，去看电影、听音乐会、去美术馆、看别人的建筑，然后要有想做得比他们更好的意愿，超越前人的勇气，体力衰退了，竞争意识就会变弱。没有了创造性的身体，竞争意识就没了。这两个是一回事，要同时锻炼身体和意志。</description><pubDate>Wed, 20 Aug 2025 21:00:49 GMT</pubDate></item><item><title>「沃兹尼亚克」</title><link>https://cyhone.com/posts/wozniak-happiness/</link><guid isPermaLink="true">https://cyhone.com/posts/wozniak-happiness/</guid><description>&gt; 我捐出了所有来自苹果的财富，因为财富和权力并非我的追求。我享受生活的乐趣——在我的出生地圣何塞，我资助了许多重要的博物馆和艺术团体，他们以我的名字命名了一条街道以示认可。如今我从事公开演讲并成为行业顶尖，虽然不清楚具体资产数额，但经过 20 年的演讲事业，可能积累了约 1000 万美元和几处房产。我从不寻找任何避税手段，通过劳动获得的收入缴纳约 55%的综合税负。我是世界上最快乐的人。对我而言</description><pubDate>Wed, 20 Aug 2025 21:00:48 GMT</pubDate></item><item><title>「贝索斯」</title><link>https://cyhone.com/posts/regret-minimization/</link><guid isPermaLink="true">https://cyhone.com/posts/regret-minimization/</guid><description>&gt; 我们做任何决定，最终都有可能会后悔会遗憾，但是面对多个选择时，我们应该选择让自己后悔或者遗憾最少的那个。</description><pubDate>Wed, 20 Aug 2025 21:00:47 GMT</pubDate></item><item><title>「tombkeeper」</title><link>https://cyhone.com/posts/tombkeeper-stock-market/</link><guid isPermaLink="true">https://cyhone.com/posts/tombkeeper-stock-market/</guid><description>&gt; 股市是世界上最可爱的东西。对于股市你可以随便怎么想，怎么想都可以，甚至觉得&quot;川大智胜&quot;和川普有关系都可以。
&gt;
&gt; 一切观点、一切想法都可以掏钱验证。如果你是对的，那就不光是对的，还能赚钱。所以如果你这么坚定地相信，就没道理不掏钱。除非，你其实也没那么相信。
&gt;
&gt; 社会是一个周期更长的股市。每个人最终都会在这个股市里得到和自己的想法相匹配的回报，一切想法也最终都会变成收益或亏损。而且社会这个</description><pubDate>Wed, 20 Aug 2025 21:00:46 GMT</pubDate></item><item><title>std::any 的性能开销：基于 libstd++ 源码分析</title><link>https://cyhone.com/articles/std-any/</link><guid isPermaLink="true">https://cyhone.com/articles/std-any/</guid><description>C++17 中引入了 `std::any`，可以非常方便地将任意类型的变量放到其中，做到安全的类型擦除。然而万物皆有代价，这种灵活性背后必然伴随着性能取舍。

std::any 的实现本身也并不复杂，本文将基于 [libstd++ 标准库源码](https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/an</description><pubDate>Tue, 04 Mar 2025 09:41:54 GMT</pubDate></item><item><title>从源码角度解读 enable_shared_from_this</title><link>https://cyhone.com/articles/enable_shared_from_this/</link><guid isPermaLink="true">https://cyhone.com/articles/enable_shared_from_this/</guid><description>我们在使用 C++ 的时候，有时会需要在类的内部获取自身的 shared_ptr，这就会用到 `std::enable_shared_from_this`。在实际使用过程中，`std::enable_shared_from_this` 有三个陷阱需要注意：
&lt;!--more--&gt;
1. 不能在构造函数中使用 shared_from_this(), 否则会抛出 std::bad_weak_ptr 异</description><pubDate>Fri, 03 Jan 2025 22:41:54 GMT</pubDate></item><item><title>Context的错误使用引发Panic的问题复盘</title><link>https://cyhone.com/articles/context-to-panic/</link><guid isPermaLink="true">https://cyhone.com/articles/context-to-panic/</guid><description>我们有这么一段业务代码，在 Gin 的 API Handler 中，开了一个子 goroutine 写 DB，代码大概是这样：
&lt;!--more--&gt;

```go
package main

import (
    &quot;github.com/gin-gonic/gin&quot;
    &quot;gorm.io/gorm&quot;
)

var db *gorm.DB

func ServerHandler(c *gi</description><pubDate>Mon, 06 May 2024 17:25:54 GMT</pubDate></item><item><title>Go 1.22 可能将改变 for 循环变量的语义</title><link>https://cyhone.com/articles/go-for-loop-var/</link><guid isPermaLink="true">https://cyhone.com/articles/go-for-loop-var/</guid><description>几乎世界上每个 Golang 程序员都踩过一遍 for 循环变量的坑，而这个坑的解决方案已经作为实验特性加入到了 Go 1.21 中，并且有望在 Go 1.22 中完全开放。
&lt;!--more--&gt;
举个例子，有这么段代码：
```go
var ids []*int
for i := 0; i &lt; 10; i++ {
	ids = append(ids, &amp;i)
}

for _, item :=</description><pubDate>Wed, 29 Nov 2023 13:05:01 GMT</pubDate></item><item><title>剖析Golang Bigcache的极致性能优化</title><link>https://cyhone.com/articles/bigcache/</link><guid isPermaLink="true">https://cyhone.com/articles/bigcache/</guid><description>[Bigcache](https://github.com/allegro/bigcache)是用Golang实现的本地内存缓存的开源库，主打的就是**可缓存数据量大，查询速度快。** 在其官方的介绍文章[《Writing a very fast cache service with millions of entries in Go》](https://blog.allegro.tech/201</description><pubDate>Sat, 25 Nov 2023 19:25:54 GMT</pubDate></item><item><title>解读 Golang 标准库里的 varint 实现</title><link>https://cyhone.com/articles/golang-varint/</link><guid isPermaLink="true">https://cyhone.com/articles/golang-varint/</guid><description>最近发现 Golang 标准库竟然自带了 varint 的实现，代码位置在 [encoding/binary/varint.go](https://github.com/golang/go/blob/go1.21.4/src/encoding/binary/varint.go)，这个跟protobuf里面的varint实现基本是一致的。刚好借助 golang 标准库的 varint 源码，我们来系</description><pubDate>Thu, 23 Nov 2023 12:10:19 GMT</pubDate></item><item><title>深度分析 Golang sync.Pool 底层原理</title><link>https://cyhone.com/articles/think-in-sync-pool/</link><guid isPermaLink="true">https://cyhone.com/articles/think-in-sync-pool/</guid><description>sync.Pool 是 Golang 内置的对象池技术，可用于缓存临时对象，以缓解因频繁建立临时对象带来的性能损耗以及对 GC 带来的压力。
&lt;!--more--&gt;

在许多知名的开源库中都可以看到 sync.Pool 的大量使用。例如，HTTP 框架 Gin 用 sync.Pool 来复用每个请求都会创建的 `gin.Context` 对象。 在 grpc-Go、kubernetes 等也都可以</description><pubDate>Sun, 18 Jul 2021 11:30:19 GMT</pubDate></item><item><title>os.Chmod 时到底用 777 还是 0777？</title><link>https://cyhone.com/articles/0777-or-777/</link><guid isPermaLink="true">https://cyhone.com/articles/0777-or-777/</guid><description>问题是这样的：我在代码里面调用了 `os.Chmod(&quot;test.txt&quot;, 777)`，希望把该文件的读写及执行权限对所有用户开放。
&lt;!--more--&gt;

执行完代码，顺手 ls 看了下。如下：
```shell
$ ls -l test.txt
-r----x--x  1 cyhone  1085706827  0 Jun 20 13:27 test.txt
```
结果出乎意料，不仅文件</description><pubDate>Sun, 20 Jun 2021 13:30:19 GMT</pubDate></item><item><title>一个 Gin 缓存中间件的设计与实现</title><link>https://cyhone.com/articles/gin-cache/</link><guid isPermaLink="true">https://cyhone.com/articles/gin-cache/</guid><description>我们在开发 HTTP Server 的时候，经常有对接口内容做缓存的需求。例如，对于某些热点内容，我们希望做 1 分钟内的缓存。短期内缓存相同内容不会对业务造成实质影响，同时也会降低系统的整体负载。
&lt;!--more--&gt;

有时我们需要把缓存逻辑放在 Server 内部，而非网关侧如 Nginx 等，是因为这样我们可以根据需要便捷地清除缓存，或者可以使用 Redis 等其他存储介质作为缓存后端。</description><pubDate>Mon, 14 Jun 2021 21:40:06 GMT</pubDate></item><item><title>高性能服务之优雅终止</title><link>https://cyhone.com/articles/service-graceful-shutdown/</link><guid isPermaLink="true">https://cyhone.com/articles/service-graceful-shutdown/</guid><description>「优雅终止」指的是当服务需要下线或者重启时，通过一些措施和手段，一方面能够让其他服务尽快的感知到当前服务的下线，另一方面也尽量减小对当前正在处理请求的影响。优雅终止可提升服务的高可用，减少下线造成的服务抖动，提升服务稳定性和用户体验。
&lt;!--more--&gt;

下线服务不仅仅是运维层面的工作，需要整个 RPC 实现、服务架构以及运维体系的配合，才能完美的实现服务的优雅下线。本文将基于服务下线的整个</description><pubDate>Thu, 18 Mar 2021 20:55:19 GMT</pubDate></item><item><title>一致性 Hash 原理及 GroupCache 源码分析</title><link>https://cyhone.com/articles/consistent-hash-of-groupcache/</link><guid isPermaLink="true">https://cyhone.com/articles/consistent-hash-of-groupcache/</guid><description>一致性 Hash 常用于缓解分布式缓存系统扩缩容节点时造成的缓存大量失效的问题。一致性 Hash 与其说是一种 Hash 算法，其实更像是一种负载均衡策略。
&lt;!--more--&gt;

GroupCache 是 golang 官方提供的一个分布式缓存库，其中包含了一个简单的一致性 Hash 的实现。其代码在 [github.com/golang/groupcache/consistenthash](</description><pubDate>Sun, 21 Feb 2021 11:55:19 GMT</pubDate></item><item><title>Golang sync.Cond 条件变量源码分析</title><link>https://cyhone.com/articles/golang-sync-cond/</link><guid isPermaLink="true">https://cyhone.com/articles/golang-sync-cond/</guid><description>sync.Cond 条件变量是 Golang 标准库 sync 包中的一个常用类。sync.Cond 往往被用在一个或一组 goroutine 等待某个条件成立后唤醒这样的场景，例如常见的生产者消费者场景。
&lt;!--more--&gt;

本文将基于 [go-1.13 的源码](https://github.com/golang/go/blob/release-branch.go1.13/src/syn</description><pubDate>Thu, 04 Feb 2021 22:55:19 GMT</pubDate></item><item><title>Golang WaitGroup 原理深度剖析</title><link>https://cyhone.com/articles/golang-waitgroup/</link><guid isPermaLink="true">https://cyhone.com/articles/golang-waitgroup/</guid><description>`sync.WaitGroup` 是 Golang 中常用的并发措施，我们可以用它来等待一批 Goroutine 结束。
&lt;!--more--&gt;

WaitGroup 的源码也非常简短，抛去注释外也就 100 行左右的代码。但即使是这 100 行代码，里面也有着关乎内存优化、并发安全考虑等各种性能优化手段。

本文将基于 [go-1.13 的源码](https://github.com/golan</description><pubDate>Sun, 17 Jan 2021 16:35:19 GMT</pubDate></item><item><title>Facebook 在 Golang 依赖注入的实现</title><link>https://cyhone.com/articles/facebookgo-inject/</link><guid isPermaLink="true">https://cyhone.com/articles/facebookgo-inject/</guid><description>依赖注入是一个经典的设计模式，可有效地解决项目中复杂的对象依赖关系。
&lt;!--more--&gt;

对于有反射功能的语言来说，实现依赖注入都比较方便一些。在 Golang 中有几个比较知名的依赖注入开源库，例如 [google/wire](https://github.com/google/wire)、[uber-go/dig](https://github.com/uber-go/dig) 以及 [</description><pubDate>Sat, 15 Aug 2020 16:00:06 GMT</pubDate></item><item><title>Golang 定时器底层实现深度剖析</title><link>https://cyhone.com/articles/analysis-of-golang-timer/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-golang-timer/</guid><description>本文将基于 Golang 源码对 Timer 的底层实现进行深度剖析。主要包含以下内容：
1. Timer 和 Ticker 在 Golang 中的底层实现细节，包括数据结构等选型。
2. 分析 `time.Sleep` 的实现细节，Golang 如何实现 Goroutine 的休眠。

注：**本文基于 go-1.13 源码进行分析**，而在 go 的 1.14 版本中，关于定时器的实现略有一些</description><pubDate>Fri, 19 Jun 2020 10:00:00 GMT</pubDate></item><item><title>Elasticsearch 学习：入门篇</title><link>https://cyhone.com/articles/introduction-of-elasticsearch/</link><guid isPermaLink="true">https://cyhone.com/articles/introduction-of-elasticsearch/</guid><description>Elasticsearch 是一个分布式搜索引擎，底层基于 Lucene 实现。Elasticsearch 屏蔽了 Lucene 的底层细节，提供了分布式特性，同时对外提供了 Restful API。Elasticsearch 以其易用性迅速赢得了许多用户，被用在网站搜索、日志分析等诸多方面。由于 ES 强大的横向扩展能力，甚至很多人也会直接把 ES 当做 NoSQL 来用。
&lt;!--more--</description><pubDate>Wed, 11 Mar 2020 13:00:54 GMT</pubDate></item><item><title>个人博客及公众号常用工具</title><link>https://cyhone.com/articles/blog-tools/</link><guid isPermaLink="true">https://cyhone.com/articles/blog-tools/</guid><description>本文整理和记录下自己在运营 [个人博客](cyhone.com) 以及公众号时常使用到的一些工具。主要包含以下方面：
1. 中英文空格的自动排版
2. 微信公众号如何使用 markdown 发布
3. 绘图工具
4. 图片压缩工具
5. 如何测试网站的打开速度以及针对性优化

&lt;!--more--&gt;
# 中英文排版及相关工具
在中英文排版最重要的就是中英文之间的空格，Github 有一个热门仓库《</description><pubDate>Sun, 08 Mar 2020 16:58:54 GMT</pubDate></item><item><title>Golang channel 源码深度剖析</title><link>https://cyhone.com/articles/analysis-of-golang-channel/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-golang-channel/</guid><description>channel 是 Golang 中一个非常重要的特性，也是 Golang CSP 并发模型的一个重要体现。简单来说就是，goroutine 之间可以通过 channel 进行通信。

channel 在 Golang 如此重要，在代码中使用频率非常高，以至于不得不好奇其内部实现。本文将基于 [go 1.13 的源码](https://github.com/golang/go/tree/relea</description><pubDate>Tue, 11 Feb 2020 04:45:00 GMT</pubDate></item><item><title>libco 的定时器实现：时间轮</title><link>https://cyhone.com/articles/time-wheel-in-libco/</link><guid isPermaLink="true">https://cyhone.com/articles/time-wheel-in-libco/</guid><description>定时器是网络框架中非常重要的组成部分，往往可以利用定时器做一些超时事件的判断或者定时清理任务等。
&lt;!--more--&gt;

定时器有许多经典高效的实现。例如，libevent 采用了最小堆实现定时器，redis 则结合自己场景直接使用了简单粗暴的双向链表。

时间轮也是一种非常经典的定时器实现方法。Linux 2.6 内核之前就采用了多级时间轮作为其低精度定时器的实现。而在微信的协程库 libco</description><pubDate>Sun, 15 Dec 2019 13:17:26 GMT</pubDate></item><item><title>FileBeat-Log 相关配置指南</title><link>https://cyhone.com/articles/usage-of-filebeat-log-config/</link><guid isPermaLink="true">https://cyhone.com/articles/usage-of-filebeat-log-config/</guid><description>本文主要介绍 Filebeat 7.5 版本中 Log 相关的各个配置项的含义以及其应用场景。

一般情况下，我们使用 log input 的方式如下，只需要指定一系列 paths 即可。
```yaml
filebeat.inputs:
- type: log
  paths:
    - /var/log/messages
    - /var/log/*.log
```
但其实除了基本的 p</description><pubDate>Tue, 26 Nov 2019 20:36:54 GMT</pubDate></item><item><title>Redis 事件循环器 (AE) 实现剖析</title><link>https://cyhone.com/articles/analysis-of-redis-ae/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-redis-ae/</guid><description>Redis 作为一个单线程高性能的内存缓存 Server 而被人熟知。作为一个典型的 Reactor 式网络应用，Redis 能够达到如此高的性能，必然要依靠足够可靠的事件循环库。
Redis 内置了一个高性能事件循环器，叫做 AE。其定义和实现可以在 `ae*.h/cpp` 这些文件中找到。

AE 本身就是 Redis 的一部分，所以整体设计原则就是够用就行。也正因为这个背景，AE 的代码才可</description><pubDate>Wed, 20 Nov 2019 11:16:54 GMT</pubDate></item><item><title>Elastic-Filebeat 实现原理剖析</title><link>https://cyhone.com/articles/analysis-of-filebeat/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-filebeat/</guid><description>Filebeat 是使用 Golang 实现的轻量型日志采集器，也是 Elasticsearch stack 里面的一员。本质上是一个 agent，可以安装在各个节点上，根据配置读取对应位置的日志，并上报到相应的地方去。

Filebeat 的可靠性很强，可以保证日志 At least once 的上报，同时也考虑了日志搜集中的各类问题，例如日志断点续读、文件名更改、日志 Truncated 等。</description><pubDate>Fri, 15 Nov 2019 02:55:00 GMT</pubDate></item><item><title>uber-go 漏桶限流器使用与原理分析</title><link>https://cyhone.com/articles/analysis-of-uber-go-ratelimit/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-uber-go-ratelimit/</guid><description>uber 在 Github 上开源了一套用于服务限流的 go 语言库 [ratelimit](https://github.com/uber-go/ratelimit/), 该组件基于 Leaky Bucket(漏桶) 实现。

我在之前写过一篇 [《Golang 限流器 time/rate 实现剖析》](https://www.cyhone.com/articles/analisys-of-go</description><pubDate>Sun, 10 Nov 2019 15:40:19 GMT</pubDate></item><item><title>Golang 标准库限流器 time/rate 实现剖析</title><link>https://cyhone.com/articles/analisys-of-golang-rate/</link><guid isPermaLink="true">https://cyhone.com/articles/analisys-of-golang-rate/</guid><description>限流器是微服务中必不缺少的一环，可以起到保护下游服务，防止服务过载等作用。上一篇文章 [《Golang 限流器 time/rate 使用介绍》](https://www.cyhone.com/articles/usage-of-golang-rate/) 简单介绍了 time/rate 的使用方法，本文则着重分析下其实现原理。建议在正式阅读本文之前，先阅读下上一篇文章。

上一篇文章讲到，time</description><pubDate>Tue, 05 Nov 2019 13:35:19 GMT</pubDate></item><item><title>Golang 标准库限流器 time/rate 使用介绍</title><link>https://cyhone.com/articles/usage-of-golang-rate/</link><guid isPermaLink="true">https://cyhone.com/articles/usage-of-golang-rate/</guid><description>&gt; 本主题为系列文章，分上下两篇。本文主要介绍 `time/rate` 的具体使用方法，另外一篇文章 [《Golang 限流器 time/rate 实现剖析》](https://www.cyhone.com/articles/analisys-of-golang-rate/) 则着重介绍其内部实现原理。

限流器是后台服务中的非常重要的组件，可以用来限制请求速率，保护服务，以免服务过载。
限流器的</description><pubDate>Sat, 02 Nov 2019 20:21:54 GMT</pubDate></item><item><title>微信 libco 协程库源码分析</title><link>https://cyhone.com/articles/analysis-of-libco/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-libco/</guid><description>libco 是微信后台开发和使用的协程库，同时也是极少数的直接将 C/C++ 协程运用到如此大规模的生产环境中的案例。

在 [《云风 coroutine 协程库源码分析》](http://www.cyhone.com/articles/analysis-of-cloudwu-coroutine/) 中，介绍了有栈协程的实现原理。相比云风的 coroutine，libco 在性能上号称可以调度千万</description><pubDate>Tue, 08 Oct 2019 17:58:26 GMT</pubDate></item><item><title>C++ 智能指针的正确使用方式</title><link>https://cyhone.com/articles/right-way-to-use-cpp-smart-pointer/</link><guid isPermaLink="true">https://cyhone.com/articles/right-way-to-use-cpp-smart-pointer/</guid><description>C++11 中推出了三种智能指针，unique_ptr、shared_ptr 和 weak_ptr，同时也将 auto_ptr 置为废弃 (deprecated)。
&lt;!--more--&gt;

但是在实际的使用过程中，很多人都会有这样的问题：
1. 不知道三种智能指针的具体使用场景
2. 无脑只使用 shared_ptr
3. 认为应该禁用 raw pointer(裸指针，即 Widget * 这种</description><pubDate>Sat, 05 Oct 2019 11:00:54 GMT</pubDate></item><item><title>C++ lambda 内 std::move 失效问题的思考</title><link>https://cyhone.com/articles/why-move-no-work-in-lambda/</link><guid isPermaLink="true">https://cyhone.com/articles/why-move-no-work-in-lambda/</guid><description>最近在写 C++ 时，有这样一个代码需求：在 lambda 中，将一个捕获参数 move 给另外一个变量。
看似一个很简单常规的操作，然而这个 move 动作却没有生效。

具体代码如下：

```cpp
std::vector&lt;int&gt; vec = {1,2,3};

auto func = [=](){
    auto vec2 = std::move(vec);
    std::cout</description><pubDate>Sun, 29 Sep 2019 18:07:00 GMT</pubDate></item><item><title>云风 coroutine 协程库源码分析</title><link>https://cyhone.com/articles/analysis-of-cloudwu-coroutine/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-cloudwu-coroutine/</guid><description>随着 Golang 的兴起，协程尤其是有栈协程 (stackful coroutine) 越来越受到程序员的关注。协程几乎成了程序员的一套必备技能。

云风实现了一套 [C 语言的协程库](https://github.com/cloudwu/coroutine/)，整体背景可以参考其 [博客](https://blog.codingnow.com/2012/07/c_coroutine.html</description><pubDate>Thu, 19 Sep 2019 14:26:19 GMT</pubDate></item><item><title>WebSocket 订单推送稳定性优化方案</title><link>https://cyhone.com/articles/optimization-of-websocket-push-system/</link><guid isPermaLink="true">https://cyhone.com/articles/optimization-of-websocket-push-system/</guid><description>[微信云支付 Android 智能 POS](https://cloud.tencent.com/document/product/569/33102) 使用 WebSocket 实现了用户订单的实时推送。即，顾客在扫描了门店的付款码，客户端会随即进行语音播报和打印等动作。
&lt;!--more--&gt;

客户端利用 WebSocket 与后端维持长连接，当后端收到该门店订单时，即将成功态的订单通过对应</description><pubDate>Sat, 17 Aug 2019 14:36:12 GMT</pubDate></item><item><title>深入理解网络 IO 模型</title><link>https://cyhone.com/articles/reunderstanding-of-non-blocking-io/</link><guid isPermaLink="true">https://cyhone.com/articles/reunderstanding-of-non-blocking-io/</guid><description>在进行 Linux 网络编程开发的时候，免不了会涉及到 IO 模型的讨论。《Unix 网络编程》一书中提到的几种 IO 模型，我们在开发过程中，讨论最多的应该就是三种： ` 阻塞 IO`、` 非阻塞 IO` 以及 ` 异步 IO`。

本文试图理清楚几种 IO 模型的根本性区别，同时分析了为什么在 Linux 网络编程中最好要用非阻塞式 IO。
&lt;!--more--&gt;

# 网络 IO 概念准备
</description><pubDate>Sun, 04 Nov 2018 02:50:00 GMT</pubDate></item><item><title>客户端秒级时间同步方案</title><link>https://cyhone.com/articles/client-time-calibration/</link><guid isPermaLink="true">https://cyhone.com/articles/client-time-calibration/</guid><description>在客户端开发中，往往会有一些功能对时间要求比较严格，客户端需要获取到当前最准确的时间。但由于客户端环境多种多样，我们无法保证直接在客户端设备上获取到的时间是最准确的时间。
对于某些问题设备来说，设备时间与比当前实际的时间差了几个小时，甚至几天的情况都存在。倘若某功能依赖于当前时间，而客户端所提供的时间不准，就往往会给客户造成一些困扰。

那么，客户端如何能够获取到当前最准确的时间呢？
&lt;!--mo</description><pubDate>Thu, 25 Oct 2018 20:08:06 GMT</pubDate></item><item><title>muduo 源码剖析</title><link>https://cyhone.com/articles/analysis-of-muduo/</link><guid isPermaLink="true">https://cyhone.com/articles/analysis-of-muduo/</guid><description>[muduo](https://github.com/chenshuo/muduo)是 [陈硕](http://chenshuo.com) 大神个人开发的 C++ 的 TCP 网络编程库。muduo 基于 Reactor 模式实现，Reactor 模式也是目前大多数 Linux 端高性能网络编程框架和网络应用所选择的主要架构，例如 Redis 和 Java 的 Netty 库等。

陈硕的《Lin</description><pubDate>Tue, 12 Jun 2018 23:51:37 GMT</pubDate></item><item><title>自动生成数据库文档小工具的诞生</title><link>https://cyhone.com/articles/db-doc-generator/</link><guid isPermaLink="true">https://cyhone.com/articles/db-doc-generator/</guid><description>最近我用 Golang 开发了一个可以将数据库每张表的各个列信息转化成文档的小工具。开发的缘由是因为写后端时，经常需要为数据库写说明文档，对于稍微有些规模的项目来说，就动辄几十张上百张数据表，开发人员在文档中不断的写各个列的列名、类型、描述实在是无聊、枯燥和苦不堪言。所以就有了这个小工具的诞生。

项目地址在 [这里](https://github.com/chenyahui/db_doc_gen</description><pubDate>Tue, 30 Jan 2018 19:00:54 GMT</pubDate></item><item><title>ClassViewer 的介绍及实现</title><link>https://cyhone.com/articles/classviewer/</link><guid isPermaLink="true">https://cyhone.com/articles/classviewer/</guid><description>[ClassViewer](https://chenyahui.github.io/ClassViewer)是我最近开发的一个用于展示 jvm class 字节码的小工具。它是一个单纯的静态网页，完全使用浏览器端的 Javascript 开发。之所以开发这款工具，是因为我在开发 [ToyJVM](https://github.com/chenyahui/ToyJVM) 的时候，需要常常校验 cla</description><pubDate>Mon, 01 Jan 2018 11:45:00 GMT</pubDate></item><item><title>首次半马记</title><link>https://cyhone.com/articles/my-first-half-marathon/</link><guid isPermaLink="true">https://cyhone.com/articles/my-first-half-marathon/</guid><description>4 月 9 号，在武汉参加了人生第一次半程马拉松，风里雨里的 21.0975 公里。虽然已时隔一周，但想到那天一路的奔跑、疲惫、欣喜，还是想记记这半马的流水账。
&lt;!--more--&gt;

# 赛前训练
关于赛前训练这一块，我自己真的是非常的汗颜，被自己的记性给坑了一把。本来 4 月 9 号的马拉松，硬是记成了 5 月 9 号。所以本来安排的提前 1 个月训练半马，也恰好完美地错过。汉马马拉松官网提</description><pubDate>Mon, 17 Apr 2017 22:20:47 GMT</pubDate></item><item><title>结合 Guava 源码解读布隆过滤器</title><link>https://cyhone.com/articles/introduction-of-bloomfilter/</link><guid isPermaLink="true">https://cyhone.com/articles/introduction-of-bloomfilter/</guid><description>&gt; BloomFilter（布隆过滤器）是一种可以高效地判断元素是否在某个集合中的算法。

在很多日常场景中，都大量存在着布隆过滤器的应用。例如：检查单词是否拼写正确、网络爬虫的 URL 去重、黑名单检验，微博中昵称不能重复的检测等。
&lt;!-- more --&gt;


在工业界中，Google 著名的分布式数据库 BigTable 也用了布隆过滤器来查找不存在的行或列，以减少磁盘查找的 IO 次数；</description><pubDate>Tue, 07 Feb 2017 16:51:51 GMT</pubDate></item><item><title>服务器校园网登录验证解决方案</title><link>https://cyhone.com/articles/whu-cs-network-auth/</link><guid isPermaLink="true">https://cyhone.com/articles/whu-cs-network-auth/</guid><description>前两天把实验室的一台旧台式机装上了 Ubuntu Server，打算当作测试服务器使用着玩。
装上之后意识到一个严重的问题：实验室电脑连接外网时候需要打开浏览器输入学号进行认证。

&lt;!-- more --&gt;

而对于服务器版的 Ubuntu Server 来说只有黑乎乎的命令行界面。根本没有浏览器可以打开，所以网络认证就无从谈起。。

就在准备打算重装一个 Ubuntu Desktop 的时候，</description><pubDate>Sun, 25 Sep 2016 22:28:54 GMT</pubDate></item><item><title>第一篇博客</title><link>https://cyhone.com/articles/hello-world/</link><guid isPermaLink="true">https://cyhone.com/articles/hello-world/</guid><description>## 为什么会想到建立一个博客:
在此博客之前，我其实也用过新浪博客、CSDN、博客园，作为个人博客的载体，但对每个博客都并不是特别的满意。原因大概有下面几条：
+ 没有美观友好的支持代码。
+ 广告多。
+ 管理复杂，但可控性差。

目前该博客是使用 hexo+Next 主题 + Github 进行搭建。
事实上，当开始接触使用 hexo 时，我觉得满足了我对博客的诸多要求。我对它的为程序员而生</description><pubDate>Wed, 16 Sep 2015 16:08:06 GMT</pubDate></item></channel></rss>