question

Upvotes
Accepted
0 0 0 1

How reduce delay between sending messages using Ema C++ Consumer

Hello everyone, can you please tell me exist possibility decrease delay between sended messages using Ema C++ interface.

I using default approach with next code. And it's in the cycle without any delay from my side.

consumer->submit(PostMsg()
                .streamId(_postStreamID)
                .postId(postID).domainType(MMT_MARKET_PRICE)
                .solicitAck(true).complete()
                .payload(UpdateMsg()
                    .streamId(_postStreamID)
                    .name(RIC)
                    .payload(fieldList))
                .complete(),
                _subStreamHandle);

I expected performance as 1~10ms between sended messages and get next result.

<!-- Time: 7:00:01:887 -->
<key  flags="0x2 (RSSL_MKF_HAS_NAME)"  name="GBPSZB10YD=RAIS"/>
<!-- Time: 7:00:01:965 -->
<key  flags="0x2 (RSSL_MKF_HAS_NAME)"  name="AUDSZB4YD=RAIS"/>

It's spended in average 80~120ms, i found it's very large delay. And I try to find any solution how I can decrease this delay. I used simple configuration for my Ema interface.

1659524258027.png

Any information from your side about this will be heplfull. Thanks in advance.

elektron-sdkema-apic++ommconsumer
1659524258027.png (116.5 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
52.8k 135 44 63

@mikhail.maryankou

I assume that you are contributing data to Refinitiv Contributions Channel and you get the timestamp from the XML trace in EMA.

I modified the code to send messages in a for loop to verify the timestamps in the XML trace.

for (int i = 0; i <= 4; i++) {
        _pOmmConsumer->submit(PostMsg()
            .streamId(_postStreamID)
            .postId(_postID).domainType(MMT_MARKET_PRICE)
            .solicitAck(true).complete()
            .payload(UpdateMsg().streamId(_postStreamID)
                .name("TRCCTEST01")
                .payload(FieldList()
                    .addReal(22, _BID, OmmReal::ExponentNeg2Enum)
                    .addReal(25, _ASK, OmmReal::ExponentNeg2Enum)
                    .complete()))
            .complete(),
            _subStreamHandle);


        _postID++;
        _BID++;
        _ASK++;
    }

If I enable XmlTraceToStdout, the delay is around 10-50 ms.

            <XmlTraceToStdout value="1"/>
            <XmlTraceToFile value="0"/>
<!-- Time: 11:08:57:414 -->
<!-- Time: 11:08:57:461 -->
<!-- Time: 11:08:57:504 -->
<!-- Time: 11:08:57:521 -->
<!-- Time: 11:08:57:568 -->

However, If I enable XmlTraceToFile, there is no delay in millisecond in the XML trace file.

            <XmlTraceToStdout value="0"/>
            <XmlTraceToFile value="1"/>
<!-- Time: 11:21:04:513 -->
<!-- Time: 11:21:04:513 -->
<!-- Time: 11:21:04:513 -->
<!-- Time: 11:21:04:513 -->
<!-- Time: 11:21:04:513 -->

In conclusion, enabling XML tracing will impact the performance of the application, especially XmlTraceToStdout. In the production environment, you should disable tracing and use the release build.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1659595429763.png

How I some investigate my point i keep wait answer ACK responce for continue sending next message, i remove this logic. And try to send messages immidiatly when it possible.Could you please look my configuration, maybe another parameters loose my performance in production case.Current my result with not wait ACK equal 15ms, it's good but not enough.

1659595429763.png (166.3 KiB)
@mikhail.maryankou

You may need to log timestamps when the application called the submit method to post messages. It may be a delay in the application.

Upvotes
24.9k 86 10 22

Hi @mikhail.maryankou

Also, please be aware that you are not required to wait for an ACK before sending the next message. If you send too many Posts and exceed any RCC Queue limits, then you will receive a NACK.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
0 0 0 1

I solved my problem. For the first i don't wait ACK responce for increase performance. For the second as delay bad case using Sleep() function, because this method do not guarantee that's 1ms sleeping it's 1ms awaking. In my case it's spend 15~20ms. Exist two ways for using in this case. It's WaitForSingleObject or more modern with condition variable:

std::mutex mtx;
std::unique_lock lk(mtx);
std::condition_variable cv;

while (fSvcStopPauseFlag != 1)
{
    cv.wait_for(lk, std::chrono::milliseconds(1)); // guarantee delay 1ms
    // send you message
}

I hope that's my explanation can help anybody in future.
Thank you all for your participation in this thread.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.