mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
docs(shmem): document that sender and receiver must use the same kind of type
- shmem uses one metadata format for a single message and another for a multipart message; Receive(Parts) of a single send, or Receive(MessagePtr) of a multipart send, gives wrong metadata or a crash - Add a sender/receiver table to the messages page of the documentation and a note to Channel::Receive() - Update the source line links into Channel.h - Keep PartsTransfer.SingleSendMultipartReceive disabled: a fix changes the shmem wire format Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -168,7 +168,7 @@ message owns its buffer. When you destroy the message, the transport releases th
|
||||
### A message of another transport
|
||||
|
||||
[`Channel::Send()`](/api/fair/mq/Channel/#Send) compares the transport of each message with the
|
||||
transport of the channel ([Channel.h](/source/fairmq/Channel.h/#L421-L480)). If they are different,
|
||||
transport of the channel ([Channel.h](/source/fairmq/Channel.h/#L425-L484)). If they are different,
|
||||
the channel makes a new message of its own transport, and your `MessagePtr` points to the new
|
||||
message after the call:
|
||||
|
||||
@@ -228,12 +228,26 @@ apply to each part. This test sends three parts, one of them empty, and receives
|
||||
:::caution[Rules for multipart messages]
|
||||
- Do not send an empty `Parts` object. Both transports return `TransferCode::error`.
|
||||
- Receive with the same form that the sender uses: `Parts` for `Parts`, `MessagePtr` for
|
||||
`MessagePtr`. The shmem transport cannot read a single message into a `Parts` object.
|
||||
`MessagePtr`. See the table below.
|
||||
- `Receive()` adds the received parts at the end of the `Parts` object. Give it an empty one.
|
||||
- A receiver with [`OnData()`](/api/fair/mq/Device/#OnData-3) must register a callback that takes
|
||||
`fair::mq::Parts&`.
|
||||
:::
|
||||
|
||||
The two transports do not accept the same mix of forms:
|
||||
|
||||
| Sender | Receiver | zeromq | shmem |
|
||||
| --- | --- | --- | --- |
|
||||
| `Send(MessagePtr&)` | `Receive(MessagePtr&)` | yes | yes |
|
||||
| `Send(Parts&)` or `vector<MessagePtr>` | `Receive(Parts&)` or `vector<MessagePtr>` | yes | yes |
|
||||
| `Send(MessagePtr&)` | `Receive(Parts&)` or `vector<MessagePtr>` | yes | **no** |
|
||||
| `Send(Parts&)` or `vector<MessagePtr>` | `Receive(MessagePtr&)` | one part per call | **no** |
|
||||
|
||||
The shmem transport uses one metadata format for a single message and another for a multipart
|
||||
message. A mix gives a message with wrong metadata or a crash. The test
|
||||
`PartsTransfer.SingleSendMultipartReceive` in `test/parts/_access.cxx` shows the problem. It is
|
||||
disabled, because a fix changes the shmem wire format.
|
||||
|
||||
## Related pages
|
||||
|
||||
- [Channels and sockets](/concepts/channels/): the channels that send and receive the messages.
|
||||
|
||||
@@ -65,7 +65,7 @@ Some rules follow from this table:
|
||||
thread that requests the transition. The next state resumes the transports in the thread of the
|
||||
state machine ([Device.cxx](/source/fairmq/Device.cxx/#L96-L104)).
|
||||
- A zeromq channel that sends a shmem message wraps the message. The free function of the wrapper
|
||||
destroys the shmem message ([Channel.h](/source/fairmq/Channel.h/#L421-L438)). Thus the shmem
|
||||
destroys the shmem message ([Channel.h](/source/fairmq/Channel.h/#L425-L442)). Thus the shmem
|
||||
message can be destroyed in a thread of ZeroMQ.
|
||||
- Both transports call the region event callback while they hold the lock of the subscription
|
||||
([shmem/Manager.h](/source/fairmq/shmem/Manager.h/#L582-L616),
|
||||
|
||||
@@ -132,7 +132,7 @@ leaves `RUNNING` after it got this number of messages on both data channels.
|
||||
|
||||
If the transport of a message is not the transport of the channel, `Send()` converts the message. It creates
|
||||
a new message of the channel transport for the same data
|
||||
([Channel.h](/source/fairmq/Channel.h/#L421-L438)). If the channel uses `shmem`, this step copies the data
|
||||
([Channel.h](/source/fairmq/Channel.h/#L425-L442)). If the channel uses `shmem`, this step copies the data
|
||||
into shared memory. `NewMessageFor()` creates the message with the transport of the channel, so `Send()`
|
||||
does not convert it.
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ The builder and the sender register a data callback with [`OnData()`](/api/fair/
|
||||
|
||||
<Snippet file="examples/readout/builder.cxx" start="bool HandleData" />
|
||||
|
||||
The sender forwards from the channel of `--input-name` (default `bs`) to `sr`. The message is a shmem message, but `sr` is a zeromq channel. [`Channel::Send()`](/api/fair/mq/Channel/#Send) compares the transports. If they differ, the channel puts the data of the message into a new message of its own transport. It does not copy the data. The new message deletes the original message when the zeromq transport releases the data. See [`Channel.h`](/source/fairmq/Channel.h/#L421-L438).
|
||||
The sender forwards from the channel of `--input-name` (default `bs`) to `sr`. The message is a shmem message, but `sr` is a zeromq channel. [`Channel::Send()`](/api/fair/mq/Channel/#Send) compares the transports. If they differ, the channel puts the data of the message into a new message of its own transport. It does not copy the data. The new message deletes the original message when the zeromq transport releases the data. See [`Channel.h`](/source/fairmq/Channel.h/#L425-L442).
|
||||
|
||||
Thus the readout device gets the acknowledgement for a block after the zeromq transport releases the data.
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ Thus a device must have all its data before it goes to `RESETTING DEVICE`. The t
|
||||
## Linger
|
||||
|
||||
The channel property `linger` is a time in ms. The default is 500
|
||||
([Channel.h](/source/fairmq/Channel.h/#L378)). [`Channel::Init()`](/api/fair/mq/Channel/#Init) sets
|
||||
([Channel.h](/source/fairmq/Channel.h/#L382)). [`Channel::Init()`](/api/fair/mq/Channel/#Init) sets
|
||||
it as the ZeroMQ option `ZMQ_LINGER` on the socket ([Channel.cxx](/source/fairmq/Channel.cxx/#L325-L326)).
|
||||
The shmem transport sets it on the ZeroMQ socket that carries the metadata of its messages.
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ transport, and makes it if the device has none.
|
||||
## Send a message of another transport
|
||||
|
||||
You can send a message on a channel of another transport. `Channel::Send()` then converts the
|
||||
message ([Channel.h](/source/fairmq/Channel.h/#L421-L480)):
|
||||
message ([Channel.h](/source/fairmq/Channel.h/#L425-L484)):
|
||||
|
||||
| Message | Channel | What the channel does |
|
||||
| --- | --- | --- |
|
||||
|
||||
@@ -29,21 +29,21 @@ The type is the C++ type of the property. The parsers of `--channel-config` and
|
||||
| Key | Type | Default | Allowed values | Effect |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [`name`](#name) | string | none | `a`–`z`, `A`–`Z`, `0`–`9`, `-`, `_`, `[`, `]`, `#` | Name of the channel. |
|
||||
| [`type`](#type) | string | [`unspecified`](/source/fairmq/Channel.h/#L369) | `push`, `pull`, `pub`, `sub`, `req`, `rep`, `dealer`, `router`, `xpub`, `xsub`, `pair` | Socket type. |
|
||||
| [`method`](#method) | string | [`unspecified`](/source/fairmq/Channel.h/#L370) | `bind`, `connect` | Bind or connect the endpoints. |
|
||||
| [`address`](#address) | string | [`unspecified`](/source/fairmq/Channel.h/#L371) | One or more endpoints, separated by `,` | Endpoints of the socket. |
|
||||
| [`transport`](#transport) | string | [`default`](/source/fairmq/Channel.h/#L367) | `default`, `zeromq`, `shmem` | Transport of the sub-channel. |
|
||||
| [`sndBufSize`](#sndbufsize-and-rcvbufsize) | int | [`1000`](/source/fairmq/Channel.h/#L372) | 0 or more | Maximum number of messages in the send queue. |
|
||||
| [`rcvBufSize`](#sndbufsize-and-rcvbufsize) | int | [`1000`](/source/fairmq/Channel.h/#L373) | 0 or more | Maximum number of messages in the receive queue. |
|
||||
| [`sndKernelSize`](#sndkernelsize-and-rcvkernelsize) | int | [`0`](/source/fairmq/Channel.h/#L374) | 0 or more | Kernel send buffer in bytes. 0: system default. |
|
||||
| [`rcvKernelSize`](#sndkernelsize-and-rcvkernelsize) | int | [`0`](/source/fairmq/Channel.h/#L375) | 0 or more | Kernel receive buffer in bytes. 0: system default. |
|
||||
| [`sndTimeoutMs`](#sndtimeoutms-and-rcvtimeoutms) | int | [`-1`](/source/fairmq/Channel.h/#L376) | -1, 0 or more | Default timeout of a send call in ms. |
|
||||
| [`rcvTimeoutMs`](#sndtimeoutms-and-rcvtimeoutms) | int | [`-1`](/source/fairmq/Channel.h/#L377) | -1, 0 or more | Default timeout of a receive call in ms. |
|
||||
| [`linger`](#linger) | int | [`500`](/source/fairmq/Channel.h/#L378) | -1, 0 or more | Time in ms that the socket keeps unsent messages after it closes. |
|
||||
| [`rateLogging`](#ratelogging) | int | [`1`](/source/fairmq/Channel.h/#L379) | 0 or more | Interval of the rate log in seconds. 0: no rate log. |
|
||||
| [`portRangeMin`](#portrangemin-portrangemax-and-autobind) | int | [`22000`](/source/fairmq/Channel.h/#L380) | A TCP port | Lowest port for autobind. |
|
||||
| [`portRangeMax`](#portrangemin-portrangemax-and-autobind) | int | [`23000`](/source/fairmq/Channel.h/#L381) | A TCP port | Highest port for autobind. |
|
||||
| [`autoBind`](#portrangemin-portrangemax-and-autobind) | bool | [`true`](/source/fairmq/Channel.h/#L382-L386) | `true`, `false`, `1`, `0` | Bind to a random port of the range when the bind fails. |
|
||||
| [`type`](#type) | string | [`unspecified`](/source/fairmq/Channel.h/#L373) | `push`, `pull`, `pub`, `sub`, `req`, `rep`, `dealer`, `router`, `xpub`, `xsub`, `pair` | Socket type. |
|
||||
| [`method`](#method) | string | [`unspecified`](/source/fairmq/Channel.h/#L374) | `bind`, `connect` | Bind or connect the endpoints. |
|
||||
| [`address`](#address) | string | [`unspecified`](/source/fairmq/Channel.h/#L375) | One or more endpoints, separated by `,` | Endpoints of the socket. |
|
||||
| [`transport`](#transport) | string | [`default`](/source/fairmq/Channel.h/#L371) | `default`, `zeromq`, `shmem` | Transport of the sub-channel. |
|
||||
| [`sndBufSize`](#sndbufsize-and-rcvbufsize) | int | [`1000`](/source/fairmq/Channel.h/#L376) | 0 or more | Maximum number of messages in the send queue. |
|
||||
| [`rcvBufSize`](#sndbufsize-and-rcvbufsize) | int | [`1000`](/source/fairmq/Channel.h/#L377) | 0 or more | Maximum number of messages in the receive queue. |
|
||||
| [`sndKernelSize`](#sndkernelsize-and-rcvkernelsize) | int | [`0`](/source/fairmq/Channel.h/#L378) | 0 or more | Kernel send buffer in bytes. 0: system default. |
|
||||
| [`rcvKernelSize`](#sndkernelsize-and-rcvkernelsize) | int | [`0`](/source/fairmq/Channel.h/#L379) | 0 or more | Kernel receive buffer in bytes. 0: system default. |
|
||||
| [`sndTimeoutMs`](#sndtimeoutms-and-rcvtimeoutms) | int | [`-1`](/source/fairmq/Channel.h/#L380) | -1, 0 or more | Default timeout of a send call in ms. |
|
||||
| [`rcvTimeoutMs`](#sndtimeoutms-and-rcvtimeoutms) | int | [`-1`](/source/fairmq/Channel.h/#L381) | -1, 0 or more | Default timeout of a receive call in ms. |
|
||||
| [`linger`](#linger) | int | [`500`](/source/fairmq/Channel.h/#L382) | -1, 0 or more | Time in ms that the socket keeps unsent messages after it closes. |
|
||||
| [`rateLogging`](#ratelogging) | int | [`1`](/source/fairmq/Channel.h/#L383) | 0 or more | Interval of the rate log in seconds. 0: no rate log. |
|
||||
| [`portRangeMin`](#portrangemin-portrangemax-and-autobind) | int | [`22000`](/source/fairmq/Channel.h/#L384) | A TCP port | Lowest port for autobind. |
|
||||
| [`portRangeMax`](#portrangemin-portrangemax-and-autobind) | int | [`23000`](/source/fairmq/Channel.h/#L385) | A TCP port | Highest port for autobind. |
|
||||
| [`autoBind`](#portrangemin-portrangemax-and-autobind) | bool | [`true`](/source/fairmq/Channel.h/#L386-L390) | `true`, `false`, `1`, `0` | Bind to a random port of the range when the bind fails. |
|
||||
| [`numSockets`](#numsockets) | int | [`0`](/source/fairmq/JSONParser.cxx/#L129) | 0 or more | Number of sub-channels with the same properties. |
|
||||
|
||||
The JSON parser uses the same defaults ([JSONParser.cxx](/source/fairmq/JSONParser.cxx/#L111-L126)). The device also uses them for a property that is not set ([Channel.cxx](/source/fairmq/Channel.cxx/#L92-L112)).
|
||||
@@ -130,7 +130,7 @@ The start script of the [region example](/examples/region/) sets `sndKernelSize=
|
||||
|
||||
### `sndTimeoutMs` and `rcvTimeoutMs`
|
||||
|
||||
The timeout of a send or receive call that does not give its own timeout ([Channel.h](/source/fairmq/Channel.h/#L297-L333)). This applies to [`Channel::Send()`](/api/fair/mq/Channel/#Send) and [`Channel::Receive()`](/api/fair/mq/Channel/#Receive), to [`Device::Send()`](/api/fair/mq/Device/#Send) and [`Device::Receive()`](/api/fair/mq/Device/#Receive) without the timeout argument, and to the receive calls of [`OnData()`](/api/fair/mq/Device/#OnData).
|
||||
The timeout of a send or receive call that does not give its own timeout ([Channel.h](/source/fairmq/Channel.h/#L297-L337)). This applies to [`Channel::Send()`](/api/fair/mq/Channel/#Send) and [`Channel::Receive()`](/api/fair/mq/Channel/#Receive), to [`Device::Send()`](/api/fair/mq/Device/#Send) and [`Device::Receive()`](/api/fair/mq/Device/#Receive) without the timeout argument, and to the receive calls of [`OnData()`](/api/fair/mq/Device/#OnData).
|
||||
|
||||
- `-1`: wait until the transfer is complete.
|
||||
- `0`: do not wait. If the transfer is not possible at once, the call returns `TransferCode::timeout` (-2).
|
||||
|
||||
@@ -43,7 +43,7 @@ message, the number of bytes is the sum of all parts.
|
||||
| Positive | Wait up to this time in ms, rounded up to a multiple of 100 ms. |
|
||||
|
||||
The channel properties `sndTimeoutMs` and `rcvTimeoutMs` give the timeout of a channel. Their
|
||||
default is `-1` ([`Channel.h`](/source/fairmq/Channel.h/#L376-L377)). The steps of 100 ms come from
|
||||
default is `-1` ([`Channel.h`](/source/fairmq/Channel.h/#L380-L381)). The steps of 100 ms come from
|
||||
the internal socket timeout of the zeromq and shmem transports
|
||||
([`zeromq/Common.h`](/source/fairmq/zeromq/Common.h/#L64-L77)).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user