# 风雪之隅 > 风雪之隅 是惠新宸(Laruence)的个人技术博客. 惠新宸是 PHP 核心开发者, PHP 扩展 Yaf、Yar、Tair 的作者, 如视(Realsee)创始人. 内容涵盖 PHP 内核源码分析、PHP 应用开发、PHP 扩展开发、性能优化、C/C++、Linux 及 AI 编程. 自 2007 年持续更新至今, 共 300 余篇原创技术文章, 另附开源项目官方中文手册. ## 开源项目手册(技术参考) - [Yaf/Yar/Yaconf/Yac/Taint 中文手册](https://www.laruence.com/manual/): 五个开源 PHP 扩展的完整中文文档, 类与方法的 API 参考 ## PHP应用 - [Yac 2.4.0 Released — 64% Faster Small-Value Reads](https://www.laruence.com/en/2026/08/26/6566.html): Background A few days ago I switched my blog's object cache to wp-yac-cache, my new WordPress plugin, replacing the Memcached setup I'd run for over a decade. Benchmark conclusion: ~19% more throughput under identical co - [Yac 2.4.0发布 - 小值读取性能提升64%](https://www.laruence.com/2026/08/26/6566.html): PHP 共享内存缓存扩展 Yac 发布 2.4.0:标量小值内嵌进 slot 指针,空数组不再占用 values 区;压缩换用 LZ4,get() 新增 $default 参数。混合值读取提速 70%,实测内存近乎减半。 - [Using Yac as WordPress's Object Cache: 19% Faster than Memcached](https://www.laruence.com/en/2026/08/20/6420.html): This blog ran on Memcached for many years. It was stable and never caused trouble, but one thing was unavoidable: every cache read in PHP went through localhost TCP. Connection management, protocol encoding/decoding, dat - [用Yac给WordPress做缓存:比Memcached快19%](https://www.laruence.com/2026/08/20/6420.html): Yac 是基于 PHP 共享内存的无锁对象缓存扩展,用它替换 WordPress 的 Memcached drop-in 可省去每次读缓存的 localhost TCP 往返。实测在 PHP 8.1 FPM 环境下,同条件压测吞吐提升约 19%、延迟降低约 15%,且优势不随并发变化,单机场景收益最大。 - [Wechatian: Let Your AI Reach You on WeChat](https://www.laruence.com/en/2026/08/17/6297.html): A few days ago I wrote about building a personal AI assistant with Obsidian, Claudian and Claude Code: Building a personal AI assistant with Obsidian + Claudian + Ds (Chinese) Once you start using it, you'll keep unlocki - [Wechatian: 让AI有事就来微信找你](https://www.laruence.com/2026/08/17/6297.html): Wechatian 是一款 Obsidian 插件,直接打通微信和Obsidian知识库,不需要第三方服务:微信发来的文字、图片、文章链接自动剪藏进 vault;Agent 往 outbox 文件夹写文件即可经腾讯 ilink 网关发出微信消息。无第三方中转,任何会写文件的程序都能发微信。 - [Improving Yaconf with DeepSeek V4 Pro: Fast It Was, but It Lost My Code](https://www.laruence.com/en/2026/08/14/6343.html): A couple of days ago I finished Taint's PHP 8 adaptation with Qwen3.8 (see the previous post); yesterday DeepSeek released V4 Pro, claiming major improvements across the board and coding ability approaching top-tier clos - [用DeepSeek V4 Pro改进Yaconf:快是真快,但它把我代码搞丢了](https://www.laruence.com/2026/08/14/6343.html): yaconf 1.2.0 新增子目录支持(最深16层)与仿照 opcache 的两阶段 compact 存储:配置数据紧凑存于一块连续内存并去重相同字符串,实测随机访问提速40%、内存降低16%。全程由 DeepSeek V4 Pro 编码,速度快但上下文压缩后易失忆、稳定性存疑。 - [Taint supports PHP 8 now!](https://www.laruence.com/en/2026/08/07/6340.html): What is Taint: Among my open source projects, Taint is the only one I ever actively "abandoned" — because maintaining it got too hard. In a nutshell, Taint is a PHP extension that detects XSS / SQL / Shell injection vuln - [Taint支持PHP8啦!](https://www.laruence.com/2026/08/07/6340.html): Taint是检测XSS/SQL注入的PHP扩展,通过GC_FLAGS标记并劫持Opcode传递污点。因PHP8引入JIT且无空闲bit而停更,现由Qwen-3.8-Max完成PHP8适配,耗时5小时、消耗2亿Token,验证了AI可胜任复杂工程执行。 - [Named Parameters in PHP 8.0](https://www.laruence.com/en/2022/05/10/6192.html): A while back I spent some time improving Yar's performance, but I also ran into a legacy design wart that had always bothered me: for parallel RPC calls, the current method prototype is: public static Yar_Concurrent_Clie - [PHP8.0的Named Parameter](https://www.laruence.com/2022/05/10/6192.html): 解决 Yar_Concurrent_Client::call 并行 RPC 调用时大量 NULL 占位传参的问题:用 argument unpacking(...$arguments)把数组解开按位置传参,配合 PHP8 Named Parameter 命名参数直接跳过可选参数,无需给 Yar 新增 API 或多态。 ## 随笔 - [GPT-6 Astra 做实景三维重建,我拿一套住宅试了试](https://www.laruence.com/2026/09/16/6626.html): GPT-6 Astra 具备在 Blender 中自主建模的能力。用如视伽罗华 P4 采集的 24K HDR 全景图、点云、深度图、Mesh 等 16 类真实空间数据测试住宅三维重建:仅给照片时结构靠"猜",补入点云和深度数据后布局、材质、尺寸接近真实,物件可分割导出。结论:AI 行动力不再是瓶颈,确定性的多视角高质量采集数据才是关键。 - [Reconstructing a Real Apartment with GPT-6 Astra](https://www.laruence.com/en/2026/09/16/6626.html): Since GPT-6 Astra was released, its hottest use case has been modeling. It writes its own scripts in Blender, runs renders, inspects the results, tweaks a bit — and then an entire house is built. Of course, some say it s - [Wechatian: Let Your AI Reach You on WeChat](https://www.laruence.com/en/2026/08/17/6297.html): A few days ago I wrote about building a personal AI assistant with Obsidian, Claudian and Claude Code: Building a personal AI assistant with Obsidian + Claudian + Ds (Chinese) Once you start using it, you'll keep unlocki - [Wechatian: 让AI有事就来微信找你](https://www.laruence.com/2026/08/17/6297.html): Wechatian 是一款 Obsidian 插件,直接打通微信和Obsidian知识库,不需要第三方服务:微信发来的文字、图片、文章链接自动剪藏进 vault;Agent 往 outbox 文件夹写文件即可经腾讯 ilink 网关发出微信消息。无第三方中转,任何会写文件的程序都能发微信。 - [Building a Personal AI Assistant with Obsidian + Claudian + DeepSeek](https://www.laruence.com/en/2026/08/10/6299.html): My earlier posts mentioned my AI knowledge base, and quite a few readers asked me to share the setup. Today I'll walk through how to build a workflow that lets AI act like a real personal assistant — handling your daily - [用Obsidian+Claudian+Ds搭建个人AI助理](https://www.laruence.com/2026/08/10/6299.html): 用 Obsidian + Claudian + Claude Code + CC Switch 路由 DeepSeek 搭建私人 AI 知识库:Claudian 提供对话窗,Claude Code 做 Agent 引擎,CC Switch 转发请求并记账;AI 行为由 CLAUDE.md 定义,目录分 raw/wiki/assets,数据全部为本地 Markdown,双平台 iCloud 同步。 - [Named Parameters in PHP 8.0](https://www.laruence.com/en/2022/05/10/6192.html): A while back I spent some time improving Yar's performance, but I also ran into a legacy design wart that had always bothered me: for parallel RPC calls, the current method prototype is: public static Yar_Concurrent_Clie - [PHP8.0的Named Parameter](https://www.laruence.com/2022/05/10/6192.html): 解决 Yar_Concurrent_Client::call 并行 RPC 调用时大量 NULL 占位传参的问题:用 argument unpacking(...$arguments)把数组解开按位置传参,配合 PHP8 Named Parameter 命名参数直接跳过可选参数,无需给 Yar 新增 API 或多态。 - [On PHP, and on Realsee](https://www.laruence.com/en/2022/04/12/6089.html): Since PHP 8.0, my involvement in PHP open source has dwindled, and so has my blogging. Quite a few friends have asked about it, so I figured a post explaining where things stand is in order. Overall, my investment in PHP - [关于PHP,关于Realsee](https://www.laruence.com/2022/04/12/6089.html): PHP8.0 JIT 后逐渐减少 PHP 开源投入,全面转向如视(Realsee)创业:自2018年在贝壳带领团队做 VR 看房,实现对2000多万套物理空间三维重建、面积超16亿平方米,延伸出户型图自动生成、AI 设计贝壳未来家与开发者开放平台。 - [New in PHP 8: the match Expression](https://www.laruence.com/en/2020/07/13/6033.html): PHP 8 alpha2 is out, and it recently introduced a new keyword: match. Its role is somewhat similar to switch. I'm usually indifferent to syntactic sugar, but I find this one rather interesting — and "match" is a nice-loo - [PHP8新特性之match表达式](https://www.laruence.com/2020/07/13/6033.html): match 表达式是 PHP8 引入的新语法:类似 switch 但直接返回值可赋值;采用严格比较 ===,避免 switch 宽松比较陷阱;多个条件可共用一个分支;所有条件都不匹配时抛出 UnhandledMatchError。match 成为保留字,不能再用作类名。 ## PHP源码分析 - [用DeepSeek V4 Pro改进Yaconf:快是真快,但它把我代码搞丢了](https://www.laruence.com/2026/08/14/6343.html): yaconf 1.2.0 新增子目录支持(最深16层)与仿照 opcache 的两阶段 compact 存储:配置数据紧凑存于一块连续内存并去重相同字符串,实测随机访问提速40%、内存降低16%。全程由 DeepSeek V4 Pro 编码,速度快但上下文压缩后易失忆、稳定性存疑。 - [Improving Yaconf with DeepSeek V4 Pro: Fast It Was, but It Lost My Code](https://www.laruence.com/en/2026/08/14/6343.html): A couple of days ago I finished Taint's PHP 8 adaptation with Qwen3.8 (see the previous post); yesterday DeepSeek released V4 Pro, claiming major improvements across the board and coding ability approaching top-tier clos - [深入理解PHP7内核之OBJECT](https://www.laruence.com/2020/03/23/5605.html): 深入解析 PHP7 内核 Object 变化:对比 PHP5 的 zend_object 结构(ce、properties、properties_table)与 PHP7 新实现,分析属性存储底层机制。 - [Understanding PHP 7 Internals: OBJECT](https://www.laruence.com/en/2020/03/23/5605.html): 剖析 PHP 7 内核对象的实现:从 PHP 5 的 zend_object 入手,说明 ce、properties_table 与动态 properties 的分工,以及 PHP 7 对象存储布局的改进。 - [PHP FFI详解 - 一种全新的PHP扩展方式](https://www.laruence.com/2020/03/11/5475.html): PHP 7.4 引入 FFI(Foreign Function Interface) 扩展,可在纯 PHP 中直接调用 C 库函数,无需编写扩展。以调用 libcurl 抓取网页为例对比 FFI 与传统扩展用法。 - [PHP FFI in Depth — A Whole New Way to Write PHP Extensions](https://www.laruence.com/en/2020/03/11/5475.html): PHP 7.4 ships with an extension I consider genuinely useful: PHP FFI (Foreign Function Interface). Quoting the FFI RFC: For PHP, FFI opens a way to write PHP extensions and bindings to C libraries in pure PHP. Exactly — - [深入理解PHP7内核之FAST_ZPP](https://www.laruence.com/2020/02/27/5213.html): FAST_ZPP是PHP7引入的快速参数解析方式,以ZEND_PARSE_PARAMETERS_START/Z_PARAM_*宏取代zend_parse_parameters。借助编译期常量剪枝与内联消除运行时type_spec解析开销(wordpress基准中约占6%耗时),代价是binary size增大,建议仅用于高频调用且逻辑简单的函数。 - [Understanding PHP 7 Internals: FAST_ZPP](https://www.laruence.com/en/2020/02/27/5213.html): Since PHP 7 you may have noticed that many functions no longer parse arguments the traditional way — they use what we call Fast zend parameters parsing (FAST_ZPP) instead. For example, before PHP 7 the count function loo - [深入理解PHP7内核之HashTable](https://www.laruence.com/2020/02/25/3182.html): PHP7新HashTable(zend_array)的设计动机与实现:针对PHP5的zval**双指针、Bucket独立分配、链表遍历缓存局部性差等问题重新设计,结构体从72字节降至56字节,数据存于arData连续Bucket数组,并用ZEND_ENDIAN_LOHI_4处理大小端。 - [Understanding PHP 7 Internals: HashTable](https://www.laruence.com/en/2020/02/25/3182.html): In my two previous articles, Understanding PHP 7 Internals: zval and Understanding PHP 7 Internals: Reference, I described some of the thinking and results behind the changes we made to zval and references while developi - [Understanding PHP 7 Internals: References](https://www.laruence.com/en/2018/04/08/3179.html): The problem In the previous chapter I said that a reference (REFERENCE) was a flag bit in PHP 5, whereas from PHP 7 on we turned it into a new type: IS_REFERENCE. References, however, are a very common thing to use, so t - [深入理解PHP7内核之Reference](https://www.laruence.com/2018/04/08/3179.html): PHP7内核中引用(Reference)从标志位变为独立类型IS_REFERENCE,通过zend_reference结构存储引用计数和zval。解析该设计如何解决PHP5中IS_LONG引用无法用标志位表示的问题,以及Change On Write分离机制在PHP7下的优化。 ## 转载 - [Yaf 3.2 发布](https://www.laruence.com/2020/04/18/5832.html): Yaf 3.2.0 beta 发布,将 Yaf 对象重构为自定义 C 结构体,按偏移量直接访问属性提升性能;新增部分 PSR-4 autoloading 支持,cachegrind 实测性能明显提升。 - [Yaf 3.2 Released](https://www.laruence.com/en/2020/04/18/5832.html): After a little over two weeks of refactoring, I finally bit the bullet and shipped Yaf 3.2.0 beta today. Otherwise I'd have kept chasing every possible optimization point, writing endlessly with no end in sight. :) The o - [What's New in Yar 2.1](https://www.laruence.com/en/2020/03/16/5578.html): Yar (Yet Another RPC framework) is a lightweight PHP RPC framework that supports parallel calls. I developed it back when I was at Weibo, as a tool to optimize Weibo's performance, and its parallel calls were used heavil - [Yar-2.1 新功能介绍](https://www.laruence.com/2020/03/16/5578.html): Yar-2.1 发布,轻量级支持并行调用的 PHP RPC 框架。YAR_OPT_PERSISTENT 改为基于 PHP 请求生命期的连接保持,RPC 调用后不销毁连接,加速后续调用。 - [PHP的性能演进(从PHP5.0到PHP7.1的性能全评测)](https://www.laruence.com/2016/12/18/3137.html): PHP 5.0到PHP 7.1全版本CPU性能基准测试对比,使用bench.php、micro_bench.php、mandelbrot.php评测各版本。结论:性能飞跃来自大版本升级而非小版本,PHP 7.0是重大突破,PHP 8试验性JIT分支比PHP 5.0快41倍以上。 - [在PHP中使用协程实现多任务调度](https://www.laruence.com/2015/05/28/3038.html): PHP5.5生成器(Generator)与协程(Coroutine)实现协作式多任务调度教程:yield实现任务中断与调度器通信,send()实现双向数据传递,通过Task包装协程函数、任务队列和run()调度器实现协作多任务,区别于抢占式多任务调度。 - [A Battle Without a Victory: Chasing a glibc freeres Bug](https://www.laruence.com/en/2015/05/14/3021.html): I first ran into this problem over a year ago, but since it wasn't causing any trouble I never followed up on it. Recently a new hire on the team triggered it again, so I finally resolved to dig into the cause of this bu - [记录一场没有胜利的局部战斗](https://www.laruence.com/2015/05/14/3021.html): Valgrind 报 Invalid free,指向 glibc-2.5 的 __libc_freeres bug,用 --run-libc-freeres=no 规避。空共享库链接 -lm 即可复现,未定位根因,仅得规避方案。 - [PHP的历史](https://www.laruence.com/2012/01/11/2482.html): 了解下PHP的历史, 有助于更加深刻的了解PHP发展到今天的轨迹, 下面的文字都是从» PHP手册中转载过来的. PHP 在过去的几年里走过了漫长的道路。成长为处理 web 的最卓越的语言并非易事。如果对 PHP 如何发展到今天很感兴趣,那么请继续读下去吧。以前的 PHP 发行版可以在 » PHP 博物馆找到。 PHP/FI PHP 继承自一个老的工程,名叫 PHP/FI。PHP/FI 在 1995 年由 Rasmus Lerdorf - [2012年1月全球www网站技术报告](https://www.laruence.com/2012/01/07/2453.html): W3Techs在2012年1月7日, 发出最新的"全球www网站技术报告". 该统计基于对全球Alexa排名前100W的www网站做分析而得出. 统计报告(Usage of server-side programming languages for websites)显示, 相比2011年12月, 使用PHP构建的前100W名中的网站,又增长了约0.1%(30个), PHP占据的份额增长至77.3%, 依旧排名第一. 下图显示了1年来的 - [PHP数组的Hash冲突实例](https://www.laruence.com/2011/12/30/2435.html): 上一篇文章, 我介绍了一个利用Hash冲突(碰撞)来对各种语言(包括,PHP, Java, Ruby等等)实施拒绝服务攻击的可能, 但是没有给出实例, 文章发出后, @Ferrari同学给出了一个另外一篇文章Supercolliding a PHP array, 文章中作者介绍了一种基于PHP的冲突实例, 以及带来的性能恶化对比. 我就借花献佛, 翻译给大家看看. 你知道不知道, 插入65536个经过构造的键值的元素到PHP数组, 会需 - [Yaf的性能对比测试](https://www.laruence.com/2011/11/05/2262.html): 从Yaf诞生以来, 我就没把它与其他框架的性能对比测试放出来, 原因呢, 也很简单, 我懒, 没对比过(只是和原生的PHP做了简单的对比). 最近, 关注Yaf的人越来越多, 今天从访问来源发现了这个页面reddit.com, 继而发现了Eryx朋友, 做的一份性能对比测试, 我就借花谢佛, 转载了过来. 后记(2011-12-02补充), Yaf 2.1做了一些性能优化的升级, 基于Yaf 2.1的性能测试报告可以参见: Yaf 2. ## PHP Extension - [用Yac给WordPress做缓存:比Memcached快19%](https://www.laruence.com/2026/08/20/6420.html): Yac 是基于 PHP 共享内存的无锁对象缓存扩展,用它替换 WordPress 的 Memcached drop-in 可省去每次读缓存的 localhost TCP 往返。实测在 PHP 8.1 FPM 环境下,同条件压测吞吐提升约 19%、延迟降低约 15%,且优势不随并发变化,单机场景收益最大。 - [Using Yac as WordPress's Object Cache: 19% Faster than Memcached](https://www.laruence.com/en/2026/08/20/6420.html): This blog ran on Memcached for many years. It was stable and never caused trouble, but one thing was unavoidable: every cache read in PHP went through localhost TCP. Connection management, protocol encoding/decoding, dat - [Wechatian: 让AI有事就来微信找你](https://www.laruence.com/2026/08/17/6297.html): Wechatian 是一款 Obsidian 插件,直接打通微信和Obsidian知识库,不需要第三方服务:微信发来的文字、图片、文章链接自动剪藏进 vault;Agent 往 outbox 文件夹写文件即可经腾讯 ilink 网关发出微信消息。无第三方中转,任何会写文件的程序都能发微信。 - [Wechatian: Let Your AI Reach You on WeChat](https://www.laruence.com/en/2026/08/17/6297.html): A few days ago I wrote about building a personal AI assistant with Obsidian, Claudian and Claude Code: Building a personal AI assistant with Obsidian + Claudian + Ds (Chinese) Once you start using it, you'll keep unlocki - [用DeepSeek V4 Pro改进Yaconf:快是真快,但它把我代码搞丢了](https://www.laruence.com/2026/08/14/6343.html): yaconf 1.2.0 新增子目录支持(最深16层)与仿照 opcache 的两阶段 compact 存储:配置数据紧凑存于一块连续内存并去重相同字符串,实测随机访问提速40%、内存降低16%。全程由 DeepSeek V4 Pro 编码,速度快但上下文压缩后易失忆、稳定性存疑。 - [Improving Yaconf with DeepSeek V4 Pro: Fast It Was, but It Lost My Code](https://www.laruence.com/en/2026/08/14/6343.html): A couple of days ago I finished Taint's PHP 8 adaptation with Qwen3.8 (see the previous post); yesterday DeepSeek released V4 Pro, claiming major improvements across the board and coding ability approaching top-tier clos - [Taint支持PHP8啦!](https://www.laruence.com/2026/08/07/6340.html): Taint是检测XSS/SQL注入的PHP扩展,通过GC_FLAGS标记并劫持Opcode传递污点。因PHP8引入JIT且无空闲bit而停更,现由Qwen-3.8-Max完成PHP8适配,耗时5小时、消耗2亿Token,验证了AI可胜任复杂工程执行。 - [Taint supports PHP 8 now!](https://www.laruence.com/en/2026/08/07/6340.html): What is Taint: Among my open source projects, Taint is the only one I ever actively "abandoned" — because maintaining it got too hard. In a nutshell, Taint is a PHP extension that detects XSS / SQL / Shell injection vuln - [一个小玩意PHP-Valgrind的介绍](https://www.laruence.com/2013/08/14/2899.html): php-valgrind 工具让 PHP 脚本在运行中控制 Valgrind/Callgrind 的 Profile 开关,借助 CALLGRIND_TOGGLE_COLLECT 机制实现按代码段粒度分析,代码开源于 GitHub。 - [Introducing php-valgrind: A Little Tool](https://www.laruence.com/en/2013/08/14/2899.html): First off, it's been way too long since I updated the blog, so let me ramble a bit. I always thought people would always manage to squeeze out time to blog, but now it seems I was wrong. It's not that I have nothing to s - [Yac (Yet Another Cache) - 无锁共享内存Cache](https://www.laruence.com/2013/03/18/2846.html): 好久没有更新blog了, 这一年来的工作确实很忙..... anyway, 今天终于有新东西可以和大家分享. 这个idea来自一个很简单的想法, 以及目前所遇到的一个机会. 首先我们来谈谈这个机会. 在以前, 很多人都会选择使用APC, APC除了提供Opcode Cache以外, 还会提供一套User Data Cache(apc_store/apc_fetch), 所以对于很多有需求使用User Data Cache的同学, 使用A - [Yac (Yet Another Cache) — A Lock-Free Shared-Memory Cache](https://www.laruence.com/en/2013/03/18/2846.html): Haven't updated the blog for a long time — work has been really busy this past year..... anyway, today there's finally something new to share with everyone. This idea comes from a very simple thought, plus an opportunity ## Js/CSS - [Wechatian: 让AI有事就来微信找你](https://www.laruence.com/2026/08/17/6297.html): Wechatian 是一款 Obsidian 插件,直接打通微信和Obsidian知识库,不需要第三方服务:微信发来的文字、图片、文章链接自动剪藏进 vault;Agent 往 outbox 文件夹写文件即可经腾讯 ilink 网关发出微信消息。无第三方中转,任何会写文件的程序都能发微信。 - [Wechatian: Let Your AI Reach You on WeChat](https://www.laruence.com/en/2026/08/17/6297.html): A few days ago I wrote about building a personal AI assistant with Obsidian, Claudian and Claude Code: Building a personal AI assistant with Obsidian + Claudian + Ds (Chinese) Once you start using it, you'll keep unlocki - [HTTP 204和205的应用](https://www.laruence.com/2011/01/20/1844.html): 之前和人讨论过这个问题,,, 今天感冒在家休息, 就回忆了一下, 整理如下. 我们很多的应用在使用Ajax的时候, 大多数情况都是询问型操作, 比如提交数据, 则Ajax只是期待服务器返回: {status: 0, message:""} //status 0代表成功, 非零的时候, message中包含出错信息. 我们知道HTTP的状态码, 2xx都是表示成功, 而HTTP的204(No Content)响应, 就表示执行成功, 但是 - [Using HTTP 204 and 205](https://www.laruence.com/en/2011/01/20/1844.html): I'd discussed this problem with someone before,,, today I'm home resting with a cold, so I recalled it and organized the notes as follows. Many of our applications use Ajax, and in most cases it's a query-type operation. - [Javascript原型链和原型的一个误区](https://www.laruence.com/2010/05/13/1462.html): 之前我对Javascript的原型链中, 原型继承与标识符查找有些迷惑, 如, 如下的代码: function Foo() {}; var foo = new Foo(); Foo.prototype.label = "laruence"; alert(foo.label); //output: laruence alert(Foo.label);//output: undefined 今天看到了如下这个图: 另外, 在Javascri - [IE下var的重要性的又一佐证](https://www.laruence.com/2010/01/21/1254.html): 一个朋友问了一个js问题, 一段看不出有任何问题的代码, 在ie下报错:"object doesn't support this property or method". function foo(obj) { productTree = obj.toString(); document.getElementById('productTree').innerHTML = productTree; } 开始, 还以为错误是指obj的toS - [关于Javascript的俩个有趣的探讨](https://www.laruence.com/2009/09/27/1123.html): 首先祝贺在经历了几乎一天的等待以后. 我的空间商终于把服务器迁到了电信机房, 外加网通CDN加速. 关于事件处理函数引用的一个佐证 之前, 我在分析Javascript的This关键字的时候, 说过, 当使用inline的方式写dom元素的事件处理函数的时候, 采用的是引用的方式. 刚好nullbyte童鞋给我提供了一个很有意思的Case: alert(document.getElementById("foo").onerror); 在 - [深入理解JavaScript定时机制](https://www.laruence.com/2009/09/23/1089.html): 转帖地址:http://www.9demo.com/archives/341 容易欺骗别人感情的JavaScript定时器 JavaScript的setTimeout与setInterval是两个很容易欺骗别人感情的方法,因为我们开始常常以为调用了就会按既定的方式执行, 我想不少人都深有同感, 例如 setTimeout(function() { alert('你好!'); }, 0); setInterval(callbackFunc - [CSS让你的IE浏览器崩溃(Crash your IE)](https://www.laruence.com/2009/09/14/1081.html): 严格来说不单是CSS就能令IE浏览器崩溃(crash),而要配合相应的XHTML架构。到现时为止发现有两种正常写法及一种错误结构分别导致会IE6、IE7崩溃(crash),至于原因我尝试寻找过答案但至今还没找到…如你有这方面的认识或更详细的资料很希望你能分享! 1 crash IE6 code Demo:http://blog.gulu77.com/demo/200808/crash_ie6.html 此BUG只存在IE6中,当伪类为 - [深入理解Javascript之this关键字](https://www.laruence.com/2009/09/08/1076.html): Javascript是一种很灵活的语言, 而This关键字又是灵活中的灵活, 但是因为它的灵活, 也注定了它的难用. 以前我用this的时候, 都会觉得不踏实, 老是担心它不知道怎么地就会指到另外的什么地方. 其实, 这都是因为, 我们对它的不了解. 刚好最近再给百度学院做《Javascript高级-作用域/原型链》的ppt, 而swit1983网友也刚好提这个问题, 索性就把这部分内容独立总结出来, 与大家分享. 首先, 我先抛出一个 - [纯属娱乐(彩蛋)](https://www.laruence.com/2009/08/31/1072.html): 现在, 请依次按下:"上上下下左右左右BA"~, ;) - [正确使用JS中的正则](https://www.laruence.com/2009/08/09/1036.html): yuchen网友发来一个问题, 大体意思就是在JS中, 同样的正则, 同样的字符串, 循环匹配结果却不一样 , var reTest = /^aid=(.*)/ig; var aData = [ 'aid=^$', 'aid=^$', 'aid=^$', 'aid=^$' ]; for (var i=0, l=aData.length; i ## PHP7 - [Yac 2.4.0发布 - 小值读取性能提升64%](https://www.laruence.com/2026/08/26/6566.html): PHP 共享内存缓存扩展 Yac 发布 2.4.0:标量小值内嵌进 slot 指针,空数组不再占用 values 区;压缩换用 LZ4,get() 新增 $default 参数。混合值读取提速 70%,实测内存近乎减半。 - [Yac 2.4.0 Released — 64% Faster Small-Value Reads](https://www.laruence.com/en/2026/08/26/6566.html): Background A few days ago I switched my blog's object cache to wp-yac-cache, my new WordPress plugin, replacing the Memcached setup I'd run for over a decade. Benchmark conclusion: ~19% more throughput under identical co - [使用PHP Socket开发Yar TCP服务](https://www.laruence.com/2020/04/01/5726.html): Yar RPC 框架支持 HTTP 与 TCP 两种 Transporter。用 PHP Socket 可实现 Yar TCP Server,解析 Yar 打包协议,可结合 Swoole 构建高性能服务。 - [Building a Yar TCP Service with PHP Sockets](https://www.laruence.com/en/2020/04/01/5726.html): Yar supports two kinds of Transporter: HTTP and TCP. The HTTP one is based on CURL, and Yar in PHP uses the HTTP Transporter by default — that should be familiar to everyone. The TCP-based one, though, you probably use l - [Yac 2.1 升级说明](https://www.laruence.com/2020/03/25/5657.html): Yac 2.1.0 发布,Lock-free 共享内存 PHP 缓存。用 CAS 原子操作保护 key 读写降低读到错误数据的概率,以 SSE4.2 CRC32-C 指令加速校验;set 可能因冲突重试失败。 - [Yac 2.1 Upgrade Notes](https://www.laruence.com/en/2020/03/25/5657.html): PHP 无锁共享内存缓存扩展 Yac 发布 2.1 版:用 CAS 原子操作保护 key 读写,在保持无锁性能的同时大幅降低读到错误数据的概率(副作用是 set 可能失败);改用 SSE4.2 硬件 CRC32 指令提升校验性能,并优化内存占用,稳定性显著增强,已发布至 PECL。 - [深入理解PHP7内核之OBJECT](https://www.laruence.com/2020/03/23/5605.html): 深入解析 PHP7 内核 Object 变化:对比 PHP5 的 zend_object 结构(ce、properties、properties_table)与 PHP7 新实现,分析属性存储底层机制。 - [Understanding PHP 7 Internals: OBJECT](https://www.laruence.com/en/2020/03/23/5605.html): 剖析 PHP 7 内核对象的实现:从 PHP 5 的 zend_object 入手,说明 ce、properties_table 与动态 properties 的分工,以及 PHP 7 对象存储布局的改进。 - [深入理解PHP7内核之FAST_ZPP](https://www.laruence.com/2020/02/27/5213.html): FAST_ZPP是PHP7引入的快速参数解析方式,以ZEND_PARSE_PARAMETERS_START/Z_PARAM_*宏取代zend_parse_parameters。借助编译期常量剪枝与内联消除运行时type_spec解析开销(wordpress基准中约占6%耗时),代价是binary size增大,建议仅用于高频调用且逻辑简单的函数。 - [Understanding PHP 7 Internals: FAST_ZPP](https://www.laruence.com/en/2020/02/27/5213.html): Since PHP 7 you may have noticed that many functions no longer parse arguments the traditional way — they use what we call Fast zend parameters parsing (FAST_ZPP) instead. For example, before PHP 7 the count function loo - [深入理解PHP7内核之HashTable](https://www.laruence.com/2020/02/25/3182.html): PHP7新HashTable(zend_array)的设计动机与实现:针对PHP5的zval**双指针、Bucket独立分配、链表遍历缓存局部性差等问题重新设计,结构体从72字节降至56字节,数据存于arData连续Bucket数组,并用ZEND_ENDIAN_LOHI_4处理大小端。 - [Understanding PHP 7 Internals: HashTable](https://www.laruence.com/en/2020/02/25/3182.html): In my two previous articles, Understanding PHP 7 Internals: zval and Understanding PHP 7 Internals: Reference, I described some of the thinking and results behind the changes we made to zval and references while developi ## GNU C/C++ - [使用SSE2指令高效实现strtolower](https://www.laruence.com/2020/06/16/5916.html): PHP8 用 SSE2 指令实现 locale 无关的 strtolower:利用 ASCII 中 A-Z 与 a-z 连续编码且相差32,通过 SIMD 比较指令并行判断大写字母并加32转小写,一次处理16字节,替代旧版256项码表逐字符处理。选 SSE2 而非 SSE4/AVX 是因 CPU 兼容性更广。 - [An Efficient strtolower with SSE2](https://www.laruence.com/en/2020/06/16/5916.html): Class, function and method names in PHP are case-insensitive: however you spell a function name, the engine lowercases it before every lookup. That makes strtolower extremely common. PHP does a lot of design work to avoi - [使用OSC52实现iTerm2远程pbcopy](https://www.laruence.com/2020/05/21/5880.html): 利用 ANSI escape code 中的 OSC 52 转义序列,可在 iTerm2 中实现远程 SSH 服务器直接写入 Mac 本地剪贴板,替代仅限本机的 pbcopy。 - [Remote pbcopy in iTerm2 with OSC 52](https://www.laruence.com/en/2020/05/21/5880.html): The most efficient way to type shares one defining trait: your fingers leave the keyboard as rarely as possible. And when they do move, the span across the keyboard is as short as possible. That's why many veteran progra - [使用SSE2指令集加速字符替换](https://www.laruence.com/2020/03/09/5412.html): 用SSE2 SIMD指令集加速字符串字符替换:_mm_cmpeq_epi8一次比较16个字符,结合ASCII差值delta与_mm_add_epi8原地替换目标字符。应用于Yaf_Loader命名空间反斜杠转下划线,字符串超16字节约提速40%-50%,短串无优势。同思路曾用于PHP7的base64_encode/decode优化。 - [Faster Character Replacement with SSE2](https://www.laruence.com/en/2020/03/09/5412.html): This is a genuinely useful performance trick. I just used it again while refactoring Yaf_Loader, and since the operation is so common, it deserves a short post of its own. When processing strings, you often need to repla - [GCC优化引起的一个"问题"](https://www.laruence.com/2014/06/26/2955.html): PHP NG 的 zend_string 按偏移仅分配 22 字节,GCC 将 len==1 && val[0]=='0' 优化为一次 8 字节读,越界 3 字节触发 valgrind invalid read 误报,修复为至少分配 24 字节。 - [A "Problem" Caused by GCC Optimization](https://www.laruence.com/en/2014/06/26/2955.html): This was originally posted as a long Weibo post. But since it's been a while since I updated the blog, I'm moving it over here — just to pad the count, so bear with me :) I wasted nearly 2 hours on this and I have to ven - [Weibo LAMP演变 - 6月在上海分享的PPT](https://www.laruence.com/2013/08/15/2913.html): 微博 LAMP 架构优化实践:以提速、降成本、清晰架构、SOA 为方针,改造 Yaf 并推出 Yar RPC 与 Yac 缓存,使微博首页响应时间下降一倍以上并降低成本,依赖工具均已开源。 - [Weibo LAMP Evolution — Slides from My June Talk in Shanghai](https://www.laruence.com/en/2013/08/15/2913.html): I've shared this PPT before on Weipan (microdisk). Today it suddenly occurred to me, so I uploaded it to SlideShare — and while I'm at it, let me also leave a memento here on the blog. This PPT covers the results of my w - [一个小玩意PHP-Valgrind的介绍](https://www.laruence.com/2013/08/14/2899.html): php-valgrind 工具让 PHP 脚本在运行中控制 Valgrind/Callgrind 的 Profile 开关,借助 CALLGRIND_TOGGLE_COLLECT 机制实现按代码段粒度分析,代码开源于 GitHub。 - [Introducing php-valgrind: A Little Tool](https://www.laruence.com/en/2013/08/14/2899.html): First off, it's been way too long since I updated the blog, so let me ramble a bit. I always thought people would always manage to squeeze out time to blog, but now it seems I was wrong. It's not that I have nothing to s ## 关于作者 - 惠新宸(Laruence), PHP 核心开发者, GitHub: https://github.com/laruence