Repository navigation
Reduce idle RabbitMQ CPU by 95% by not rebuilding the insert pipeline on every empty read - #133527
Conversation
… idle An empty first poll returned at once, so each of the up to 10 empty-read retries of a streaming round built the whole insert pipeline: context copy, interpreter with the views chain and executor, 50-80 times a second for an idle table. Like KafkaSource, an empty first poll now waits up to stream_poll_timeout_ms for a message inside the same pipeline. Direct SELECT keeps returning at once.
The source already waited up to stream_poll_timeout_ms, so nine more empty reads only held a message-broker worker for 5 s per round. Drop MAX_FAILED_READ_ATTEMPTS and end the round at once, as Kafka does; the backoff still resets after each cycle that ran. Stop the wait on SYSTEM PAUSE, which blocks only future cycles.
|
Workflow [PR], commit [095a29f] Summary: ✅
AI ReviewSummaryThe change reduces idle Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 15 s compile time in total, 8 of them have a recent master baseline. |
|
📊 Cloud Performance Report ✅ AI verdict: No performance change can be attributed to this PR, because it only changes how the RabbitMQ engine handles empty-queue polling and rescheduling, and neither benchmark runs that code. The only flagged query is clickbench Q28 at -5.3%. That result is inconclusive: the two tests disagree, measurements on both sides were noisy, and the query is a MergeTree regex aggregation that never creates a RabbitMQ source. Queries 10, 30 and 31 on clickbench were marked unstable because master's performance shifted partway through the baseline period, but none of them is flagged here, and nothing in the diff points the other way. clickbenchFlagged queries (1 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
…red `RabbitMQ` description The sentence was added inside the `AUTOGENERATED_START` / `AUTOGENERATED_END` region of `docs/reference/engines/table-engines/integrations/rabbitmq.mdx`, which is regenerated from the description registered in `registerStorageRabbitMQ`. Put it into that description and revert the direct edit of the generated page, which also fails the docs check "No direct edits to generated or read-only docs". Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ty-read-like-kafka" This reverts commit 3d50995, reversing changes made to 73c474c. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md. Changelog-revert: 131167 122380 Revert "Record the static conditions of a PREWHERE shared with a join runtime filter in the query condition cache" Changelog-revert: 134110 133527 Revert "Reduce idle RabbitMQ CPU by 95% by not rebuilding the insert pipeline on every empty read" Changelog-deleted-entry: 133527 [Performance Improvement] [section] * An idle `RabbitMQ` table with materialized views no longer rebuilds its insert pipeline for every empty read: an empty read now waits up to `stream_poll_timeout_ms` for a message and then ends the streaming round, as `Kafka` does. [#133527](#133527) ([Sven Eliasson](https://github.com/comino)).
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
An idle
RabbitMQtable with materialized views no longer rebuilds its insert pipeline for every empty read: an empty read now waits up tostream_poll_timeout_msfor a message and then ends the streaming round, asKafkadoes.Details
Each streaming call builds a context copy, an
InterpreterInsertQuerywith all attached materialized view chains and aPipelineExecutor. On an empty queue the source returned at once, and a round made up to 10 such calls (MAX_FAILED_READ_ATTEMPTS) before sleeping ~110 ms, so an idle table rebuilt its pipeline continuously. After #131355 this was the largest remaining cost of idle RabbitMQ tables in a production profile.flowchart LR subgraph before["master: idle round ≈ 120 ms, 10 builds"] direction LR b1["build pipeline"] --> b2["empty read,<br/>returns at once"] -->|"× 10"| b1 b2 --> b3["sleep 110 ms"] end subgraph after["this PR: idle round ≈ 610 ms, 1 build"] direction LR a1["build pipeline"] --> a2["wait up to 500 ms<br/>for a message"] --> a3["sleep 110 ms"] endOne materialized view per table, flush interval 1000 ms (pipelines) or 500 ms (CPU, latency), other settings default; master = official builds 26.12.1.148 and .160.
The change follows
KafkaSource, which waits up to the poll timeout instead of returning an empty block (NATS also ends its round on an empty read):RabbitMQSource: during background streaming, an empty first poll waits up tostream_poll_timeout_ms(default 500 ms, capped by the flush interval), reusingdriveLoopUntilMessagefrom theSYSTEM REFRESHpath, so delivery during the wait does not depend on the looping task getting a worker. DirectSELECTis unchanged.StorageRabbitMQ: the source already waited, so an empty read ends the round;MAX_FAILED_READ_ATTEMPTSandread_attemptsare removed. The backoff resets after each cycle that returns, so the idle cadence staysrabbitmq_empty_queue_backoff_start_ms+_step_msas on master, and it still grows while cycles throw.SYSTEM PAUSEonly blocks future cycles, so the wait checks it, also after a delivery wakes it. A message received at that moment stays unacked in the consumer and is read in order afterSTART.Behaviour changes:
stream_poll_timeout_msearlier.background_message_broker_schedule_pool_sizegives the tables more workers.tests/performancehas no broker, so the new integration testtest_rabbitmq_idle_table_does_not_rebuild_insert_pipelinecounts the pipelines built in 10 s of idle (Processed 0 rowsper call); its bound follows from the poll timeout. It fails on master and passes with this change; the wholetest_storage_rabbitmqmodule passes.Workflow [PR]
Sync PR [sync-upstream/pr/133527]
Version info
26.12.1.296-master(included in26.12and later)