Перейти к основному содержимому
Нормативная версия документации - английская

Эта страница переведена с английского языковой моделью. При любом расхождении верен английский оригинал.

Стоимость

Сколько стоит собственный код фреймворка на одно сообщение в инструкциях и выделениях памяти и куда уходит эта стоимость.

Инструкции и выделения памяти на сообщение

AMD Ryzen 9 7900X 12-Core Processor, x86_64 (x86-64-v4), base unknown, min 427 MHz, max 5912 MHz, 12 physical, 24 logical, 62.4 GiB, unknown, Linux 7.3.0-3-moloko, 1.99.1, 3.25.1, bench, inheriting release (opt-level = 3, lto = fat, codegen-units = 16, debug = line-tables-only), --no-default-features --features memory,macros,json,tokio. ruststream 0.8.0, измерено 2026-11-01.

Инструкции
Выделения
consume, JSON decode into a small struct
1 697,4
0
consume, JSON decode of a 1 KB body
17 304,2
0
consume on the byte lane, no codec
862,4
0
consume through a pool of four workers
3 131,8
0
consume on four dedicated threads
461,4
0
consume through a middleware stack of one
1 742,3
0
consume through a middleware stack of four
1 785,3
0
consume in batches of 64
1 516,2
0
consume in batches of 64 through a pool of four workers
1 538,8
0
reply, encoded to a declared destination
2 583,4
1
reply to a transport that reads the payload
2 051,4
0
publish through an Out slot with one transform
3 143,4
2
publish through an Out slot to a transport that reads the payload
2 570,4
1
publish with a typed header contract
3 589,4
4
read a typed header contract, then publish
3 972,3
1
request and reply, one round trip
8 920,9
10
a continuation left behind by every delivery
3 456,6
2
a delivery that asks to be redelivered, natively by the broker
3 270,5
0
a delayed redelivery the runtime publishes as a copy
9 531,1
6
Показать числа таблицей
СценарийИнструкцииВыделенияХолодный старт
consume, JSON decode into a small struct1 697,4016 282 / 26
consume, JSON decode of a 1 KB body17 304,2032 028 / 26
consume on the byte lane, no codec862,4015 563 / 26
consume through a pool of four workers3 131,8029 529 / 43
consume on four dedicated threads461,4056 438 / 133
consume through a middleware stack of one1 742,3016 700 / 26
consume through a middleware stack of four1 785,3016 742 / 26
consume in batches of 641 516,2018 273 / 28
consume in batches of 64 through a pool of four workers1 538,8033 921 / 45
reply, encoded to a declared destination2 583,4118 881 / 28
reply to a transport that reads the payload2 051,4018 136 / 29
publish through an Out slot with one transform3 143,4219 056 / 29
publish through an Out slot to a transport that reads the payload2 570,4118 907 / 31
publish with a typed header contract3 589,4419 789 / 31
read a typed header contract, then publish3 972,3119 464 / 28
request and reply, one round trip8 920,91024 823 / 36
a continuation left behind by every delivery3 456,6217 781 / 28
a delivery that asks to be redelivered, natively by the broker3 270,5017 914 / 26
a delayed redelivery the runtime publishes as a copy9 531,1625 096 / 32

Числа показывают установившийся режим на одно сообщение на брокере внутри процесса, поэтому транспорта в них нет. При наведении или фокусе строка показывает холодный старт: сколько вместе стоили запуск сервиса и первая доставка. Его платят один раз.

Приём доставки ничего не выделяет. Цикл держит одну ячейку для доставки и один буфер кодирования, а каждый этап - обобщённый тип, который разрешается при компиляции, без динамических вызовов по пути. DynStack из слоёв, выбранных во время работы, стоит одного упакованного Future на слой на сообщение. Продолжение and_after - один упакованный Future, и платит за него только доставка, которая его задала.

Ответ ничего не выделяет, если клиент брокера только читает байты: ему одалживают буфер цикла. Брокер внутри процесса сохраняет то, что ему передали, поэтому его ответ стоит буфера, в который писал кодек. Остальные строки публикации выделяют то, что брокер внутри процесса хранит от каждого сообщения, и то, что сценарий строит сам: значение заголовка или одноразовый ящик запроса.

Дороже всего в декодировании размер содержимого: сравните тело в 1 КБ с маленькой структурой. Бенчмарки публикуют каждый сценарий вместе с методикой, а также сравнение с сырым клиентом каждого брокера.