Hello, World!

~ Enjoy Today ~

如何极致地压榨一颗 CPU 核心
通常当服务端工程师谈论 CPU 核心的时候,更多地时候在乎的是数量而不是质量,比如我们开发了一个 Java 服务的容器需要申请一个 4 核 32 GB 内存的套餐(4C32G),还开发了一个 Golang 服务需要 4C8G 的 quota(我真的不是在黑 Java),但我们绝大多数时候并不会关心底层的 4 个核心来自于 AMD 还是 Intel 品牌的 CPU, 更别说具体什么 Xeon 还是 EPYC 型号了。 因为大部分服务端的问题都可以水平扩容来得到解决,四颗核心不够了,那我们申请六颗核心就好了,......
数据的蒲公英——组播
组播与单播 组播(Multicast,又称群播、多播) 与单播 (Unicast) 都是数据传输的一种方式,如果要映射现实世界中的信息传递方式,单播可以类比为打电话,有人呼出电话然后有人接听,然后他们互相畅谈最后互道再见;而组播则更加类似于广播,电台的主播会在收音机的那一头说话,所有打开收音机的人都可以收到,你也可以随时关闭收音机,只能单方面的听到来自对方的声音。 虽然今天到处都是打电话的人,而我们已经很少能在身边看到广播......
动态链接函数调用是如何实现的
函数链接 根据函数在编译期间的链接方式, 我们可以将函数分为三种: 直接调用(Direct Call):这是最直接的一种方式,函数地址在编译时就已经确定,调用时直接跳转到目标地址。 静态链接(Static Linking):在编译时将库与程序合并,尽管在单个编译单元内不确定函数的具体地址,但在链接阶段会解析所有符号,最终生成的可执行文件包含所有必要的代码,无需依赖外部库。 动态链接(Dynamic Linking......
C/C++ & Python 融合之道
Python 解释器 正如软件系统通常分为定义与实现两部分,编程语言也是。 比如 C++ 标准是由国际标准化组织 ( ISO ) 下属的 ISO/IEC JTC1/SC22/WG21特别工作组制定的,最新标准为 C++ 20 (ISO/IEC 14882:2020),这是定义;而其实现则有 GNU 的 gcc、微软的 visual c++、Apple 发起的 clang 等等,任何人都可以按照定义去实现自己的实现。 Java 规范则是由 Oracle 主导的 JCP 所制定,有 Oracle Java SE、OpenJDK、Corretto、AdoptOpen 等大量......
Executable and Linkable Format
ELF Executable and Linkable Format,可执行与可链接格式,其一个很熟悉的身份就是 Linux 操作系统的标准可执行文件格式,在 Linux 上运行我们编写的代码时,就需要将其编译成 ELF 格式。 另外它还定义了共享库和核心转储文件的结构和布局。 ELF 文件格式在操作系统中起着重要的作用,它使得我们编写的代码能够被正确地编译、链接和执行。 此外,部分 Unix 系统,如: Solaris、FreeBSD 等也采用 ELF 作为其可执行文件格式。 ELF 文件格式被设计为可扩展和灵活的......
很快的共享内存
WHY 共享内存 进程间通信有许多种方式,不同的场景有不同的选择。 当通信内容非常简单的时候,可以考虑信号、信号量甚至 flock() 这种最基础的通信方式。 当需要传递不仅仅是信号这种规模的数据时,可以考虑 FIFO、MQ 等内核 API,也非常的简单易用 。 当我们的传输内容再进一步复杂,需要用“协议”去抽象这种复杂度的时候,Unix Domain Socket 会是一个不错的选择,比如常见的 gRPC over UDS;或者牺牲一点网络栈开销,直接使用基于 TCP / UDP 的 Socket 也非常......
Linux Kernel Debug Tips
Kernel Kernel undertakes the core Operating System job, which is the foundation of the current software ecosystem. So, knowing more about how the kernel works will contribute to the construction of our user mode system. The best method to learn software code is debugging while watching, software = code + data, know more about the runtime data while learning code can help us understand it better. However the Kernel is not a normal software system, we can’t add breakpoint and debug it through IDE debug button like other normal software, though we can implement it by kgdb + QEMU, it’ still too heavy, and not available for online systems. This article shares two lightweight kernel debugging tips, helps us observing it runtime status rapidly. Kernel Module Usally, our codes are runing in user mode. In Linux operating systems, the instruction of user mode program will run in level Ring 3 , they do not have the permission to acces the data in level Ring 0 high memory address space, which means that they can’t snoop the data inside Kernel. In that case, why not try to run our code inside the Kernel? It’s possible to edit the source code of kernel, adding log to print the information we concerned, but it’s a long tedious step.......