<feed xmlns="http://www.w3.org/2005/Atom"> <id>https://blog.antsmallant.top/</id><title>antsmallant</title><subtitle>记录游戏服务器开发、C++、Lua、数据库、网络与工程实践。</subtitle> <updated>2026-10-05T12:54:20+08:00</updated> <author> <name>antsmallant</name> <uri>https://blog.antsmallant.top/</uri> </author><link rel="self" type="application/atom+xml" href="https://blog.antsmallant.top/feed.xml"/><link rel="alternate" type="text/html" hreflang="zh-CN" href="https://blog.antsmallant.top/"/> <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator> <rights> © 2026 antsmallant </rights> <icon>/assets/img/favicons/favicon.ico</icon> <logo>/assets/img/favicons/favicon-96x96.png</logo> <entry><title>游戏服务器工程实践六：lua cpu 和 heap profiling</title><link href="https://blog.antsmallant.top/2026/10/03/gamesvr-practice-6-lua-profiling" rel="alternate" type="text/html" title="游戏服务器工程实践六：lua cpu 和 heap profiling" /><published>2026-10-03T00:00:00+08:00</published> <updated>2026-10-03T00:00:00+08:00</updated> <id>https://blog.antsmallant.top/2026/10/03/gamesvr-practice-6-lua-profiling</id> <content type="text/html" src="https://blog.antsmallant.top/2026/10/03/gamesvr-practice-6-lua-profiling" /> <author> <name>antsmallant</name> </author> <category term="游戏后端" /> <summary>游戏服务器时常需要做一些 profiling 工作，c/c++ 部分可以使用 gperftools（Google Performance Tools）进行 profiling，而 lua 并没有一个业界权威的工具，在 github 找到的也都不能满足我的要求。 于是我自己做了一个项目 https://github.com/antsmallant/luaprof，实现了想要的效果：开销低，又能相对精确地捕捉到较大的热点。 本文主要介绍 profiling 的机制，以及 luaprof 的功能和设计。luaprof 虽然大部分是 ai coding 出来的，但其思想是经过比较长期的摸索和实践才得来的，也在生产项目上得到了实践。对于大热点的采样挺准的，并且开销很低，远低于那种基于 tracing 机制的 profiling 库。 我们这里说 heap profiling，是比较精确的...</summary> </entry> <entry><title>游戏服务器工程实践五：业务逻辑的事务性</title><link href="https://blog.antsmallant.top/2026/08/15/gamesvr-practice-5-transactional-logic" rel="alternate" type="text/html" title="游戏服务器工程实践五：业务逻辑的事务性" /><published>2026-08-15T00:00:00+08:00</published> <updated>2026-08-15T00:00:00+08:00</updated> <id>https://blog.antsmallant.top/2026/08/15/gamesvr-practice-5-transactional-logic</id> <content type="text/html" src="https://blog.antsmallant.top/2026/08/15/gamesvr-practice-5-transactional-logic" /> <author> <name>antsmallant</name> </author> <category term="游戏后端" /> <summary>声明：gpt-6-sol 也参与了文章创作。 一、道具交易的事务性 游戏中的一些逻辑是需要有事务性的，否则会出现半完成状态。举个例子，玩家 A 用一件 X 换 B 的 100 金币。 如果是小规模数据，数据库事务的代价不高，那么数据库事务就可以解决问题了。但如果是大规模数据，数据库事务的代价太高，就要避免使用了。通常也不推荐使用数据库事务，往往一开始小规模的数据，到后面都可能变得庞大。这时候可以使用一种被称为 Saga 的分布式事务模型来实现事务。 Saga 并非什么缩写，而是来自于 1987 年 Hector Garcia-Molina 和 Kenneth Salem 提出的论文《Sagas》，名字借自北欧长篇英雄史诗。 Saga 将长事务分解为多个独立提交的子事务，并通过补偿处理失败情况[1]。在跨服务实现中，可以进一步区分可补偿步骤、不可取消的分界步骤和后续可重试步...</summary> </entry> <entry><title>游戏服务器工程实践四：可观测之prometheus+grafana+日志mcp</title><link href="https://blog.antsmallant.top/2026/04/25/gamesvr-practice-4-prometheus-grafana" rel="alternate" type="text/html" title="游戏服务器工程实践四：可观测之prometheus+grafana+日志mcp" /><published>2026-04-25T00:00:00+08:00</published> <updated>2026-04-25T00:00:00+08:00</updated> <id>https://blog.antsmallant.top/2026/04/25/gamesvr-practice-4-prometheus-grafana</id> <content type="text/html" src="https://blog.antsmallant.top/2026/04/25/gamesvr-practice-4-prometheus-grafana" /> <author> <name>antsmallant</name> </author> <category term="游戏后端" /> <summary>用 prometheus 做观测是大家都在做的事，关键是要对什么做观测，以及怎么做观测，以下总结一些实践。 1. 常见数据的观测 1.1 请求延迟数据的观测 可以统计几个项：延迟分布，avg延迟，最近请求量（总/成功/失败），请求QPS。 大致效果： 图1：请求延迟grafana展示 1、延迟分布 需要的指标（分桶统计各个延迟区间的请求量）： xx_latent_stat{serverid="xx", tag="latent_ngt_1ms_count"} xxxx xx_latent_stat{serverid="xx", tag="latent_ngt_5ms_count"} xxxx xx_latent_stat{serverid="xx", tag="latent_ngt_8ms_count"} xxxx xx_latent_stat{serverid="...</summary> </entry> <entry><title>工作笔记：避免资源泄漏</title><link href="https://blog.antsmallant.top/2026/01/02/work-note-resource-manage" rel="alternate" type="text/html" title="工作笔记：避免资源泄漏" /><published>2026-01-02T00:00:00+08:00</published> <updated>2026-01-02T00:00:00+08:00</updated> <id>https://blog.antsmallant.top/2026/01/02/work-note-resource-manage</id> <content type="text/html" src="https://blog.antsmallant.top/2026/01/02/work-note-resource-manage" /> <author> <name>antsmallant</name> </author> <category term="工作" /> <summary>资源的有效释放始终是个艰难的问题。特别是在具体的业务逻辑中，由于逻辑的多变和复杂，导致出错的可能性大大增加。 举个例子，游戏服务器，一个房间等到所有人都不在的时候就被销毁。而当房主退出的时候，要踢出所有人。假设所有人退出都走同样的 exit 逻辑，并且在 exit 逻辑里面判断人数为 0 时销毁房间，就会变得很糟糕，因为 exit 调用其他 exit，如果中间有个环节出错，就会出现房间不释放的问题，造成泄漏。 那怎么做才是安全的呢？标记状态+超时处理。当房主退出的时候，直接就标记房间状态为 releasing，并加上超时时间，由另外的 tick 逻辑去保证最终会销毁这个房间。 总结起来，最核心就 3 条（够应付大多数“资源创建/状态变化/回收”系统）： 1、先定目标，再走流程 把“最终要达到的事实”先写成状态/标记（例如“必须释放/必须踢出/必须回滚”），流程只...</summary> </entry> <entry><title>2025 年终总结</title><link href="https://blog.antsmallant.top/2026/01/02/2025-summary" rel="alternate" type="text/html" title="2025 年终总结" /><published>2026-01-02T00:00:00+08:00</published> <updated>2026-01-02T00:00:00+08:00</updated> <id>https://blog.antsmallant.top/2026/01/02/2025-summary</id> <content type="text/html" src="https://blog.antsmallant.top/2026/01/02/2025-summary" /> <author> <name>antsmallant</name> </author> <category term="认知与总结" /> <summary>AI 善用 AI 近些年出现的最大变量就是 AI，它开始影响整个人类世界，影响我们每一个人。作为码农，受到的冲击和震撼是最大的。你可以抱怨 AI 经常把事情搞砸，但不得不承认，它比你聪明太多太多了。唯一的问题就在于，你能不能用好它？为什么大神们说要2000个小时的使用才算熟练呢？因为这个阶段，它还没法完全替代人类，所以它还是个工具，只要是工具，就有个熟悉的过程，你精通它的各种特性并熟练的使用之后，你就可以善用它了。 如何善用呢？目前总结有几点： 1、确定性。AI 产生的东西确定性暂时存疑，所以连续的交互中间，必须想办法做确定性验证，少了这一步，可能前功尽弃，至于如何做确定性验证？可以让 AI 给你做，但最终还是需要你的某种 review 或验证。 2、自我定位。你的目标是完成工作，而不是多写代码多练习，所以你应该是一个manager、一个工头，应该想办法做到效率最优，而不是...</summary> </entry> </feed>
