Conversion from std::vector to repeated field

511 views
Skip to first unread message

Deepak Jain

unread,
Aug 8, 2023, 5:47:37 AM8/8/23
to grp...@googlegroups.com
Hello guys,

We have a repeated field of GFrameQuery and we have a std::vector.

So, now we need conversion from vector to repeated field.

So we do like
{vec.begin(), vec.end()}

which is a standard thing to do.
But it involved memcy and therefore, it is resulting in performance degradation when lakhs of query come and for each query we have to do such memcy for vector to repeated field and then repeated field to vector conversion.

So, is their any other way to achieve this?
Performance is the key here and that should not be comprised if we compare to other RPC like thrift which works well in above scenario.

Any solution will be appreciated.

Thanks
Deepak Jain

Brad Town

unread,
Aug 8, 2023, 5:15:19 PM8/8/23
to Deepak Jain, grp...@googlegroups.com
If you are doing something like this:

    *foo.mutable_bar() = {strings.begin(), strings.end()};

You would probably see an improvement if you change it to this:

    foo.mutable_bar()->Assign(strings.begin(), strings.end());

Brad

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAJhXTGf4kv4J56D657Qkn7KM%2B_V9H66%3Dpg6O1Rioh2LhygJf3w%40mail.gmail.com.

Deepak Jain

unread,
Aug 9, 2023, 3:49:27 AM8/9/23
to Brad Town, grp...@googlegroups.com
Thanks Brad.

I will check this out and get back to you.

Thanks 

Wei-Jen Lee

unread,
Jul 4, 2024, 1:56:43 AM7/4/24
to grpc.io
Hi,

I'm facing the same issue and curious about the result? Also, is there any way that we can directly swap the underlying heap/arena allocated container? Thanks in advance!

Reply all
Reply to author
Forward
0 new messages