talloc vs malloc speed

Andreas Schneider asn at samba.org
Mon Apr 17 18:17:50 UTC 2023


On Sunday, 16 April 2023 04:16:20 CEST Douglas Bagnall via samba-technical 
wrote:
> On 15/04/23 06:11, Andreas Schneider via samba-technical wrote:
> > P.S. The talloc website states it is 4% slower than malloc. This was
> > probably a long long time ago ;-)
> 
> Ha. `man talloc` has almost the same sentence saying "10%".
> 
> I thought serious trouble with talloc performance has to do with the
> linked lists getting huge, making talloc_free or reparenting really slow.
> And I thought that this talloc-doing-talloc cost outweighs the
> talloc-as-malloc cost, which I guess is what is being measured here?

The talloc vs malloc test only does a talloc_strdup() in a loop. There are 
basically no childs involved and this cost doesn't show up here.

I think it would be tricky to use something like a red black tree.

> If that's the case (I have no evidence) then optimising talloc-as-malloc
> might not really help. OTOH, because talloc makes it easier to keep track
> of millions of little allocations, we do that often, so perhaps talloced
> code is *more* sensitive to the primitive alloc cost.

The thing is that that really simple testcase is already that slow. Getting 
rid of talloc_fill might help a tiny bit.

-- 
Andreas Schneider                      asn at samba.org
Samba Team                             www.samba.org
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D





More information about the samba-technical mailing list