[libvirt] [PATCH 1/2] rpc: Switch to dynamically allocated message buffer
Eric Blake
eblake at redhat.com
Wed May 2 19:52:27 UTC 2012
On 04/27/2012 07:22 AM, Michal Privoznik wrote:
> Currently, we are allocating buffer for RPC messages statically.
> This is not such pain when RPC limits are small. However, if we want
> ever to increase those limits, we need to allocate buffer dynamically,
> based on RPC message len (= the first 4 bytes). Therefore we will
> decrease our mem usage in most cases and still be flexible enough in
> corner cases.
> ---
> src/rpc/virnetclient.c | 16 ++-
> src/rpc/virnetmessage.c | 12 ++-
> src/rpc/virnetmessage.h | 6 +-
> src/rpc/virnetserverclient.c | 20 ++-
> tests/virnetmessagetest.c | 393 +++++++++++++++++++++++-------------------
> 5 files changed, 264 insertions(+), 183 deletions(-)
I haven't looked closely at this, but I do have a generic question:
Are you malloc'ing and free'ing the buffer for each rpc on every call,
or are you tracking a pool of buffers and only alloc'ing when needed?
Furthermore, can you use the stack or a statically allocated array to
receive short messages, saving alloc only for the long messages? I'm
worried about performance if we malloc on every single RPC call.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120502/e99ece28/attachment-0001.sig>
More information about the libvir-list
mailing list