Malloc elimination in vl-messaging branch

Aleksey Fedoseev fedoseev at ru.ibm.com
Tue Aug 22 09:02:32 GMT 2006


Good day!

Here are my review of malloc/free usage in cluster messaging code
(vl-messaging branch). Because of multiple messaging backends we have to
deal with multi-layered code and complex structures, messaging queues,
etc -- so lot of mallocs are used. I've counted the number of memory
allocations/deallocations for the messaging operations:

  sending a message:
	2 tallocs, 1 memcpy (from the message_send_pid argument to the
allocated buffer), 1 free
	
  receiving a message:
	2 tallocs, 1 free
	2 tallocs, 1 memcpy, 1 free

I've done first steps to minimize malloc/free usage. The patch consists
of several modifications:

1) added preallocation of incoming stream buffer (minus 2 tallocs and 1
free per incoming message)
2) corrected program exit (cleaning up communication buffer / closing
dispatcher's sockets)
3) added message size test to msgtest program

-- 
Aleksey Fedoseev
Linux Center of Competence, IBM EE/A
IBM Linux Technology Center: Samba Team
Phone: +7495 775-8800 x 2133

-------------- next part --------------
A non-text attachment was scrubbed...
Name: incoming-preallocation.patch
Type: text/x-patch
Size: 11664 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20060822/e16ada76/incoming-preallocation.bin


More information about the samba-technical mailing list