zhuizhuhaomeng Blog

「记录下来,一切都会更容易理解」

Why YYJSON has high performance

Table of Contents Introduction Loop Unroll Branch Prediction Inline C Routines Efficient Number Converter Efficient Memory Manager Table Lookup Zero copy Inline assemble indicati...

Print function name when entering a function using GDB

Reading code is a very important skill for software developers. Knowing the calling sequence of a function is essential for understanding. GDB rbreak command is a powerful tool for code analysis. ...

Cross compile

https://github.com/stunnel/static-curl/blob/main/curl-static-cross.sh

lua_package_path of the OpenResty

OpenResty 官方发布的包的搜索路径默认包含 /usr/local/openresty/site/lualib,这个是如何做到的呢? 从 C 代码中我们可以看到, lua-nginx-module 的正常发布版本是不会有 LUA_DEFAULT_PATH 的,除非定义了 LUA_DEFAULT_PATH。 #if !defined(LUA_DEFAULT_PATH) &&a...

使用 OpenTelemetry 采集 Nginx 访问日志/错误日志/指标数据/Trace 数据

安装 nginx-otel 模块 安装 Nginx 模块参考 https://github.com/nginxinc/nginx-otel/blob/main/README.md 配置 Nginx 为了方便日志采集,将日志输出为 json 这种结构化的格式。注意 log_format 中指定 escape 为 json。 location /t 配置了推送 trace 信息到...

Nginx Shared Memory Fragment

从 如何估算共享内存大小 我们知道, 其实 Nginx 的共享内存分配是划分成固定大小的块的。 这些大小分别是 8, 16, 32,64, …, page_size / 2。以 4K 页面大小为例,这个固定的块就是 8,16, 32, …, 2048。 nginx 共享内存分配除了固定大小外还有另一个特性就是内存分配是池化的。也就是说,这些固定大小的内存块是以内存池的形式存在的。 要申请一...

How to estimate Nginx shared memory size

Why it is 8K entries in one megabyte From http://nginx.org/en/docs/http/ngx_http_proxy_module.html, we know that one megabyte zone can store about 8 thousand keys. But why it is 8 thousand? Let’s...

parsing file by token

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 sub parse_file($) { open my $in, $yfile or die "Cannot open file $yfile for r...

luarocks for openresty

luarocks 安装模块给 OpenResty使用,最好是要跟非 LuaJIT 的版本区分,因此应该使用类似这样子的命令 1 sudo luarocks install --force --lua-dir=/usr/local/openresty/luajit/ --tree=/usr/local/openresty/luajit --server=https://luarocks.or...

resty.core not found

在搞 OpenResty 应用的测试有时候突然遇到这样的错误,平常跑得好好的突然不行了,这是为什么呢? 如果不是修改一点就执行测试很难想起来是怎么回事。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 nginx: [alert] failed to load the 'resty.core' module (https://github.com/ope...