The release of the F-Stack 2.0 project has been announced, which develops a version of the FreeBSD network stack tailored for isolated operation in user space as a library. The project was created by Tencent, the largest telecommunications company in China, and is used in its products and services. The code is written in C and distributed under the BSD license. It supports operation in both Linux and FreeBSD. The project also supports modified versions of Nginx 1.28 and the Redis 6.2.6 database, which demonstrate performance exceeding that of standard builds operating on the system network stack.
F-Stack allows applications to utilize their own local network stack, independent of the operating system's network stack, working in user space and interacting directly with network hardware. F-Stack is positioned as a solution that enhances the performance of network request handlers in scenarios where the default TCP/IP stack of the Linux kernel becomes a bottleneck and limits scalability. Theoretically, F-Stack enables reaching the maximum network performance possible for the used network card, and in some situations, it allows significantly increasing the number of minor network requests processed.
Performance improvements are achieved by eliminating operations such as copying network packets, thread scheduling, interrupt processing, and system calls. To interact with the network card, bypassing the operating system's kernel interfaces, the DPDK (Data Plane Development Kit) framework is utilized, which develops a set of libraries for low-level work with network adapters. DPDK allows reducing overhead and achieving a minimal number of CPU cycles when receiving or sending network packets.
The functionality of the TCP/IP stack corresponds to the FreeBSD 15 network stack and has been extracted from this operating system into an independent library. For application development, you can use the standard POSIX API (socket, epoll, kqueue) or a custom interface based on micro-threads that simplifies the creation of network applications and allows you to avoid complex asynchronous request handling logic. It can be used with unmodified applications through LD_PRELOAD.
The most notable changes in the new release are:
- The components of the network stack have been updated to FreeBSD 15 (previously FreeBSD 13 was used).
- A multi-threaded operation mode (thread_mode=1) has been implemented within a single process, complementing the previously available multi-process mode.
- A lightweight operation mode (primary_slim) has been added, in which the main process performs only basic initialization and coordination tasks, while packet reception and processing of receive/transmit queues (rx/tx) occur solely on the side of child processes.
- Support for hardware acceleration mechanisms has been added.
TSO (TCP Segmentation Offload) for offloading packet aggregation operations to the network card, with the option to fall back to software implementation. Improved TSO (TCP Segmentation Offload, offloading segment processing to the network card) support for IPv6. - The ability to change the MTU (Maximum Transmission Unit) size has been added, along with support for jumbo frames.
- Enhanced management capabilities for hardware acceleration of checksum calculations for sent packets.
- The function ff_zc_recv() for receiving data without intermediate buffering (zero-copy) has been added. The similar function ff_zc_send() for sending has been redesigned. It has been optimized and supplemented. IPv6 support The function ff_rss_check().
- An option FF_KERNEL_COEXIST has been added for working alongside the kernel's network stack.
- The ability to save traffic information in pcap dumps with nanosecond precision has been provided.
- New parameters idle_loop_interval, extra_eal_args, drain_ring_size, reload_heartbeat_timeout_ms, and reload_udp_idle_ms have been added to config.ini.
- In a specialized build of nginx, support has been implemented for reloading the configuration and updating the binary file without breaking connections (graceful_reload=1).
Source: opennet.ru
