question

Upvotes
Accepted
46 4 5 10

callback RefreshMsg/UpdateMsg size

Hell, everyone, is there any method to know the size of RefreshMsg or UpdateMsg object ?

Currently in onRefreshMsg & onUpdateMsg, I will create a new object using new operator and push back into an internal queue that has no size limit that will be popped by a decoder thread for processing. But on market open time, the queue will soon filled with many messages and consumes much memory with 1 minute due to speed unmatch between callback thread and decoder thread. Even though 1 minutes later, the decoder consumes message in the queue, the memory of deleted message will still reside in the application, unable to be released to operating system.

One method is to increase decoder thread. But my puzzle is If i increase decoder thread count, due to message wil be hashed into queue via ric, but different ric may comes with different message count, which may cause certain queue filled with messages faster than corresponding decoder can process.

So how should I resolve this problem ?

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apimemory
icon clock
10 |1500

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

Upvotes
Accepted
13k 32 12 18

Yes, the OMM message is usually decoded in the callback event. Once decoded, you can push the blob into the queue for further processing.

You will still have to keep callback event loop as concise as possible, or else ADS might drop the connection due to slow consumer. The best approach is to subscribe to a limited set of fields required by your application, by using the view feature of the SDK. See this article on how to use views - https://developers.refinitiv.com/article/elektron-messaging-api-java-batch-and-view-features

Also see 360__MarketPrice__View shipped with SDK on how to use views.

icon clock
10 |1500

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

Upvotes
13k 32 12 18

Hi @wangfugen,

You didn't specify which language you are using, and also which objects (OMM or language-custom-structures) you are creating for reading the market data. Either way, it is quite inefficient for a very high throughput system to create and destroy/GC old objects. The best approach in this regards will be to create a pool of objects once and reuse them over and over again. The pool objects can be created once at the beginning or upon market event - when no more objects are available in the pool.

I must point out that even with this approach, your application will eventually run of of memory, if your decoder thread is slow. It is best to optimize the code to run as fast as possible. Usual tips for doing so are - eliminate logging, don't use string manipulation and reduce/avoid any IO blocking operations like network/database etc.

icon clock
10 |1500

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

Upvotes
46 4 5 10

Hi, @Gurpreet, Thanks for your reply. I am using C++ EMA SDK, trying to pass RefreshMsg and UpdateMsg object received from callback functions onRefreshMsg & onUpdateMsg to decoder threads via an internal queue by creating new object using C++ operator new. Then if message is processed by decoder thread, it will be deleted via delete operator.

The problem with RefreshMsg & UpdateMsg is that user has no idea about its structure, I don't know how to preallocate pool of such objects before market open. Maybe I should decode the message in callback thread into my custom structure, storing it into object pool and using that object in decoder thread ?

icon clock
10 |1500

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

Click below to post an Idea Post Idea