{"id":267,"date":"2023-05-04T11:15:55","date_gmt":"2023-05-04T03:15:55","guid":{"rendered":"https:\/\/lovelyping.com\/?p=267"},"modified":"2026-05-26T14:48:39","modified_gmt":"2026-05-26T06:48:39","slug":"f-stack-ld_preload-%e6%b5%8b%e8%af%95%e7%89%88%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/lovelyping.com\/?p=267","title":{"rendered":"F-Stack LD_PRELOAD \u4ecb\u7ecd"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">2026.05.26\u672c\u6587\u7ae0\u5df2\u7ecf\u66f4\u65b0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8df3\u7968\u8bb8\u4e45\u8bb8\u4e45\u7684<code>LD_PRELOAD<\/code>\u529f\u80fd\u6a21\u5757\uff08\u540e\u7eed\u4ee5 <code>libff_syscall.so<\/code> \u4ee3\u66ff\uff09\u5728 F-Stack dev \u5206\u652f\u7684 <code>adapter\/sysctall<\/code> \u76ee\u5f55\u4e0b\u5df2\u7ecf\u63d0\u4ea4\uff0c\u652f\u6301 hook \u7cfb\u7edf\u5185\u6838 socket \u76f8\u5173\u63a5\u53e3\u7684\u4ee3\u7801\uff0c\u964d\u4f4e\u5df2\u6709\u5e94\u7528\u8fc1\u79fb\u5230 F-Stack \u7684\u95e8\u69db\u3002\u4e0b\u9762\u5c06\u5206\u522b\u8fdb\u884c\u5177\u4f53\u4ecb\u7ecd\uff0c \u4e3b\u8981\u5305\u62ec<code>libff_syscall.so<\/code> \u76f8\u5173\u7684\u67b6\u6784\u6d89\u53ca\u5176\u4e2d\u7684\u4e00\u4e9b\u601d\u8003\uff0c\u652f\u6301\u7684\u51e0\u79cd\u6a21\u5f0f\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u7b49\u5185\u5bb9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u603b\u4f53\u7ed3\u8bba\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u539f\u6709\u5e94\u7528\u7a0b\u5e8f\u7684\u63a5\u5165\u95e8\u69db\u6bd4\u539f\u672c\u7684 F-Stack \u6709\u6240\u964d\u4f4e\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u53ef\u4ee5\u4e0d\u4fee\u6539\u539f\u6709\u7684\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u548c F-Stack lib \u7684\u4ee3\u7801\uff0c\u800c\u662f\u4ec5\u4fee\u6539<code>libff_syscall.so<\/code>\u76f8\u5173\u4ee3\u7801\u5373\u53ef\u9002\u914d\u3002<\/li><li>\u53ef\u4ee5\u652f\u6301\u591a F-Stack \u5b9e\u4f8b\uff08\u5373\u539f F-Stack \u5e94\u7528\u7a0b\u5e8f\u8fdb\u7a0b\uff09\uff0c\u6bcf\u4e2a F-Stack \u5b9e\u4f8b\u53ef\u4ee5\u5bf9\u5e94 1 \u4e2a\u6216\u591a\u4e2a\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u3002<ul><li>\u4e3a\u4e86\u8fbe\u5230\u6700\u4f73\u7684\u6027\u80fd\uff0c\u5efa\u8bae\u4e00\u4e2a\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\uff08\u8fdb\u7a0b\u6216\u7ebf\u7a0b\uff09\u5bf9\u5e94\u4e00\u4e2a fstack \u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\uff0c\u5373\u4e3a\u4e00\u7ec4\u5e94\u7528\u5b9e\u4f8b\u3002<\/li><\/ul><\/li><li>\u6bcf\u7ec4\u5e94\u7528\u5b9e\u4f8b\u7684\u6027\u80fd\u4f1a\u7565\u9ad8\u4e8e\u7cfb\u7edf\u5185\u6838\u7684\u6027\u80fd\uff0c\u4e0e\u5355\u4e2a\u6807\u51c6  F-Stack \u5e94\u7528\u8fdb\u7a0b\u4e92\u6709\u9ad8\u4f4e\uff1b\u5355\u673a\u6574\u4f53\u7684\u6027\u80fd\u76f8\u6bd4\u7cfb\u7edf\u5185\u6838\u4ecd\u6709\u8f83\u5927\u7684\u4f18\u52bf\uff0c\u4f46\u4e0e\u6807\u51c6 F-Stack \u4ecd\u6709\u5dee\u8ddd\u3002<ul><li>\u65b0\u7684\u6bcf\u7ec4\u5e94\u7528\u5b9e\u4f8b\u9700\u8981\u8fd0\u884c\u5728\u4e24\u4e2a CPU \u6838\u5fc3\u4e0a\uff0c\u800c\u6807\u51c6 F-Stack \u5e94\u7528\u8fdb\u7a0b\u53ea\u9700\u8981\u8fd0\u884c\u5728\u4e00\u4e2a CPU \u6838\u5fc3\u4e0a\uff0c\u603b\u4f53\u800c\u8a00<strong>\u6027\u4ef7\u6bd4\u4e0d\u9ad8<\/strong>\uff0c\u662f\u5426\u4f7f\u7528\u53ef\u4ee5\u89c6\u5404\u4e1a\u52a1\u7684\u5177\u4f53\u60c5\u51b5\u800c\u5b9a\u3002<\/li><li>Nginx 600 \u5b57\u8282\u7684 body \u5185\u5b58\u5e94\u7b54\u6d4b\u8bd5\u4e2d\uff0c\u957f\u8fde\u63a5\u4e2d\u76f8\u540c\u6570\u91cf\u7684\u65b0\u5e94\u7528\u5b9e\u4f8b<strong>\u7ec4<\/strong>\u7565<strong>\u9ad8<\/strong>\u4e8e\u6807\u51c6 F-Stack \u5e94\u7528\u8fdb\u7a0b\uff0c\u77ed\u8fde\u63a5\u4e2d\u76f8\u540c\u6570\u91cf\u7684\u65b0\u5e94\u7528\u5b9e\u4f8b<strong>\u7ec4<\/strong>\u5219\u7565<strong>\u4f4e<\/strong>\u4e8e\u6807\u51c6 F-Stack \u5e94\u7528\u8fdb\u7a0b\uff0c\u89c1 Nginx \u63a5\u5165\u4ecb\u7ecd\u7ae0\u8282\uff0c\u4f46\u4f7f\u7528\u7684 CPU \u51e0\u4e4e\u7ffb\u500d\u3002<\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5df2\u77e5\u9650\u5236<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u81ea 2023 \u5e74\u4ee5\u6765 <code>libff_syscall.so<\/code> \u6301\u7eed\u8fed\u4ee3\uff0c\u539f\u672c\u4f5c\u4e3a\u5f00\u653e\u95ee\u9898\u7684\u591a\u4e2a\u80fd\u529b\uff08\u5982 <code>fork<\/code>\u3001<code>accept4<\/code>\u3001<code>__recv_chk<\/code> \u7cfb\u5217\u3001<code>epoll<\/code> polling \u6a21\u5f0f\u4ee5\u53ca lock-free ring IPC \u7b49\uff09\u5df2\u7ecf\u5b9e\u73b0\uff0c\u8be6\u89c1\u4e0b\u6587 <a href=\"#\u529f\u80fd\u66f4\u65b0\u5386\u7a0b-2023-05-04--2026-05-25\">\u529f\u80fd\u66f4\u65b0\u5386\u7a0b<\/a>\u3002\u4e0b\u5217\u9650\u5236\u4ecd\u5728\u8ddf\u8e2a\uff0c\u6b22\u8fce\u793e\u533a\u5171\u540c\u5b8c\u5584\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u8fdb\u7a0b\u7ed3\u675f\u65f6\u4ecd\u53ef\u80fd\u5b58\u5728\u5185\u5b58\u6cc4\u6f0f\u4e0e\u6b7b\u9501\u98ce\u9669\u3002<\/li><li>\u90e8\u5206\u63a5\u53e3\uff08\u5982 <code>sendmsg<\/code>\u3001<code>readv<\/code>\u3001<code>readmsg<\/code> \u7b49\uff09\u7ebf\u4e0a\u573a\u666f\u4f7f\u7528\u8f83\u5c11\uff0c\u5c1a\u672a\u505a\u5145\u5206\u7684\u6027\u80fd\u4f18\u5316\u4e0e\u6d4b\u8bd5\uff0c\u4ecd\u9700\u8fdb\u4e00\u6b65\u6253\u78e8\uff08\u8f83\u65b0\u52a0\u5165\u7684 <code>accept4<\/code>\u3001<code>__recv_chk<\/code>\u3001<code>__read_chk<\/code>\u3001<code>__recvfrom_chk<\/code> \u7b49\u5df2\u8986\u76d6\uff09\u3002<\/li><li>\u9879\u76ee\u5728\u51c6\u751f\u4ea7\u73af\u5883\u4e2d\u6301\u7eed\u8fed\u4ee3\uff0c\u6b22\u8fce\u793e\u533a\u63d0\u4f9b\u66f4\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\u53cd\u9988\u3002<\/li><li>\u5728\u591a F-Stack \u5b9e\u4f8b\u540c\u65f6\u8fd0\u884c\u65f6\u6682\u4e0d\u80fd\u4f5c\u4e3a\u5ba2\u6237\u7aef\u4f7f\u7528\uff0c\u4f8b\u5982 Nginx \u7684 proxy \u573a\u666f\uff1b\u53c2\u8003\u7684\u6539\u9020\u601d\u8def\u5982\u4e0b\uff1a<\/li><li>@\u94c1\u76ae\u5927\u7237\uff1a\u4e4b\u524d\u5b9e\u73b0\u8fc7\u7c7b\u4f3c\u7684\u903b\u8f91\uff0c\u5728 hook \u5185\u518d\u52a0\u4e00\u5c42 RSS\u3002\u5ef6\u8fdf\u5efa\u7acb socket\uff08\u4ec5\u5728\u786e\u5b9a\u76ee\u7684\u4e0e\u6765\u6e90\u540e\u518d\u9009\u62e9\u7531\u54ea\u4e2a F-Stack \u4f5c\u4e3a worker \u8fdb\u7a0b\uff09\uff0c\u540c\u65f6\u8981\u6c42\u7f51\u5361\u63a5\u6536\u4fa7\u5f00\u542f RSS \u5bf9\u79f0\u54c8\u5e0c\uff0c\u4fdd\u8bc1\u51fa\u5165\u65b9\u5411\u80fd\u843d\u5230\u540c\u4e00\u4e2a F-Stack worker\u3002<ul><li>app -> <code>socket<\/code>\uff1a\u6682\u5b58 socket \u64cd\u4f5c\uff0c\u521b\u5efa fd\uff08fd1\uff09\u8fd4\u56de\u7ed9\u7528\u6237\u3002<\/li><li>app -> <code>bind<\/code>\uff1a\u6682\u5b58 bind \u64cd\u4f5c\uff0c\u5c06 bind \u53c2\u6570\u4e0e fd1 \u7ed1\u5b9a\u540e\u8fd4\u56de\u7ed9\u7528\u6237\u3002<\/li><li>app -> <code>connect<\/code>\uff1a\u5728 fd1 \u4e0a\u8ffd\u52a0 connect \u53c2\u6570\uff0c\u6309 RSS \u5bf9\u79f0\u54c8\u5e0c\u9009\u5b9a\u67d0\u4e2a F-Stack \u8fdb\u7a0b\uff08worker\uff09\uff0c\u5c06\u6682\u5b58\u7684 <code>socket<\/code>\u3001<code>bind<\/code>\u3001<code>connect<\/code> \u4e00\u5e76\u4ea4\u7ed9\u8be5 F-Stack \u8fdb\u7a0b\u5904\u7406\u5e76\u7b49\u5f85\u540c\u6b65\u7ed3\u679c\u3002<\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u529f\u80fd\u66f4\u65b0\u5386\u7a0b (2023-05-04 ~ 2026-05-25)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u6c47\u603b\u81ea v1.22 \u4ee5\u6765 <code>adapter\/syscall\/<\/code> \u76ee\u5f55\u7684\u4e3b\u8981\u53d8\u66f4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u65b0\u529f\u80fd<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Lock-free <code>rte_ring<\/code> IPC\uff08<code>FF_USE_RING_IPC<\/code>\uff09<\/strong>\uff1a\u4ee5 DPDK SPSC ring \u66ff\u4ee3\u539f\u5148\u57fa\u4e8e\u4fe1\u53f7\u91cf\u7684\u5171\u4eab\u5185\u5b58 IPC\uff0c\u4ece fstack \u4e3b\u5faa\u73af\u4e2d\u5f7b\u5e95\u79fb\u9664\u5168\u5c40 <code>ff_so_zone-&gt;lock<\/code>\u3002\u591a\u6838\u77ed\/\u957f\u8fde\u63a5\u5b9e\u6d4b\u4e2d ring \u4e0e sem \u6027\u80fd\u76f8\u5f53\u6216\u7565\u4f4e 2\u20134%\uff0c\u65e0\u8de8 worker \u9501\u7ade\u4e89\uff0c\u5e76\u5929\u7136\u514d\u75ab\u542f\u52a8\u671f\u81ea\u65cb\u9501\u9965\u997f\u3002Ring \u5206\u652f\u9ed8\u8ba4\u542f\u7528 v3.4 \u7684\u4f18\u5316\uff08D2\uff1a<code>sc-&gt;completion<\/code> \u5524\u9192\uff1bD5\uff1a\u5185\u8054 <code>rte_ring_empty<\/code> \u5feb\u901f\u7a7a\u5224\u65ad\uff1bD6\uff1a\u5185\u8054 dequeue burst \u4e0e dispatch\uff09\u3002\u7f16\u8bd1\u5f00\u5173\u89c1\u9644\u5f55 <code>FF_USE_RING_IPC<\/code>\uff0c\u5b8c\u6574\u8bbe\u8ba1\u4e0e\u6027\u80fd\u5206\u6790\u89c1 <code>docs\/ld_preload_ring_spec\/<\/code>\u3002<\/li><li><strong><code>epoll<\/code> polling \u6a21\u5f0f<\/strong>\uff1a\u5728 RTT \u654f\u611f\u7684\u4e8b\u4ef6\u7b49\u5f85\u8def\u5f84\u4e0a\u6539\u5584\u65f6\u5ef6\u8868\u73b0\u3002<\/li><li><strong><code>fork<\/code> \u652f\u6301<\/strong>\uff1a\u6bcf\u4e2a fork \u51fa\u7684\u8fdb\u7a0b\u62e5\u6709\u81ea\u5df1\u7684 FreeBSD <code>struct thread<\/code>\uff0c\u884c\u4e3a\u66f4\u63a5\u8fd1 Linux kernel\uff0c\u89e3\u9664\u4e86\u539f\u5148 LD_PRELOAD \u4e0b <code>fork<\/code> \u4f7f\u7528\u53d7\u9650\u7684\u72b6\u51b5\u3002<\/li><li><strong><code>accept4<\/code> \u53ca <code>SOCK_CLOEXEC<\/code> \/ <code>SOCK_NONBLOCK<\/code> \u652f\u6301<\/strong>\uff1a\u65b0\u589e <code>accept4<\/code> hook\uff0c\u5e76\u5728 <code>ff_socket<\/code> \u4e0a\u652f\u6301 <code>LINUX_SOCK_CLOEXEC<\/code> \/ <code>LINUX_SOCK_NONBLOCK<\/code> \u6807\u5fd7\u4f4d\u3002<\/li><li><strong>glibc <code>_FORTIFY_SOURCE<\/code> \u7cfb\u5217 hook<\/strong>\uff1a\u65b0\u589e <code>__recv_chk<\/code>\u3001<code>__read_chk<\/code>\u3001<code>__recvfrom_chk<\/code>\uff0c\u4f7f\u5f00\u542f <code>-D_FORTIFY_SOURCE<\/code> \u7f16\u8bd1\u7684\u5e94\u7528\u80fd\u5728 LD_PRELOAD \u4e0b\u6b63\u5e38\u5de5\u4f5c\u3002<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u529f\u80fd\u5b8c\u5584\u4e0e\u7f3a\u9677\u4fee\u590d<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><code>FF_KERNEL_EVENT<\/code> \u6a21\u5f0f\u4e0b kernel epoll fd \u6cc4\u6f0f\u4fee\u590d<\/strong>\uff1a<code>ff_hook_close<\/code> \u5728\u542f\u7528 <code>FF_KERNEL_EVENT<\/code> \u65f6\u540c\u6b65\u5173\u95ed\u7cfb\u7edf\u4fa7 epoll fd\uff0c\u89e3\u51b3\u957f\u65f6\u95f4\u8fd0\u884c Nginx \u573a\u666f\u4e0b\u89c2\u5bdf\u5230\u7684\u5185\u6838 fd \u6cc4\u6f0f\u3002<\/li><li><strong><code>ff_hook_syscall.c<\/code> \u4e2d cplen \u8ba1\u7b97\u4fee\u590d<\/strong>\uff1a\u4fee\u590d hook \u8def\u5f84\u4e2d\u9519\u8bef\u7684\u957f\u5ea6\u8ba1\u7b97\uff0c\u5e76\u540e\u7eed\u5c06\u4ee3\u7801\u98ce\u683c\u7edf\u4e00\u5230 <code>ff_hook_accept<\/code>\u3002<\/li><li><strong><code>ff_hook_recvfrom<\/code> \u4e2d <code>sh_fromlen<\/code> \u672a\u521d\u59cb\u5316\u4fee\u590d<\/strong>\uff1a\u5728\u8c03\u7528 <code>ff_sys_recvfrom<\/code> \u4e4b\u524d\u521d\u59cb\u5316 <code>sh_fromlen<\/code>\uff0c\u4fee\u590d\u8fd4\u56de <code>-1<\/code> \u7684\u56de\u5f52\u95ee\u9898\u3002<\/li><li><strong><code>ioctl<\/code> \u51fd\u6570\u539f\u578b\u51b2\u7a81\u7684\u7f16\u8bd1\u9519\u8bef\u4fee\u590d\uff08#942\uff09<\/strong>\uff1a\u89e3\u51b3\u65b0\u7248\u5de5\u5177\u94fe\u4e0b\u51fd\u6570\u539f\u578b\u51b2\u7a81\u5bfc\u81f4\u7684\u6784\u5efa\u5931\u8d25\u3002<\/li><li><strong>Ring IPC \u542f\u52a8\u671f\u9965\u997f\u4fee\u590d<\/strong>\uff1a\u5728 <code>FF_MULTI_SC<\/code> + <code>idle_sleep = 0<\/code> \u573a\u666f\u4e0b\uff0cnginx worker \u5728 attach \u7b2c\u4e8c\u4e2a fstack \u5b9e\u4f8b\u7684 <code>ff_so_zone<\/code> \u65f6\u53ef\u80fd\u8868\u73b0\u4e3a\u6b7b\u9501\uff1bsem \u8def\u5f84\u5728\u786e\u8ba4\u65e0\u5728\u7528 socket context \u65f6\u505a\u6761\u4ef6\u6027\u7684 <code>unlock \u2192 pause \u2192 lock<\/code>\uff0c\u6d88\u9664\u9965\u997f\u4e14\u5bf9\u6b63\u5e38\u8d1f\u8f7d\u96f6\u5f71\u54cd\u3002<\/li><li><strong>Ubuntu 22.04 \/ kernel 5.19 \/ gcc 11.4 \u7f16\u8bd1\u9519\u8bef\u4fee\u590d<\/strong>\uff1a\u5305\u542b pre-C99 \u58f0\u660e\u95ee\u9898\uff0c\u53c2\u8003 #777\u3002<\/li><li><strong>\u5176\u4ed6\u96f6\u788e\u7f16\u8bd1 \/ \u65e5\u5fd7 \/ Makefile \/ \u5934\u6587\u4ef6\u6253\u78e8<\/strong>\uff1a\u5305\u62ec syscall \u76ee\u5f55\u7f16\u8bd1\u95ee\u9898\u4fee\u590d\u3001\u65e5\u5fd7\u6e05\u7406\uff0c\u4ee5\u53ca\u4e00\u7cfb\u5217\u56f4\u7ed5 <code>ff_hook_syscall.c<\/code>\u3001<code>ff_socket_ops.c<\/code>\u3001<code>ff_socket_ops.h<\/code>\u3001<code>ff_linux_syscall.c<\/code>\u3001<code>ff_sysproto.h<\/code>\u3001<code>ff_declare_syscalls.h<\/code> \u4e0e <code>Makefile<\/code> \u7684\u7ec6\u8282\u6539\u8fdb\u3002<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><code>libff_syscall.so<\/code> \u7684\u7f16\u8bd1<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u8bbe\u7f6e\u597d<code>FF_PATH<\/code>\u548c<code>PKG_CONFIG_PATH<\/code>\u73af\u5883\u53d8\u91cf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_PATH=\/data\/f-stack<br>export PKG_CONFIG_PATH=\/usr\/lib64\/pkgconfig:\/usr\/local\/lib64\/pkgconfig:\/usr\/lib\/pkgconfig<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728<code>adapter\/sysctall<\/code>\u76ee\u5f55\u4e0b\u76f4\u63a5\u7f16\u8bd1\u5373\u53ef\u5f97\u5230<code>ibff_syscall.so<\/code>\u7684\u76f8\u5173\u529f\u80fd\u7ec4\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/data\/f-stack\/adapter\/sysctall<br>make clean;make all<br>\u200b<br>ls -lrt<br>fstack<br>libff_syscall.so<br>helloworld_stack<br>helloworld_stack_thread_socket<br>helloworld_stack_epoll<br>helloworld_stack_epoll_thread_socket<br>helloworld_stack_epoll_kernel<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u5c06\u5206\u522b\u8fdb\u884c\u4ecb\u7ecd\u5404\u4e2a\u7ec4\u4ef6\u7684\u4e3b\u8981\u4f5c\u7528<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">fstack \u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>fstack<\/code>\u5e94\u7528\u7a0b\u5e8f\u5bf9\u6807\u7684\u662f\u6807\u51c6\u7248 F-Stack \u4e2d\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5176\u8fd0\u884c\u4e0e\u666e\u901a\u7684 F-Stack \u5e94\u7528\u7a0b\u5e8f\u5b8c\u5168\u76f8\u540c\uff0c\u5305\u62ec\u914d\u7f6e\u6587\u4ef6\u53ca\u5176\u591a\u8fdb\u7a0b\uff08\u6bcf\u8fdb\u7a0b\u5373\u4e3a\u4e00\u4e2a\u5b9e\u4f8b\uff09\u7684\u8fd0\u884c\u65b9\u5f0f\u7b49, \u5177\u4f53\u8fd0\u884c\u65b9\u5f0f\u53ef\u4ee5\u53c2\u8003 F-Stack \u4e3b\u76ee\u5f55\u7684 README\uff0c \u5728\u6267\u884c LD_PRELOAD \u7684\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u524d\u5fc5\u987b\u5148\u8fd0\u884c <code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">fstack \u5e94\u7528\u7a0b\u5e8f\u7684\u4f5c\u7528\u4e3b\u8981\u662f\u5e95\u5c42\u5bf9\u63a5 F-Stack API\uff0c\u5176\u4e3b\u51fd\u6570<code>ff_handle_each_context<\/code>\u5373\u4e3a\u666e\u901a F-Stack \u5e94\u7528\u7684\u7528\u6237\u5c42 loop \u51fd\u6570\uff0c\u975e\u7a7a\u95f2\u65f6\u6216\u6bcf\u95f4\u9694 10ms (\u53d7 <code>HZ<\/code>\u53c2\u6570\u5f71\u54cd) \u65f6\u4f1a\u8c03\u7528\u8be5\u51fd\u6570\u53bb\u5faa\u73af\u5904\u7406\u4e0e APP \u5bf9\u63a5\u7684\u4e0a\u4e0b\u6587\uff0c\u5982\u679c APP \u6709\u5bf9\u5e94\u7684 API \u8bf7\u6c42\uff0c\u5219\u8c03\u7528\u5b9e\u9645\u7684 F-Stack API \u8fdb\u884c\u5904\u7406\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0e <code>libff_syscall.so<\/code>\u7528\u6237\u5e94\u7528\u8fdb\u7a0b\u95f4\u901a\u4fe1\u4f7f\u7528 DPDK \u7684 <code>rte_malloc<\/code> \u5206\u914d\u7684 Hugepage \u5171\u4eab\u5185\u5b58\u8fdb\u884c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u51fd\u6570\u5bf9 <code>libff_syscall.so<\/code> \u7684\u6574\u4f53\u6027\u80fd\u6709<strong>\u81f3\u5173\u91cd\u8981<\/strong>\u7684\u5f71\u54cd\uff0c\u76ee\u524d\u662f\u590d\u7528\u4e86 F-Stack \u4e3b\u914d\u7f6e\u6587\u4ef6\uff08config.ini\uff09\u4e2d\u7684 <code>pkt_tx_dalay<\/code>\u53c2\u6570\uff0c\u6b7b\u5faa\u73af\u5e76\u5ef6\u8fdf\u8be5\u53c2\u6570\u6307\u5b9a\u7684\u503c\u540e\u624d\u4f1a\u56de\u5230 F-Stack \u7684\u5176\u4ed6\u5904\u7406\u6d41\u7a0b\u4e2d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u60f3\u63d0\u9ad8 <code>libff_syscall.so<\/code>\u7684\u6574\u4f53\u6027\u80fd\uff0c\u90a3\u4e48<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u4e0e APP \u5e94\u7528\u7a0b\u5e8f\u7684\u5339\u914d\u5341\u5206\u91cd\u8981\uff0c\u53ea\u6709\u5f53\u4e00\u4e2a<code>ff_handle_each_context<\/code>\u5faa\u73af\u4e2d\u5c3d\u91cf\u5339\u914d\u4e00\u6b21\u5faa\u73af\u7684\u6240\u6709\u4e8b\u4ef6\u65f6\u624d\u80fd\u8fbe\u5230\u6700\u4f18\u7684\u6027\u80fd\uff0c\u8fd9\u91cc\u9700\u8981\u8c03\u5341\u5206\u7cbe\u7ec6\u7684\u8c03\u4f18\uff0c\u4f46\u662f\u76ee\u524d\u8fd8\u662f\u7c97\u7565\u7684\u4f7f\u7528 <code>pkt_tx_dalay<\/code>\u53c2\u6570\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u63d0\u793a\u3011<code>pkt_tx_dalay<\/code>\u53c2\u6570\u7684\u9ed8\u8ba4\u503c\u4e3a 100us\uff0c \u8f83\u9002\u5408\u957f\u8fde\u63a5\u7684\u573a\u666f\u3002\u5982\u679c\u662f Nginx \u77ed\u94fe\u63a5\u7684\u573a\u666f\uff0c\u5219\u5e94\u8003\u8651\u8bbe\u7f6e\u4e3a 50us\uff0c\u53ef\u4ee5\u53ef\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002\u5f53\u7136\u4e0d\u540c\u7684\u7528\u7528\u573a\u666f\u5982\u679c\u60f3\u8fbe\u5230\u6700\u4f18\u7684\u6027\u80fd\uff0c\u53ef\u80fd\u9700\u8981\u4e1a\u52a1\u81ea\u884c\u8c03\u6574\u53ca\u6d4b\u8bd5\u3002\u590d\u7528\u8be5\u53c2\u6570\u4e5f\u53ea\u662f\u4e34\u65f6\u65b9\u6848\uff0c\u540e\u7eed\u5982\u679c\u6709\u66f4\u4f18\u7684\u65b9\u6848\uff0c\u5219\u968f\u65f6\u53ef\u80fd\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">libff_syscall.so<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u52a8\u6001\u5e93\u4e3b\u8981\u4f5c\u7528\u662f\u52ab\u6301\u7cfb\u7edf\u7684 socket \u76f8\u5173\u63a5\u53e3\uff0c\u6839\u636e fd \u53c2\u6570\u5224\u65ad\u662f\u8c03\u7528 F-Stack\u7684\u76f8\u5173\u63a5\u53e3\uff08\u901a\u8fc7\u4e0a\u4e0b\u6587 sc \u4e0e fsack \u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u4ea4\u4e92\uff09\u8fd8\u662f\u7cfb\u7edf\u5185\u6838\u7684\u76f8\u5173\u63a5\u53e3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0e<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u8fdb\u7a0b\u95f4\u901a\u4fe1\u4f7f\u7528 DPDK \u7684 <code>rte_malloc<\/code> \u5206\u914d\u7684 Hugepage \u5171\u4eab\u5185\u5b58\u8fdb\u884c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f\u3011\u5728\u7b2c\u4e00\u6b21\u8c03\u7528\u76f8\u5173\u63a5\u53e3\u65f6\u5206\u914d\u76f8\u5173\u5185\u5b58\uff0c\u4e0d\u518d\u91ca\u653e\uff0c\u8fdb\u7a0b\u9000\u51fa\u65f6\u5b58\u5728\u5185\u5b58\u6cc4\u6f0f\u7684\u95ee\u9898\uff0c\u5f85\u4fee\u590d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">F-Stack\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f \uff08\u5982 helloworl \u6216 Nginx\uff09\u8bbe\u7f6e <code>LD_PRELOAD<\/code>\u52ab\u6301\u7cfb\u7edf\u7684 socket \u76f8\u5173 API \u65f6\u4f7f\u7528\uff0c\u5373\u53ef\u76f4\u63a5\u63a5\u5165 F-Stack \u5f00\u53d1\u6846\u67b6\uff0c\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>export LD_PRELOAD=\/data\/f-stack\/adapter\/syscall\/libff_syscall.so<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u786e\u4fdd <code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u6b63\u786e\u8fd0\u884c\u7684\u524d\u63d0\u4e0b\uff0c\u7136\u540e\u542f\u52a8\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136\u5982\u679c\u662f\u6539\u9020\u7528\u6237\u7684 APP \u4f7f\u7528 <code>kqueue<\/code>\u4ee3\u66ff Linux \u7684 epoll \u76f8\u5173\u4e8b\u4ef6\u63a5\u53e3\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5728\u7528\u6237 APP \u4e2d\u76f4\u63a5\u94fe\u63a5\u8be5\u8fd0\u884c\u5e93\uff0c \u53ef\u4ee5\u53c2\u8003\u76f8\u5173\u793a\u4f8b\u7a0b\u5e8f<code>helloworld_stack<\/code>\u548c<code>helloworld_stack_thread_socket<\/code>\u5bf9\u5e94\u7684\u6e90\u6587\u4ef6<code>main_stack.c<\/code>\u548c<code>main_stack_thread_socket.c<\/code>\uff0c\u56e0\u4e3a\u4e0d\u662f\u4f7f\u7528\u7684<code>LD_PRELOAD<\/code>, \u6240\u4ee5\u672c\u6587\u6863\u4e0d\u518d\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u91cd\u8981\u63d0\u793a\u3011\u4e00\u7ec4\u5bf9\u5e94\u7684<code>fstack<\/code>\u5e94\u7528\u7a0b\u5e8f\u548c\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u6700\u597d\u8fd0\u884c\u5728<strong>\u540c\u4e00\u4e2a CPU NUMA \u8282\u70b9<\/strong>\u7684<strong>\u4e0d\u540c\u7269\u7406\u6838<\/strong>\u4e0a\uff0c\u5176\u4ed6\u573a\u666f\uff08\u8fd0\u884c\u5728\u540c\u4e00\u4e2aCPU\u6838\u5fc3\u3001\u4e24\u4e2a CPU \u6838\u5fc3\u8de8 NUMA \u8282\u70b9\uff0c\u7269\u7406\u6838\u548c\u8d85\u7ebf\u7a0b\u6838\u6df7\u7528\uff09\u90fd\u65e0\u6cd5\u8fbe\u5230\u4e00\u7ec4\u5b9e\u4f8b\u7684\u6700\u4f73\u6027\u80fd\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7279\u522b\u7684\uff0c\u5982\u679c CPU \u7269\u7406\u6838\u5fc3\u6bd4\u8f83\u7f3a\u4e4f\uff0c\u53ef\u4ee5\u8003\u8651\u4e00\u7ec4\u5b9e\u4f8b\u5206\u522b\u8fd0\u884c\u5728\u5bf9\u5e94\u7684\u4e00\u7ec4 CPU \u7684\u7269\u7406\u6838\u5fc3\u548c HT \u6838\u5fc3\u4e0a\uff0c\u867d\u7136\u5355\u7ec4\u5b9e\u4f8b\u6027\u80fd\u4f1a\u6709\u6240\u4e0b\u964d\uff08\u7ea6 20% \u5de6\u53f3\uff09\uff0c\u4f46\u53ef\u4ee5\u4f7f\u7528\u66f4\u591a\u7684 CPU \u6838\u5fc3\uff0c\u5355\u673a\u603b\u6027\u80fd\u53ef\u80fd\u4f1a\u6709\u6240\u63d0\u5347\u3002<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">DEMO \u6f14\u793a\u7a0b\u5e8f helloworld_stack*<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4ed6\u7f16\u8bd1\u751f\u6210\u7684<code>hello_world<\/code>\u5f00\u5934\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e3a\u5f53\u524d<code>libff_syscall.so<\/code>\u652f\u6301\u7684\u51e0\u79cd\u4e0d\u540c\u8fd0\u884c\u6a21\u5f0f\u7684\u76f8\u5173\u6f14\u793a\u7a0b\u5e8f\uff0c\u4e0b\u4e00\u8282\u8fdb\u884c\u5177\u4f53\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">F-Stack LD_PRELOAD \u652f\u6301\u7684\u51e0\u79cd\u6a21\u5f0f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u9002\u5e94\u4e0d\u540c\u5e94\u7528\u5bf9 socket \u63a5\u53e3\u7684\u4e0d\u540c\u4f7f\u7528\u65b9\u5f0f\uff0c\u964d\u4f4e\u5df2\u6709\u5e94\u7528\u8fc1\u79fb\u5230 F-Stack \u7684\u95e8\u69db\uff0c\u5e76\u5c3d\u91cf\u63d0\u9ad8\u8f83\u9ad8\u7684\u6027\u80fd\uff0c\u76ee\u524d F-Stack \u7684 <code>libff_syscall.so<\/code> \u4e3b\u8981\u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\u6a21\u5f0f\uff0c\u652f\u6301\u591a\u7ebf\u7a0b\u7684 PIPELINE \u6a21\u5f0f\u3001\u7ebf\u7a0b\uff08\u8fdb\u7a0b\uff09\u5185\u7684 RTC\uff08run to completion\uff09\u6a21\u5f0f\u3001\u540c\u65f6\u652f\u6301 F-Stack \u548c\u5185\u6838 socket \u63a5\u53e3\u7684 FF_KERNEL_EVENT \u6a21\u5f0f\u548c\u7c7b\u4f3c\u5185\u6838 SO_REUSEPORT \u7684 FF_MULTI_SC \u6a21\u5f0f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u652f\u6301\u591a\u7ebf\u7a0b\u7684 PIPELINE \u6a21\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u6a21\u5f0f\u4e3a\u9ed8\u8ba4\u6a21\u5f0f\uff0c\u65e0\u9700\u989d\u5916\u8bbe\u7f6e\u4efb\u4f55\u53c2\u6570\u76f4\u63a5\u7f16\u8bd1<code>libff_syscall.so<\/code>\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6b64\u6a21\u5f0f\u4e0b\uff0csocket \u76f8\u5173\u63a5\u53e3\u8fd4\u56de\u7684 fd <strong>\u53ef\u4ee5\u5728\u4e0d\u540c\u7ebf\u7a0b\u4ea4\u53c9\u8c03\u7528<\/strong>\uff0c\u5373\u652f\u6301 PIPELINE \u6a21\u5f0f\uff0c\u5bf9\u5df2\u6709\u5e94\u7528\u7684\u79fb\u690d\u63a5\u5165\u66f4\u53cb\u597d\uff0c\u4f46\u6027\u80fd\u4e0a\u76f8\u5e94\u4e5f\u4f1a\u6709\u66f4\u591a\u7684\u635f\u5931\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u6a21\u5f0f\u9664\u4e86\u5355\u8fdb\u7a0b\u8fd0\u884c\u65b9\u5f0f\u5916\uff0c\u540c\u65f6\u53ef\u4ee5<strong>\u652f\u6301\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u591a\u8fdb\u7a0b\u65b9\u5f0f\u8fd0\u884c<\/strong>\uff0c\u6bcf\u4e2a\u7528\u6237\u8fdb\u7a0b\u5bf9\u5e94\u4e00\u4e2a<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u7684\u5b9e\u4f8b\uff0c\u66f4\u591a\u4fe1\u606f\u53ef\u4ee5\u53c2\u8003\u9644\u5f55\u7684\u8fd0\u884c\u53c2\u6570\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f\u3011\u4ee5\u6b64\u9ed8\u8ba4\u65b9\u5f0f\u63a5\u5165 F-Stack \u7684\u5e94\u7528\u7a0b\u5e8f\u53ea\u80fd\u4f7f\u7528 F-Stack \u7684 socket \u7f51\u7edc\u63a5\u53e3\uff0c\u800c\u4e0d\u80fd\u4f7f\u7528\u7cfb\u7edf\u7684 socket \u63a5\u53e3\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">hook \u7cfb\u7edf epoll \u63a5\u53e3<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u5df2\u6709\u7684 Linux \u4e0b\u7684\u5e94\u7528\uff0c\u4e8b\u4ef6\u63a5\u53e3\u90fd\u662f\u4e00\u822c\u4f7f\u7528\u7684\u662f<code>epoll<\/code>\u76f8\u5173\u63a5\u53e3\uff0c\u5bf9\u4e8e\u6ca1\u6709\u66f4\u591a\u7279\u6b8a\u8981\u6c42\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u9ed8\u8ba4\u7684\u7f16\u8bd1\u53c2\u6570\u7f16\u8bd1<code>libff_syscall.so<\/code>\u540e\u4f7f\u7528\uff0c\u53c2\u8003 DEMO \u7a0b\u5e8f<code>helloworld_stack_epoll<\/code>\uff0c \u4ee3\u7801\u6587\u4ef6\u4e3a<code>main_stack_epoll.c<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f\u3011F-Stack \u7684<code>epoll<\/code>\u63a5\u53e3\u4f9d\u7136\u4e3a<code>kqueue<\/code>\u63a5\u53e3\u7684\u5c01\u88c5\uff0c\u4f7f\u7528\u4e0a\u4f9d\u7136\u4e0e\u7cfb\u7edf\u6807\u51c6\u7684<code>epoll<\/code>\u4e8b\u4ef6\u63a5\u53e3\u6709\u4e00\u5b9a\u533a\u522b\uff0c\u4e3b\u8981\u662f\u4e8b\u4ef6\u89e6\u53d1\u65b9\u5f0f\u548cmulti accept\u7684\u533a\u522b\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528 kqueue<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136<code>libff_syscall.so<\/code>\u9664\u4e86\u652f\u6301\u4f7f\u7528<code>LD_PRELOAD<\/code>\u65b9\u5f0f hook \u7cfb\u7edf\u7684 socket \u63a5\u53e3\u7684\u65b9\u5f0f\u4f7f\u7528\uff0c\u4e5f\u652f\u6301\u666e\u901a\u7684\u94fe\u63a5\u65b9\u5f0f\u4f7f\u7528\uff0c\u6b64\u65f6\u9664\u4e86\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u7684<code>epoll<\/code>\u4e8b\u4ef6\u63a5\u53e3\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 F-Stack(FreeBSD)\u5177\u6709\u7684<code>kqueue<\/code>\u4e8b\u4ef6\u63a5\u53e3\uff0c\u53c2\u8003 DEMO \u7a0b\u5e8f<code>helloworld_stack<\/code>\uff0c \u4ee3\u7801\u6587\u4ef6\u4e3a<code>main_stack.c<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u4f7f\u7528\u65b9\u5f0f\u7684\u6027\u80fd\u6bd4<code>LD_PRELOALD<\/code>\u4f7f\u7528\u7cfb\u7edf<code>epoll<\/code>\u63a5\u53e3\u7684\u65b9\u5f0f\u6709\u7565\u5fae\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7ebf\u7a0b\uff08\u8fdb\u7a0b\uff09\u5185\u7684 RTC\uff08run to completion\uff09\u6a21\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u6a21\u5f0f\u9700\u8981\u8bbe\u7f6e\u989d\u5916\u7684\u7f16\u8bd1\u53c2\u6570\u540e\u6765\u7f16\u8bd1<code>libff_syscall.so<\/code>\u624d\u80fd\u5f00\u542f\uff0c\u53ef\u4ee5\u5728<code>adapter\/sysctall\/Makefile<\/code>\u4e2d\u4f7f\u80fd<code>FF_THREAD_SOCKET<\/code>\u6216\u6267\u884c\u4ee5\u4e0b shell \u547d\u4ee4\u6765\u5f00\u542f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_THREAD_SOCKET=1<br>make clean;make all<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6b64\u6a21\u5f0f\u4e0b\uff0csocket \u76f8\u5173\u63a5\u53e3\u8fd4\u56de\u7684 fd <strong>\u4ec5\u53ef\u4ee5\u5728\u672c\u7ebf\u7a0b\u5185\u8c03\u7528<\/strong>\uff0c\u5373\u4ec5\u652f\u6301\u7ebf\u7a0b\u5185\u7684 RTC \u6a21\u5f0f\uff0c\u5bf9\u5df2\u6709\u5e94\u7528\u7684\u79fb\u690d\u63a5\u5165\u95e8\u69db\u7a0d\u9ad8\uff0c\u4f46\u6027\u80fd\u4e0a\u76f8\u5e94\u4e5f\u4f1a\u6709\u4e00\u5b9a\u7684\u63d0\u5347\uff0c\u9002\u5408\u539f\u672c\u5c31\u4ee5 RTC \u6a21\u5f0f\u8fd0\u884c\u7684\u5e94\u7528\u79fb\u690d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\u7684\uff0c\u8be5\u6a21\u5f0f\u9664\u4e86\u5355\u8fdb\u7a0b\u8fd0\u884c\u65b9\u5f0f\u5916\uff0c\u540c\u65f6\u53ef\u4ee5<strong>\u652f\u6301\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u591a\u8fdb\u7a0b\u65b9\u5f0f\u8fd0\u884c<\/strong>\uff0c\u6bcf\u4e2a\u7528\u6237\u8fdb\u7a0b\u5bf9\u5e94\u4e00\u4e2a<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u7684\u5b9e\u4f8b\uff0c\u66f4\u591a\u4fe1\u606f\u53ef\u4ee5\u53c2\u8003\u9644\u5f55\u7684\u8fd0\u884c\u53c2\u6570\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f\u3011\u4ee5\u6b64\u9ed8\u8ba4\u65b9\u5f0f\u63a5\u5165 F-Stack \u7684\u5e94\u7528\u7a0b\u5e8f\u540c\u6837\u53ea\u80fd\u4f7f\u7528 F-Stack \u7684 socket \u7f51\u7edc\u63a5\u53e3\uff0c\u800c\u4e0d\u80fd\u4f7f\u7528\u7cfb\u7edf\u7684 socket \u63a5\u53e3\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">hook \u7cfb\u7edf epoll \u63a5\u53e3<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4ed6\u540c\u9ed8\u8ba4\u7684 PIPELINE \u6a21\u5f0f\uff0c\u53ef\u4ee5\u53c2\u8003 DEMO \u7a0b\u5e8f<code>helloworld_stack_epoll_thread_socket<\/code>\uff0c \u4ee3\u7801\u6587\u4ef6\u4e3a<code>main_stack_epoll_thread_socket.c<\/code>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528 kqueue<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4ed6\u540c\u9ed8\u8ba4\u7684 PIPELINE \u6a21\u5f0f\uff0c\u53ef\u4ee5\u53c2\u8003 DEMO \u7a0b\u5e8f<code>helloworld_stack_thread_socket<\/code>\uff0c \u4ee3\u7801\u6587\u4ef6\u4e3a<code>main_stack_thread_socket.c<\/code>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">FF_KERNEL_EVENT \u6a21\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u6a21\u5f0f\u53ef\u4ee5\u540c\u65f6\u652f\u6301 F-Stack \u548c\u7cfb\u7edf\u5185\u6838\u7684 socket \u63a5\u53e3\uff0c\u9700\u8981\u8bbe\u7f6e\u989d\u5916\u7684\u7f16\u8bd1\u53c2\u6570\u540e\u6765\u7f16\u8bd1<code>libff_syscall.so<\/code>\u624d\u80fd\u5f00\u542f\uff0c\u53ef\u4ee5\u5728<code>adapter\/sysctall\/Makefile<\/code>\u4e2d\u4f7f\u80fd<code>FF_KERNEL_EVENT<\/code>\u6216\u6267\u884c\u4ee5\u4e0b shell \u547d\u4ee4\u6765\u5f00\u542f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_KERNEL_EVENT=1<br>make clean;make all<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6b64\u6a21\u5f0f\u4e0b\uff0c<code>epoll<\/code>\u76f8\u5173\u63a5\u53e3\u5728\u8c03\u7528 F-Stack \u63a5\u53e3\u7684\u540c\u65f6\u4f1a\u8c03\u7528\u7cfb\u7edf\u5185\u6838\u7684\u76f8\u5173\u63a5\u53e3\uff0c\u5e76\u5c06 F-Stack \u8fd4\u56de\u7684 fd \u4e0e\u7cfb\u7edf\u5185\u6838\u8fd4\u56de\u7684 fd \u5efa\u7acb\u6620\u5c04\u5173\u7cfb\uff0c\u4e3b\u8981\u4e3a\u4e86\u652f\u6301\u4e24\u4e2a\u573a\u666f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6709\u63a7\u5236 fd \u4e0e \u6570\u636e fd \u4f7f\u7528\u76f8\u540c\u7684 epoll fd\uff0c \u5982 Nginx\u3002<\/li><li>\u5e0c\u671b\u672c\u673a\u4e5f\u53ef\u4ee5\u540c\u65f6\u8bbf\u95ee\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u76d1\u542c\u7684\u7f51\u7edc\u63a5\u53e3\u3002<ul><li>\u5982\u679c\u5e0c\u671b\u5355\u72ec\u4e0e\u672c\u673a\u7cfb\u7edf\u5185\u6838\u8fdb\u884c\u666e\u901a\u7f51\u7edc\u901a\u4fe1\uff0c\u9700\u8981\u989d\u5916\u8c03\u7528<code>socket<\/code>\u63a5\u53e3\uff0c\u5e76\u9700\u8981\u6307\u5b9a<code>type | SOCK_KERNEL<\/code>\u53c2\u6570\uff0c\u5e76\u4e3a\u8fd4\u56de\u7684 fd \u5355\u72ec\u8c03\u7528 <code>bind()<\/code>\u3001<code>listen()<\/code>\u3001<code>epoll_ctl()<\/code>\u7b49\u63a5\u53e3\uff0c\u53c2\u8003 DEMO \u7a0b\u5e8f<code>helloworld_stack_epoll_kernel<\/code>\uff0c \u4ee3\u7801\u6587\u4ef6\u4e3a<code>main_stack_epoll_kernel.c<\/code><\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f1\u3011F-Stack \u4e2d FreeBSD \u7684\u5185\u6838\u53c2\u6570 <code>kern.maxfiles<\/code>\u4e0d\u5e94\u8be5\u5927\u4e8e 65536\uff08\u539f\u9ed8\u8ba4\u503c\u4e3a 33554432\uff09\uff0c\u4ee5\u4fdd\u8bc1 F-Stack \u7684 epoll fd \u5230\u7cfb\u7edf\u5185\u6838\u7684 epoll fd \u7684\u6b63\u786e\u6620\u5c04\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f2\u3011Nginx \u7684\u65e0\u7f1d\u63a5\u5165\u9700\u8981\u5f00\u542f\u6b64\u6a21\u5f0f\uff0c\u56e0\u4e3a\u5728 Nginx \u4e2d\u6709\u591a\u4e2a\u63a7\u5236 fd \u4e0e \u6570\u636e fd \u4f7f\u7528\u76f8\u540c\u7684 epoll fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">FF_MULTI_SC \u6a21\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5\u6a21\u5f0f\u4e3a Nginx \u7b49\u4f7f\u7528\u5185\u6838<code>SO_REUSEPORT<\/code>\u4e14<code>fork<\/code>\u5b50\u8fdb\u7a0b worker \u8fd0\u884c\u7b49\u7279\u6b8a\u7684\u8bbe\u7f6e\u4e3a\u8bbe\u7f6e\uff0c\u9700\u8981\u8bbe\u7f6e\u989d\u5916\u7684\u7f16\u8bd1\u53c2\u6570\u540e\u6765\u7f16\u8bd1<code>libff_syscall.so<\/code>\u624d\u80fd\u5f00\u542f\uff0c\u53ef\u4ee5\u5728<code>adapter\/sysctall\/Makefile<\/code>\u4e2d\u4f7f\u80fd<code>FF_MULTI_SC<\/code>\u6216\u6267\u884c\u4ee5\u4e0b shell \u547d\u4ee4\u6765\u5f00\u542f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_MULTI_SC=1<br>make clean;make all<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6b64\u6a21\u5f0f\u4e0b\uff0c\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u4e0e<code>fstack<\/code>\u5b9e\u4f8b\u76f8\u5173\u8054\u7684\u4e0a\u4e0b\u6587<code>sc<\/code>\u9664\u4e86\u4fdd\u5b58\u5728\u5168\u5c40\u53d8\u91cf<code>sc<\/code>\u4e2d\u4e4b\u5916\uff0c\u4f1a\u989d\u5916\u4fdd\u5b58\u5728\u5168\u5c40\u7684<code>scs<\/code>\u6570\u7ec4\u4e2d\uff0c\u5728<code>fork()<\/code>\u5b50\u8fdb\u7a0b worker \u65f6\u4f1a\u4f7f\u7528 <code>current_worker_id<\/code>\u8bbe\u7f6e<code>sc<\/code>\u53d8\u91cf\u4e3a\u5bf9\u5e94 worker \u8fdb\u7a0b fd \u5bf9\u5e94\u7684 sc\uff0c\u4f9b\u5b50\u8fdb\u7a0b\u590d\u5236\u53ca\u4f7f\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx \u7684<code>reuseport<\/code>\u6a21\u5f0f\u7684\u4e3b\u8981\u6d41\u7a0b\u4e3a\uff0c\u4e3b\u8fdb\u7a0b\u4e3a\u6bcf\u4e2a worker \u5206\u522b\u8c03\u7528 <code>socket()<\/code>\u3001<code>bind()<\/code>\u3001<code>listen()<\/code>\u7b49\u63a5\u53e3\uff0c\u5e76\u590d\u5236\u5230 worker \u8fdb\u7a0b\uff0c\u800c\u540e woker \u8fdb\u7a0b\u5404\u81ea\u8c03\u7528<code>epoll<\/code>\u76f8\u5173\u63a5\u53e3\u5904\u7406\u5404\u81ea\u7684 fd, \u9700\u8981\u5404\u81ea fd \u5bf9\u5e94\u7684\u4e0a\u4e0b\u6587 sc \u624d\u80fd\u6b63\u786e\u8fd0\u884c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f\u3011Nginx \u7684\u65e0\u7f1d\u63a5\u5165\u9700\u8981\u540c\u65f6\u5f00\u542f <code>FF_THREAD_SOCKET<\/code> \u548c <code>FF_MULTI_SC<\/code> \u6a21\u5f0f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nginx \u63a5\u5165<code>libff_syscall.so<\/code>\u4ecb\u7ecd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx(\u4ee5 F-Stack \u9ed8\u8ba4\u643a\u5e26\u7684 Nginx-1.16.1 \u4e3a\u4f8b)\u76ee\u524d\u53ef\u4ee5\u4e0d\u4fee\u6539\u4efb\u4f55\u4ee3\u7801\u76f4\u63a5\u4ee5<code>LD_PRELOAD<\/code>\u52a8\u6001\u5e93<code>libff_syscall.so<\/code>\u7684\u65b9\u5f0f\u63a5\u5165 F-Stack\uff0c\u4ee5\u4e0b\u4e3a\u4e3b\u8981\u6b65\u9aa4\u53ca\u6548\u679c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7f16\u8bd1<code>libff_syscall.so<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9700\u8981\u540c\u65f6\u5f00\u542f <code>FF_THREAD_SOCKET<\/code> \u548c <code>FF_MULTI_SC<\/code> \u6a21\u5f0f\u8fdb\u884c\u7f16\u8bd1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_PATH=\/data\/f-stack<br>export PKG_CONFIG_PATH=\/usr\/lib64\/pkgconfig:\/usr\/local\/lib64\/pkgconfig:\/usr\/lib\/pkgconfig<br>\u200b<br>cd \/data\/f-stack\/adapter\/sysctall<br>export FF_KERNEL_EVENT=1<br>export FF_MULTI_SC=1<br>make clean;make all<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u914d\u7f6e<code>nginx.conf<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u4e3a\u4e3b\u8981\u9700\u8981\u6ce8\u610f\u53ca\u4fee\u6539\u7684\u76f8\u5173\u914d\u7f6e\u53c2\u6570\u793a\u4f8b\uff08\u975e\u5168\u91cf\u53c2\u6570\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">user  root;<br>worker_processes  4; # worker \u6570\u91cf<br>worker_cpu_affinity 10000 100000 1000000 10000000; # \u8bbe\u7f6e CPU \u4eb2\u548c\u6027<br>\u200b<br>events {<br> &nbsp;  worker_connections  1024;<br> &nbsp;  multi_accept on; # epoll \u662f\u5c01\u88c5 kqueue \u63a5\u53e3\uff0c\u5fc5\u987b\u8981\u5f00\u542f<br> &nbsp;  use epoll;<br>}<br>\u200b<br>http {<br>    access_log  off; # \u5173\u95ed\u8bbf\u95ee\u65e5\u5fd7\uff0c\u7528\u4e8e\u63d0\u9ad8\u6d4b\u8bd5\u65f6\u7684\u7f51\u7edc\u6027\u80fd\uff0c\u5426\u5219\u6bcf\u6b21\u8bf7\u6c42\u90fd\u9700\u8981\u989d\u5916\u8c03\u7528\u7cfb\u7edf\u7684 write() \u63a5\u53e3\u8bb0\u5f55\u8bbf\u95ee\u65e5\u5fd7<br>\u200b<br>    sendfile &nbsp; &nbsp; &nbsp;  off; # \u4f7f\u7528 F-Stack \u65f6\u9700\u8981\u5173\u95ed<br>    <br>    keepalive_timeout  0; # \u89c6\u957f\u8fde\u63a5\/\u77ed\u94fe\u63a5\u7684\u4e1a\u52a1\u9700\u8981\u8c03\u6574<br> &nbsp;  #keepalive_timeout  65;<br> &nbsp;  #keepalive_requests 200; # \u9ed8\u8ba4\u6bcf\u4e2a\u957f\u8fde\u63a5\u6700\u591a 100 \u4e2a\u8bf7\u6c42\uff0c\u89c6\u4e1a\u52a1\u9700\u8981\u8c03\u6574\uff0c\u957f\u8fde\u63a5\u65f6\u9002\u5f53\u63d0\u9ad8\u6b64\u503c\u53ef\u4ee5\u7565\u5fae\u63d0\u9ad8\u6027\u80fd<br> &nbsp; &nbsp;<br> &nbsp;  server {<br> &nbsp; &nbsp; &nbsp;  listen &nbsp; &nbsp; &nbsp; 80 reuseport; # \u5e94\u8be5\u8bbe\u7f6e reuseport\uff0c\u4e0e\u4f7f\u7528\u7cfb\u7edf\u7684\u5185\u6838\u7684 reuseport \u884c\u4e3a\u4e0d\u592a\u4e00\u81f4\uff0c\u4f46\u90fd\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd<br>\u200b<br> &nbsp; &nbsp; &nbsp;  access_log off;<br> &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp;  location \/ {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  #root &nbsp; html;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  #index  index.html index.htm;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return 200 \"0123456789abcdefghijklmnopqrstuvwxyz\"; # \u76f4\u63a5\u8fd4\u56de\u6570\u636e\u7528\u4ee5\u6d4b\u8bd5\u5355\u7eaf\u7684\u7f51\u7edc\u6027\u80fd<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  \uff5d<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010\u6ce8\u610f\u3011\u6b64\u5904\u7684 <code>reuseport<\/code>\u4f5c\u7528\u662f\u4f7f\u7528\u591a\u4e2a\u4e0d\u540c\u7684 socket fd, \u800c\u6bcf\u4e2a fd \u53ef\u4ee5\u5bf9\u63a5\u4e0d\u540c\u7684<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u7684\u4e0a\u4e0b\u6587<code>sc<\/code>\u6765\u5206\u6563\u8bf7\u6c42\uff0c\u4ece\u800c\u8fbe\u5230\u63d0\u9ad8\u6027\u80fd\u7684\u76ee\u7684\u3002\u4e0e\u7cfb\u7edf\u5185\u6838\u7684<code>reuseport<\/code>\u884c\u4e3a\u5f02\u66f2\u540c\u5de5\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8fd0\u884c<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5047\u8bbe\u8fd0\u884c4\u7ec4 Nginx &#8211; fstack \u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u7b80\u5355\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u8fd0\u884c fstack \u5b9e\u4f8b<\/li><li>\u8bbe\u7f6e<code>config.ini<\/code>\u4e2d\u7684<code>lcore_mask=f00<\/code>\uff0c\u5373\u4f7f\u7528 CPU \u6838\u5fc3 9-11\uff0c \u5176\u4ed6\u914d\u7f6e\u6309\u7167\u6807\u51c6 F-Stack \u914d\u7f6e\u8fdb\u884c\u3002<\/li><li>\u53c2\u8003\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 fstack \u5b9e\u4f8b\uff0c\u5e76\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u5f85 fstack \u4e3b\u8fdb\u7a0b\u548c\u5b50\u8fdb\u7a0b\u90fd\u542f\u52a8\u5b8c\u6210<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  cd \/data\/f-stack\n  bash .\/start.sh -b adapter\/syscall\/fstack<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u8fd0\u884c Nginx<\/li><li>\u53c2\u8003\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e<code>libff_syscall.so<\/code>\u6240\u9700\u7684\u73af\u5883\u53d8\u91cf<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  export LD_PRELOAD=\/data\/f-stack\/adapter\/syscall\/libff_syscall.so # \u8bbe\u7f6e LD_PRELOAD libff_syscall.so\n  export FF_NB_FSTACK_INSTANCE=4 # \u8bbe\u7f6e\u6709 4 \u4e2a fstack \u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\uff0c\u524d\u9762 nginx.conf \u4e2d\u4e5f\u914d\u7f6e\u4e86 4 \u4e2aworker<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u542f\u52a8 Nginx<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/usr\/local\/nginx\/sbin\/nginx # \u542f\u52a8 Nginx<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6027\u80fd\u5bf9\u6bd4<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u6d4b\u8bd5\u73af\u5883<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">CPU\uff1aIntel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz * 2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f51\u5361\uff1aIntel Corporation Ethernet Controller 10-Gigabit X540-AT2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OS  \uff1aTencentOS Server 3.2 (Final)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5185\u6838\uff1a5.4.119-1-tlinux4-0009.1 #1 SMP Sun Jan 23 22:20:03 CST 2022 x86_64 x86_64 x86_64 GNU\/Linux<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Nginx\u957f\u8fde\u63a5<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"454\" src=\"https:\/\/lovelyping.com\/wp-content\/uploads\/2023\/05\/nginx-keep-alive-1.png\" alt=\"\" class=\"wp-image-272\" srcset=\"https:\/\/lovelyping.com\/wp-content\/uploads\/2023\/05\/nginx-keep-alive-1.png 749w, https:\/\/lovelyping.com\/wp-content\/uploads\/2023\/05\/nginx-keep-alive-1-300x182.png 300w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>body \u5927\u5c0f\u4e3a 602 \u5b57\u8282(\u4e0d\u5305\u62ec http \u5934\u7b49)\u3002<\/li><li>LD_PRELOAD \u5b9e\u9645\u4f7f\u7528\u7684 CPU \u4e3a\u51e0\u4e4e\u6a2a\u8f74 CPU \u6838\u5fc3\u6570\u7684\u53cc\u500d\uff0c\u7cfb\u7edf\u5185\u6838\u5747\u8861\u8f6f\u4e2d\u65ad\u5b9e\u9645\u4f7f\u7528\u7684 CPU \u4e5f\u8fdc\u9ad8\u4e8e worker \u6570\u91cf\u5bf9\u5e94\u7684 CPU \u6838\u5fc3\u6570\u91cf\u3002<\/li><li>\u9650\u4e8e\u65f6\u95f4\u6240\u9650\uff0c\u5176\u4e2d LD_PRELOAD \u7684\u6d4b\u8bd5\u6570\u636e\u4e3a\u4ee5\u4e0a\u6d4b\u8bd5\u73af\u5883\u7684\u6570\u636e\uff0c\u5176\u4ed6\u4e3a\u5386\u53f2 40G \u6d4b\u8bd5\u73af\u5883\u7684\u6570\u636e\uff0c\u540e\u7eed\u4f1a\u66f4\u65b0\u4e3a\u76f8\u540c\u6d4b\u8bd5\u73af\u5883\u7684\u6570\u636e\u3002<\/li><li>\u53d7\u7f51\u5361\u786c\u4ef6\u6240\u9650\uff0c8\u6838 LD_PRELOAD \u6d4b\u8bd5\u5e26\u5bbd<strong>\u5df2\u7ecf\u63a5\u8fd1 10G \u7f51\u5361\u7ebf\u901f<\/strong>(\u670d\u52a1\u7aef\u51fa\u5e26\u5bbd9.xG\uff0c148\u4e07 RPS), \u5bfc\u81f4\u7684\u4e0e\u6807\u51c6 F-Stack \u7684\u6570\u636e\u5dee\u5f02\uff0c\u5b9e\u9645CPU\u5c1a\u6709\u4e00\u4e9b\u7a7a\u95f2\uff0c\u540e\u7eed\u5e94\u4f7f\u7528 40G\/100G \u7f51\u5361\u8fdb\u884c\u5bf9\u6bd4\u6d4b\u8bd5<\/li><li>pkt_tx_delay \u53c2\u6570\u4e3a 100us\u3002<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Nginx\u77ed\u94fe\u63a5<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"483\" height=\"291\" src=\"https:\/\/lovelyping.com\/wp-content\/uploads\/2023\/05\/nginx-close.png\" alt=\"\" class=\"wp-image-269\" srcset=\"https:\/\/lovelyping.com\/wp-content\/uploads\/2023\/05\/nginx-close.png 483w, https:\/\/lovelyping.com\/wp-content\/uploads\/2023\/05\/nginx-close-300x181.png 300w\" sizes=\"auto, (max-width: 483px) 100vw, 483px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>body \u5927\u5c0f\u4e3a 602 \u5b57\u8282(\u4e0d\u5305\u62ec http \u5934\u7b49)\u3002<\/li><li>LD_PRELOAD \u5b9e\u9645\u4f7f\u7528\u7684 CPU \u4e3a\u51e0\u4e4e\u6a2a\u8f74 CPU \u6838\u5fc3\u6570\u7684\u53cc\u500d\uff0c\u7cfb\u7edf\u5185\u6838\u5747\u8861\u8f6f\u4e2d\u65ad\u5b9e\u9645\u4f7f\u7528\u7684 CPU \u4e5f\u8fdc\u9ad8\u4e8e worker \u6570\u91cf\u5bf9\u5e94\u7684 CPU \u6838\u5fc3\u6570\u91cf\u3002<\/li><li>\u53d7 CPU \u786c\u4ef6\u6240\u9650\uff0812C24HT * 2\uff09\uff0cLD_PRELOAD \u6d4b\u8bd5\u53ea\u80fd\u6d4b\u8bd512\u7ec4\u5e94\u7528\u5b9e\u4f8b\u7ec4\uff0c\u5373\u4f7f\u7528\u4e86\u5168\u90e8 CPU \u7684\u7269\u7406\u6838\u5fc3\uff0c\u65e0\u6cd5\u8fdb\u884c\u66f4\u591a\u5b9e\u4f8b\u7ec4\u7684\u6d4b\u8bd5\u3002<\/li><li>8\u6838\u4e4b\u540e LD_PRELOAD \u7684\u6027\u80fd\u4e0d\u5982\u6807\u51c6 F-Stack \u7684\u6027\u80fd\uff0c\u6700\u4e3b\u8981\u662f\u53d7\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u548cfstack\u5e94\u7528\u7a0b\u5e8f\u7684\u5339\u914d\u5ea6\u4e0d\u9ad8(<code>ff_handle_each_context<\/code>\u7684\u5faa\u73af\u6b21\u6570\u53ca\u65f6\u95f4\u7b49)\u5f71\u54cd\u5f88\u5927\uff0c\u5e76\u672a\u5b8c\u5168\u8fbe\u5230\u6027\u80fd\u6781\u81f4\uff0c\u5982\u679c\u6301\u7eed\u7684\u7cbe\u7ec6\u5316\u8c03\u6574\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u6027\u80fd\uff0c\u4f46\u662f\u901a\u7528\u6027\u4e5f\u4e0d\u9ad8\u3002<\/li><li>pkt_tx_delay \u53c2\u6570\u7531 100us \u8c03\u6574\u5230 50us\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u9644\u5f55\uff1a\u8be6\u7ec6\u53c2\u6570\u4ecb\u7ecd<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u7f16\u8bd1\u53c2\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6bb5\u603b\u4f53\u4ecb\u7ecd\u5404\u4e2a\u7f16\u8bd1\u9009\u9879\uff0c\u6240\u6709\u53c2\u6570\u90fd\u53ef\u4ee5\u5728<code>adapter\/sysctall\/Makefile<\/code>\u4e2d\u5f00\u542f\u6216\u901a\u8fc7 shell \u547d\u4ee4\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u6765\u5f00\u542f\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">DEBUG<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542f\u6216\u5173\u95ed DEBUG \u6a21\u5f0f\uff0c\u4e3b\u8981\u5f71\u54cd\u4f18\u5316\u548c\u65e5\u5fd7\u8f93\u51fa\u7b49\uff0c \u9ed8\u8ba4\u5173\u95ed\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export DEBUG=-O0 -gdwarf-2 -g3<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ed8\u8ba4\u7684\u4f18\u5316\u53c2\u6570\u4e3a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">-g -O2 -DNDEBUG<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">FF_THREAD_SOCKET<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u662f\u5426\u5f00\u542f\u7ebf\u7a0b\u7ea7\u4e0a\u4e0b\u6587<code>sc<\/code>\u53d8\u91cf\uff0c\u5982\u679c\u5f00\u542f\uff0c\u5219 socket \u76f8\u5173 fd \u53ea\u80fd\u5728\u672c\u7ebf\u7a0b\u4e2d\u8c03\u7528\uff0c\u4e00\u822c\u53ef\u4ee5\u7565\u5fae\u63d0\u9ad8\u6027\u80fd\uff0c \u9ed8\u8ba4\u5173\u95ed\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_THREAD_SOCKET=1<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">FF_KERNEL_EVENT<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u662f\u5426\u5f00\u542f<code>epoll<\/code>\u76f8\u5173\u63a5\u53e3\u5728\u8c03\u7528 F-Stack \u63a5\u53e3\u7684\u540c\u65f6\u8c03\u7528\u7cfb\u7edf\u5185\u6838\u7684\u76f8\u5173\u63a5\u53e3\uff0c\u5e76\u5c06 F-Stack \u8fd4\u56de\u7684 fd \u4e0e\u7cfb\u7edf\u5185\u6838\u8fd4\u56de\u7684 fd \u5efa\u7acb\u6620\u5c04\u5173\u7cfb\uff0c \u9ed8\u8ba4\u5173\u95ed\uff0c\u4e3b\u8981\u4e3a\u4e86\u652f\u6301\u4e24\u4e2a\u573a\u666f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6709\u63a7\u5236 fd \u4e0e \u6570\u636e fd \u4f7f\u7528\u76f8\u540c\u7684 epoll fd\uff0c \u5982 Nginx\u3002<\/li><li>\u5e0c\u671b\u672c\u673a\u4e5f\u53ef\u4ee5\u540c\u65f6\u8bbf\u95ee\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u76d1\u542c\u7684\u7f51\u7edc\u63a5\u53e3\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_KERNEL_EVENT=1<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">FF_MULTI_SC<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6b64\u6a21\u5f0f\u4e0b\uff0c\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u4e0e<code>fstack<\/code>\u5b9e\u4f8b\u76f8\u5173\u8054\u7684\u4e0a\u4e0b\u6587<code>sc<\/code>\u9664\u4e86\u4fdd\u5b58\u5728\u5168\u5c40\u53d8\u91cf<code>sc<\/code>\u4e2d\u4e4b\u5916\uff0c\u4f1a\u989d\u5916\u4fdd\u5b58\u5728\u5168\u5c40\u7684<code>scs<\/code>\u6570\u7ec4\u4e2d\uff0c\u5728<code>fork()<\/code>\u5b50\u8fdb\u7a0b worker \u65f6\u4f1a\u4f7f\u7528 <code>current_worker_id<\/code>\u8bbe\u7f6e<code>sc<\/code>\u53d8\u91cf\u4e3a\u5bf9\u5e94 worker \u8fdb\u7a0b fd \u5bf9\u5e94\u7684 sc\uff0c\u4f9b\u5b50\u8fdb\u7a0b\u590d\u5236\u53ca\u4f7f\u7528\u3002 \u9ed8\u8ba4\u5173\u95ed\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_KERNEL_EVENT=1<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">FF_USE_RING_IPC<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u662f\u5426\u5c06 <code>libff_syscall.so<\/code> \u4e0e <code>fstack<\/code> \u5b9e\u4f8b\u4e4b\u95f4\u7684 IPC \u4ece\u539f\u6709\u7684\u4fe1\u53f7\u91cf+\u5171\u4eab\u5185\u5b58\u65b9\u6848\u5207\u6362\u4e3a lock-free \u7684 DPDK SPSC <code>rte_ring<\/code>\uff0c\u9ed8\u8ba4\u5173\u95ed\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_USE_RING_IPC=1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u542f\u7528\u8be5\u5f00\u5173\u65f6\uff0cv3.4 \u7684 ring \u8def\u5f84\u4f18\u5316\u5747\u4f5c\u4e3a\u9ed8\u8ba4\u884c\u4e3a\u5408\u5165\uff08\u57fa\u4e8e <code>sc-&gt;completion<\/code> \u7684\u5524\u9192\u3001\u5185\u8054 <code>rte_ring_empty<\/code> \u5feb\u901f\u7a7a\u5224\u65ad\u3001\u4ee5\u53ca\u5185\u8054 dequeue burst \u4e0e dispatch\uff09\uff0c\u65e0\u9700\u989d\u5916\u5b50\u5f00\u5173\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6027\u80fd\u6458\u8981\uff1a\u5728 LD_PRELOAD + <code>FF_MULTI_SC<\/code> \u4e14 nginx worker \u4e0e fstack \u5b9e\u4f8b 1:1 \u7684\u90e8\u7f72\u5f62\u6001\u4e0b\uff0cring \u4e0e sem \u5728 1 \/ 2 \/ 4 \u6838\u77ed\/\u957f\u8fde\u63a5\u5b9e\u6d4b\u4e2d\u76f8\u5dee\u5747\u5728 2\u20134% \u4ee5\u5185\u3002Ring \u8def\u5f84\u7684\u4e3b\u8981\u4ef7\u503c\u662f\u7ed3\u6784\u6027\u7684\uff1a\u4e3b\u5faa\u73af lock-free\u3001\u5929\u7136\u514d\u75ab\u542f\u52a8\u671f\u81ea\u65cb\u9501\u9965\u997f\u3001\u4e14\u4e0d\u9700\u8981 fstack \u4fa7\u7684 zone \u7ea7\u9501\u3002\u5bf9\u4e8e\u6bcf\u4e2a worker \u62e5\u6709\u72ec\u7acb fstack \u5b9e\u4f8b\u7684\u751f\u4ea7\u90e8\u7f72\uff0csem \u8def\u5f84\u4ecd\u662f\u63a8\u8350\u914d\u7f6e\uff1bring \u8def\u5f84\u4e3b\u8981\u4f5c\u4e3a\u672a\u6765&#8221;\u5355\u8fdb\u7a0b\u5185\u591a\u7ebf\u7a0b\u5171\u4eab sc&#8221;\u6216&#8221;\u591a\u8fdb\u7a0b\u95f4\u5171\u4eab sc\uff08worker \u6570\u91cf\u591a\u4e8e fstack \u5b9e\u4f8b\u6570\u91cf\uff09&#8221;\u6269\u5c55\u573a\u666f\u7684\u9884\u7559\u80fd\u529b\u3002\u5b8c\u6574\u8bbe\u8ba1\u4e0e\u6027\u80fd\u5206\u6790\u89c1 <code>docs\/ld_preload_ring_spec\/<\/code>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8fd0\u884c\u53c2\u6570<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u4e00\u4e9b\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u7684\u53c2\u6570\u503c\uff0c\u5982\u679c\u540e\u7eed\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u7684\u8bdd\u53ef\u80fd\u9700\u8981\u4fee\u6539\u539f\u6709\u5e94\u7528\uff0c\u6240\u4ee5\u6682\u65f6\u4f7f\u7528\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u65b9\u5f0f\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">LD_PRELOAD<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u7f6e LD_PRELOAD \u7684\u8fd0\u884c\u5e93\uff0c\u518d\u8fd0\u884c\u5b9e\u9645\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export LD_PRELOAD=\/data\/f-stack\/adapter\/syscall\/libff_syscall.so<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u60f3\u901a\u8fc7<code>gdb<\/code>\u8c03\u8bd5\u5e94\u7528\u7a0b\u5e8f\uff0c\u5219\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export LD_PRELOAD=<br>gdb .\/helloworld_stack_epoll<br>(gdb) set exec-wrapper env 'LD_PRELOAD=\/data\/f-stack\/adapter\/syscall\/libff_syscall.so'<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">FF_NB_FSTACK_INSTANCE<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u7f6e<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u6570\uff0c\u7528\u4e8e\u548c\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u7684\u8fdb\u7a0b\/\u7ebf\u7a0b\u7b49 worker \u6570\u91cf\u76f8\u5339\u914d\uff0c\u9ed8\u8ba41\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_NB_FSTACK_INSTANCE=4<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5efa\u8bae\u7528\u6237\u5e94\u7528\u7a0b\u5e8f worker \u6570\u91cf\u4e0e<code>fstack<\/code>\u5b9e\u4f8b\u5e94\u7528\u7a0b\u5e8f\u5c3d\u91cf 1:1 \u914d\u7f6e\uff0c\u53ef\u4ee5\u8fbe\u5230\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">FF_INITIAL_LCORE_ID<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u914d\u7f6e\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u7684 CPU \u4eb2\u548c\u6027\u7ed1\u5b9a\u7684\u8d77\u59cb CPU \u903b\u8f91 ID\uff0c16\u8fdb\u5236\uff0c\u9ed8\u8ba40x4\uff080b0100\uff09\uff0c\u5373 CPU 2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_INITIAL_LCORE_ID=0x4<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u914d\u7f6e CPU \u4eb2\u548c\u6027\uff0c\u5219\u53ef\u4ee5\u5ffd\u7565\u8be5\u53c2\u6570\uff0c\u5982 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684<code>worker_cpu_affinity<\/code>\u53c2\u6570\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">FF_PROC_ID<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u914d\u7f6e\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u7684\u8fdb\u7a0b ID\uff0c\u53ef\u4ee5\u914d\u5408<code>FF_INITIAL_LCORE_ID<\/code>\u53c2\u6570\u8bbe\u7f6e CPU \u4eb2\u548c\u6027\u7684\u7ed1\u5b9a\uff0c10\u8fdb\u5236\u9012\u589e\uff0c\u9ed8\u8ba40\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export FF_PROC_ID=1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u914d\u7f6e CPU \u4eb2\u548c\u6027\uff0c\u5219\u53ef\u4ee5\u5ffd\u7565\u8be5\u53c2\u6570\uff0c\u5982 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684<code>worker_cpu_affinity<\/code>\u53c2\u6570\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u81f4\u8c22<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7279\u522b\u611f\u8c22\u4ee5\u4e0b\u5916\u90e8\u8d21\u732e\u8005\u81ea 2023-05-04 \u4ee5\u6765\u901a\u8fc7 pull request \u4e0e commit \u5bf9 <code>libff_syscall.so<\/code> \u505a\u51fa\u7684\u5b9e\u8d28\u6027\u6269\u5c55\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><a href=\"https:\/\/github.com\/liujinhui-job\">liujinhui-job<\/a><\/strong> \u2014\u2014 \u81ea 2025 \u5e74\u4ee5\u6765\u8d21\u732e\u6700\u591a\u7684\u5916\u90e8\u5f00\u53d1\u8005\uff0c\u4e3b\u8981\u5de5\u4f5c\u5305\u62ec\uff1a<code>fork<\/code> \u652f\u6301\uff08PR #887\uff09\u3001<code>accept4<\/code> \u53ca <code>SOCK_CLOEXEC<\/code> \/ <code>SOCK_NONBLOCK<\/code> \u652f\u6301\u3001<code>__recv_chk<\/code> \/ <code>__read_chk<\/code> \/ <code>__recvfrom_chk<\/code> \u7cfb\u5217 <code>_FORTIFY_SOURCE<\/code> hook\u3001<code>epoll<\/code> polling \u6a21\u5f0f\u3001<code>ff_hook_recvfrom<\/code> \u4e2d <code>sh_fromlen<\/code> \u672a\u521d\u59cb\u5316\u4fee\u590d\uff08PR #872\uff09\uff0c\u4ee5\u53ca\u56f4\u7ed5 <code>ff_hook_syscall.c<\/code>\u3001<code>ff_socket_ops.c<\/code>\u3001<code>ff_socket_ops.h<\/code>\u3001<code>ff_linux_syscall.c<\/code>\u3001<code>ff_sysproto.h<\/code>\u3001<code>ff_declare_syscalls.h<\/code> \u4e0e <code>Makefile<\/code> \u7684\u4e00\u7cfb\u5217\u7ec6\u8282\u4f18\u5316\u3002<\/li><li><strong><a href=\"https:\/\/github.com\/zhaozihanzzh\">zhaozihanzzh<\/a><\/strong> \u2014\u2014 \u4fee\u590d <code>ff_hook_syscall.c<\/code> \u4e2d\u7684 cplen \u8ba1\u7b97\u9519\u8bef\uff08\u5e76\u5c06\u4ee3\u7801\u98ce\u683c\u7edf\u4e00\u5230 <code>ff_hook_accept<\/code>\uff09\uff0c\u4ee5\u53ca\u5728 <code>FF_KERNEL_EVENT<\/code> \u6a21\u5f0f\u4e0b <code>ff_hook_close<\/code> \u5185\u7684 kernel epoll fd \u6cc4\u6f0f\u95ee\u9898\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u8ff0\u8d21\u732e\u663e\u8457\u63d0\u5347\u4e86 LD_PRELOAD \u8def\u5f84\u7684\u5b8c\u6574\u6027\u3001\u6b63\u786e\u6027\u4ee5\u53ca\u5bf9 Nginx \u7684\u53cb\u597d\u7a0b\u5ea6\uff0c\u6b22\u8fce\u793e\u533a\u7ee7\u7eed\u63d0\u4ea4 pull request \u4e0e\u5efa\u8bae\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u914d\u7f6e CPU \u4eb2\u548c\u6027\uff0c\u5219\u53ef\u4ee5\u5ffd\u7565\u8be5\u53c2\u6570\uff0c\u5982 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684<code>worker_cpu_affinity<\/code>\u53c2\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2026.05.26\u672c\u6587\u7ae0\u5df2\u7ecf\u66f4\u65b0 \u8df3\u7968\u8bb8\u4e45\u8bb8\u4e45\u7684LD_PRELOAD\u529f\u80fd\u6a21\u5757\uff08\u540e\u7eed\u4ee5 libff_sysca &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lovelyping.com\/?p=267\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cF-Stack LD_PRELOAD \u4ecb\u7ecd\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[21,31,11],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-f-stack","tag-f-stack","tag-ld_preload","tag-nginx"],"_links":{"self":[{"href":"https:\/\/lovelyping.com\/index.php?rest_route=\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelyping.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelyping.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelyping.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelyping.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":9,"href":"https:\/\/lovelyping.com\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":423,"href":"https:\/\/lovelyping.com\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/423"}],"wp:attachment":[{"href":"https:\/\/lovelyping.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelyping.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelyping.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}