Archived

This forum has been archived. Please start a new discussion on GitHub.

About the transmission efficiency

I made a demo to test the efficiency of different types,for example:

Type Timespan
sequence<byte> 1.6
sequence<string> 6.2
sequence<struct> 17.5
sequence<class> 50.7

the byte/string has a same value
the struct and class has a string,double.

The question is:Why string/struct/class costs so much time?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    I assume you're using the C++ language mapping here, correct? Could you also detail how you got these numbers (sequence size, etc)?

    In general, the main reason for these differences is that strings and classes need to be heap allocated and the heap allocation can be significant when transmitting large sequences on a fast network or over the loopback. On a slower network, the heap allocation is in general insignificant compared to the time needed to transmit the marshalled data.

    In C++, Slice structs are not allocated on the heap so sequence of structs should be as efficient as transmitting sequence of primitive types (byte, int, ...) as long as the struct doesn't contain attributes which require heap allocation (such as strings...). If you replace the string attribute in your struct by an int for example, I expect you should see much better performances for sequence of structs.

    In addition to the heap allocation cost, the marshalling/un-marshalling of Slice classes is more expensive than strings because it requires additional data to be encoded such as the Slice ID of the class (this explains the difference between the string/class marshalling times). You'll find more information in the Ice manual regarding the encoding of the different Slice types.

    Let us know if you need more information on this.

    Cheers,
    Benoit.
  • I use c# mappint.

    Here is the slice:
    module Test
    {
    sequence<byte> ByteSeq;

    sequence<string> StringSeq;

    struct StructStringDouble
    {
    string s;
    double d;
    };
    sequence<StructStringDouble> StructSeq;

    class ClassStringDouble
    {
    string s;
    double d;
    };
    sequence<ClassStringDouble> ClassSeq;

    interface TestClass
    {
    void SendByteSeq(ByteSeq t);
    void SendStringSeq(StringSeq t);
    void SendStructSeq(StructSeq t);
    void SendClassSeq(ClassSeq t);
    }
    }

    I don't know how to improve the string/struct/class transporation efficiency.
  • benoit
    benoit Rennes, France
    Hi,

    How do you measure these numbers and on which kind of network? Are you measuring them on the same network link that you will be using for your application? Why do you think these numbers won't be good enough and what would you expect instead?

    Unless you're planning to run your client and server on the same machine over the loopback interface or on a very fast network, it's important to realize that these differences will most likely be insignificant compared to the time of transmission of the data over the network.

    Therefore, before trying to optimize things, it's important to first figure out whether or not you're measuring something which is worth trying to optimize :)

    Cheers,
    Benoit.