Tech Internals Meetup 2025: Algorithm of Massively Parallel Networking in C++
My talk is dedicated to the performance of C++ servers using an alternative to boost::asio for massively parallel network operations. boost::asio is effectively the standard for network programming in C++, but in rare cases, it may be unavailable or insufficient for various reasons. Drawing from my experience in high-performance projects, I developed a new task scheduling algorithm, built a networking library based on it, and am presenting them in this talk. The most interesting aspects include fair CPU load distribution, support for C++ coroutines, formal verification with TLA+, and reproducible benchmarks demonstrating an N-times speedup over boost::asio. The project is open-source: https://github.com/Gerold103/serverbox.
Feb 18, 2025380
C++ Russia 2025: Algorithm of Massively Parallel Networking in C++
Мой доклад посвящен производительности серверов на C++ с использованием альтернативы boost::asio для массово параллельной сетевой работы. Boost::asio — фактически стандарт для сетевого кода на C++, но в редких случаях он недоступен или недостаточен по разным причинам. Используя опыт работы над высокопроизводительными проектами, я разработал новый алгоритм планирования задач, построил на его основе сетевую библиотеку и представляю их в докладе. Самые интересные детали — справедливое распределение нагрузки на процессор, поддержка C++ корутин, формальная верификация на TLA+ и воспроизводимые бенчмарки, показывающие ускорение в N раз от boost::asio. Проект в открытом доступе: https://github.com/Gerold103/serverbox.
Jan 30, 2025730
C++ Russia 2024: First Aid Kit for C/C++ server performance
I categorize the primary sources of code performance degradation into three groups: - Thread contention. For instance, too hot mutexes, overly strict order in lock-free operations, and false sharing. - Heap utilization. Loss is often caused by frequent allocation and deallocation of large objects, and by the absence of intrusive containers at hand. - Network IO. Socket reads and writes are expensive due to being system calls. Also they can block the thread for a long time, resulting in hacks like adding tens or hundreds more threads. Such measures intensify contention, as well as CPU and memory usage, while neglecting the underlying issue. I present a series of concise and straightforward low-level recipes on how to gain performance via code optimizations. While often requiring just a handful of changes, the proposals might amplify the performance N-fold. The suggestions target the mentioned bottlenecks caused by certain typical mistakes. Proposed optimizations might render architectural changes not necessary, or even allow to simplify the setup if existing servers start coping with the load effortlessly. As a side effect, the changes can make the code cleaner and reveal more bottlenecks to investigate.
May 22, 20245511
FOSDEM 2024: First Aid Kit for C/C++ server performance
I categorize the primary sources of code performance degradation into three groups: - Thread contention. For instance, too hot mutexes, overly strict order in lock-free operations, and false sharing. - Heap utilization. Loss is often caused by frequent allocation and deallocation of large objects, and by the absence of intrusive containers at hand. - Network IO. Socket reads and writes are expensive due to being system calls. Also they can block the thread for a long time, resulting in hacks like adding tens or hundreds more threads. Such measures intensify contention, as well as CPU and memory usage, while neglecting the underlying issue. I present a series of concise and straightforward low-level recipes on how to gain performance via code optimizations. While often requiring just a handful of changes, the proposals might amplify the performance N-fold. The suggestions target the mentioned bottlenecks caused by certain typical mistakes. Proposed optimizations might render architectural changes not necessary, or even allow to simplify the setup if existing servers start coping with the load effortlessly. As a side effect, the changes can make the code cleaner and reveal more bottlenecks to investigate.
Jan 10, 20241,1064
FOSDEM 2023: Fair threaded task scheduler verified in TLA+
Algorithm for a multithreaded task scheduler for languages like C, C++, C#, Rust, Java. C++ version is open-sourced. Features: (1) formally verified in TLA+, (2) even CPU usage across worker threads, (3) coroutine-like functionality, (4) almost entirely lock-free, (5) up to 10 million RPS per thread. Key points for the potential audience: fair task scheduling with multiple worker threads; open source; algorithms; TLA+ verified; up to 10 million RPS per thread; for backend programmers; algorithm for languages like C++, C, Java, Rust, C# and others.
Feb 02, 20236590
Highload 2022: Fair threaded task scheduler verified in TLA+
Algorithm for a multithreaded task scheduler for languages like C, C++, C#, Rust, Java. C++ version is open-sourced. Features: (1) formally verified in TLA+, (2) even CPU usage across worker threads, (3) coroutine-like functionality, (4) almost entirely lock-free, (5) up to 10 million RPS per thread. Key points for the potential audience: fair task scheduling with multiple worker threads; open source; algorithms; TLA+ verified; up to 10 million RPS per thread; for backend programmers; algorithm for languages like C++, C, Java, Rust, C# and others.
Oct 25, 20226491
Ubisoft в Google Cloud: автомасштабирование игрового кластера
Sep 10, 20211,1270
Ubisoft in Google Cloud: game cluster autoscaling
Aug 30, 20211,2410
Highload 2021: Изобретая синхронную репликацию
Использование асинхронной репликации может приводить к потере транзакции, если мастер-узел выходит из строя сразу после ее коммита. Синхронная репликация позволяет добиться репликации транзакции на заданное число реплик до ее коммита, когда изменения становятся видны пользователю. В данном докладе рассматривается один из таких алгоритмов - Raft, и его применение в СУБД Tarantool.
Tarantool 2.6 was released in October of 2020. This is the biggest release in several years, which brings beta version of synchronous replication and transaction manager for memtx storage engine. The talk sheds more light on the key features of the release.
Nov 10, 20201,1780
Inventing synchronous replication
Usage of asynchronous replication can lead to transaction loss if the master node fails immediately after its commit. Synchronous replication helps to achieve replication of a transaction on a specified number of replicas before its commit, before the changes become visible to the user. This talk describes one of such algorithms - Raft, and its application in Tarantool DBMS.
Nov 03, 20201,2000
Изобретая синхронную репликацию
Использование асинхронной репликации может приводить к потере транзакции, если мастер-узел выходит из строя сразу после ее коммита. Синхронная репликация позволяет добиться репликации транзакции на заданное число реплик до ее коммита, когда изменения становятся видны пользователю. В данном докладе рассматривается один из таких алгоритмов - Raft, и его применение в СУБД Tarantool.
Oct 19, 20201,6181
System programming 10
Users and groups, rights. Attributes and access rights of files and processes. Process groups, sessions. /etc/passwd, /etc/group. Sticky bit. Process daemonization. Object attributes.
Network. Short history from ARPANET. Canonical OSI model, real TCP/IP model, protocol stack. Network implementation in the kernel. User space interface socket(), connect(), close(). TCP and UDP.
Jan 28, 20201,7067
FOSDEM 2020: SWIM - protocol to build a cluster
SWIM is a protocol for detection and monitoring of cluster nodes, distribution of events and data between them. The protocol is lightweight, decentralized and its speed does not depend on cluster size. The talk describes how SWIM protocol is organized, how and with which extensions it is implemented in Tarantool.
SWIM - это протокол обнаружения и мониторинга узлов кластера, распространения событий и данных между ними. Протокол особенен своей легковесностью, децентрализованностью и независимостью скорости работы от размера кластера. В докладе рассказывается о том, как устроен протокол SWIM, как и с какими расширениями он реализован в Тарантуле.
Oct 06, 20191,4591
System programming 5
Storage devices. File system and the kernel. Virtual file system. Files and their types: block, char, network. Representation in the kernel: inode. Sectors. IO schedulers - elevators: Linus, Deadline, Anticipatory, CFQ, Noop. Page cache. Page nowrite/writethrough/writeback. File work modes - buffered, unbuffered, line.
Sep 01, 20191,9259
Мегафон: SWIM - протокол построения кластера
SWIM - это протокол обнаружения и мониторинга узлов кластера, распространения событий и данных между ними. Протокол особенен своей легковесностью, децентрализованностью и независимостью скорости работы от размера кластера. В докладе рассказывается о том, как устроен протокол SWIM, как и с какими расширениями он реализован в Тарантуле.
Aug 12, 20191,3440
System programming 4
Interrupts. Hardware and software, their nature, purpose. Interrupt handling. Purpose of signals, how they work. Signals handling, execution context, longjmp, top and bottom halves. /proc/interrupts. signal, sigaction.
SWIM - это протокол обнаружения и мониторинга узлов кластера, распространения событий и данных между ними. Протокол особенен своей легковесностью, децентрализованностью и независимостью скорости работы от размера кластера. В докладе рассказывается о том, как устроен протокол SWIM, как и с какими расширениями он реализован в Тарантуле.
Jun 03, 20192,1235
System programming 3
Virtual and physical memory. Cache, cache line, cache levels, cache coherence, false sharing. High and low memory. Page tables. User space and kernel space memory, layout. Functions brk, madvice, mmap. Malloc and alternative libraries.
May 09, 20191,95811
System programming 2
Work modes: privileged, normal. Memory, its sections. Process resources - descriptors, locks. Process interrupts: exceptions, hardware, scheduling. Work context: user, kernel, signal. Interaction with the kernel - system calls: what are they, how parameters are passed and a result returned.
Apr 17, 20192,26722
System programming 1
The kernel. Process and its representation in the kernel. Process states, lifecycle. Types of process scheduling: preemptive and cooperative. Process schedulers, and IO Bound vs Processor Bound processes, details of scheduling. 'Nice' value and priorities. Timeslice - scheduling atom. CFS scheduler.
Apr 03, 20193,43733
System programming 0
Linux vs Unix. Microkernel. FreeBSD, Ubuntu, Mac, System III, V, Unix time-sharing system, 4.4BSD. Standard: ISO C, POSIX, Single Unix Specifications. Organisations: Open Group, IEEE.
Mar 24, 20193,31060
Системное программирование 4
Прерывания. Аппаратные и программные, их природа, назначение. Обработка прерываний. Сигналы - зачем нужни они, как устроены. Обработка сигналов, особенности, контекст выполнения, longjump, top and bottom halves. /proc/interrupts. signal, sigaction.
Mar 16, 20192,45913
Горизонтальное масштабирование в ядре Tarantool
Feb 15, 20191,7862
Масштабирование баз данных, Tarantool
Dec 17, 20181,6140
Системное программирование 10
Пользователи, группы, права. Атрибуты и права доступа файлов и процессов. Группы процессов, сессии. /etc/passwd, /etc/group. Sticky bit. Демонизация процесса. Атрибуты глобальных объектов: локов, памяти.
Сеть, краткая история от ARPANET. Каноническая модель OSI, реальная TCP/IP, стек протоколов. Реализация сетевого взаимодействия в ядре. Пользовательский интерфейс socket, connect, close, send, recv. TCP и UDP.
Потоки в linux, представление в ядре. Отличие от процессов. POSIX. Синхронизация: mutex, rw-lock, condition variable, spin lock, barrier. Атомарные операции. Атрибуты потоков и объектов синхронизации.
Nov 05, 20182,1719
Системное программирование 5
Файловая система и ядро. Виртуальная ФС. Файлы и типы: block, char, network. Представление в ядре: inode. Секторы. Планировщики IO операций - elevator-ы: Linus, Deadline, Anticipatory, CFQ, Noop. Page cache. Page nowrite/writethrough/writeback. Работа с файлом - buffered, unbuffered, line.
Oct 26, 20182,1414
VShard - горизонтальное масштабирование в Tarantool
Oct 24, 20183,0192
Системное программирование 3
Виртуальная и физическая память. Cache, cache line, cache levels, cache coherence, false sharing. High and low memory, области памяти. Page tables. Память ядра и процесса пользователя, разметка, вызовы: kmalloc, vmalloc, brk, madvice, mmap, pmap. Malloc, его альтернативы.
Oct 10, 20182,45411
Системное программирование 2
Режимы работы: привелигированный, обычный. Память, разбивка на секции. Ресурсы процесса - дескрипторы, локи. Прерывания процесса: исключения, аппаратные, шедулинг. Контексты работы: пользователь, ядро, сигнал. Обращения к ядру - системные вызовы: как определяются, передача параметров, возврат результата.
Oct 04, 20183,46027
Системное программирование 1
Ядро. Процесс и его представление в ядре. Состояния процесса, цикл жизни. Типы совместной работы процессов: preemptive и cooperative. Планировщики и IO Bound vs Processor Bound процессы, особенности планирования. Вызов nice, приоритеты. Единица планирования - timeslice. Планировщики в ядре, CFS. Вызовы sched_yield и sched_setaffinity.
Sep 29, 20184,60916
Системное программирование 0
Linux vs Unix. Microkernel. FreeBSD, Ubuntu, Mac, System III, V, Unix time-sharing system, 4.4BSD. Стандарты: ISO C, POSIX, Single Unix Specifications. Организации: Open Group, IEEE.
Sep 26, 20184,31815
VShard - горизонтальное масштабирование в Tarantool
Jun 13, 20185,1022
Новые LSM индексы в Tarantool
May 13, 20181,5710
Защита диссертации
Apr 08, 20181,4690
ДЗ по запросу проекта
Apr 02, 20181,5530
Разработка и реализация алгоритма отложенного обновления вторичных индексовна LSM-деревьях в базах данных
Oct 30, 20171,6330
Разработка распределенного алгоритма двухфазной синхронизации на основе архитектуры базы данных Tarantool
Apr 01, 20171,6662
Почему в основе интернета лежит ненадежный протокол без соединений?