What's the best way to work with TIBCO RV from C #?

I am using TIBCO RV.NET API (TIBCO.Rendezvous.dll).

Do you know if there is a better way, in terms of performance, to receive and read messages from an RV channel in C # ? I found the type Message

- wrapping around RV post - quite heavy. Retrieving a field by name or by index can be quite slow, especially if we view it as a recurrent / high frequency operation.

Any ideas?

0


source to share


2 answers


The main problem with the C # shell is that it:

  • Allocates for any field access (c / C ++ api provides strongly typed fast accessors for the most likely primitives
  • marks references to every field accessed (you don't need to do this unless you plan to update the fields later and don't want to leak memory)
  • Searching a field by name requires converting a string to ascii string c

These aspects will overshadow the overhead of basic search queries based on field names and names, which can themselves be avoided when you know you need to look at each field in a message, iterating over the fields in order. This works fast in C / C ++, since it works linearly in memory and is thus cache-related.



Personally, we wrapped the C ++ api directly from the C ++ CLI (at the time the .net library was of poor quality). It's tricky to get it right (especially if you have multiple app domains), but gives close to the same performance as the C ++ api (which is an incredibly thin wrapper around the C api).

If your profiling tells you that message access distributions are preventing your application from running at the speed you need / want, I'm afraid you will have a problem with the .net library. You can use reflection to go to the underlying IntPtr to your own message and then use the same outer functions in MessageToolbaox (inner class in dll) that fall into the native api, the cost of accessing the inner field once per post can be offset by more fast field search. This is obviously fragile and difficult to maintain, but if you find it worthwhile to fully upgrade your shell, it might help.

+3


source


I've seen the same thing. In my experience, accessing fields in C # Rv messages is very slow compared to accessing them in C ++. Therefore, you want to avoid adding and reading multiple fields to and from the message.

One solution is not to use serialization of native Rv messages. That is, don't add many fields with Message.AddField (), or get them with Message.GetField (). Instead, you can serialize your data to the Opaque type (which is a binary buffer, that is, an array of bytes). Then you can add this message to the message.



If everything you do reads and writes one field, there is very little overhead. And you should be able to serialize and deserialize data in your own code pretty quickly.

+1


source







All Articles