Talloc sonsidered harmful to performance testing ...
Jeremy Allison
jra at samba.org
Mon Jun 8 10:39:57 MDT 2015
On Sun, Jun 07, 2015 at 12:46:24PM -0700, Richard Sharpe wrote:
> On Sun, Jun 7, 2015 at 12:28 PM, Matthieu Patou <mat at samba.org> wrote:
> > On 06/07/2015 11:46 AM, Richard Sharpe wrote:
> >>
> >>
> >> This seems to be because of the following code in smb2_pull_o16s16_blob:
> >>
> >> *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size);
> >> NT_STATUS_HAVE_NO_MEMORY(blob->data);
> >> return NT_STATUS_OK;
> >>
> >> Does anyone have any comments? If I get a chance I might modify that
> >> code to use any passed in blob if it is big enough.
> >
> > Did you try to run perf on it ? if not can you run:
> > perf -F 99 -g -a -- sleep 600
> > perf script >smbtorture.perf.out
> >
> > Adapt 600 so that perf capture the time when you are running your
> > smbtorture.
> >
> > Also have you tried to use a talloc_pool, with talloc pool you can allocate
> > a big memory chunk and let talloc tap into it.
> > It should be much faster.
>
> The tallocs are being done in code I am calling. After this change:
>
> --- a/source4/libcli/smb2/request.c
> +++ b/source4/libcli/smb2/request.c
> @@ -267,7 +267,10 @@ NTSTATUS smb2_pull_o16s16_blob(struct
> smb2_request_buffer *buf, TALLOC_CTX *mem_
> if (smb2_oob(buf, buf->hdr + ofs, size)) {
> return NT_STATUS_INVALID_PARAMETER;
> }
> - *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size);
> + if (blob->length >= size) {
> + memcpy(blob->data, buf->hdr + ofs, size);
> + } else
> + *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size);
> NT_STATUS_HAVE_NO_MEMORY(blob->data);
> return NT_STATUS_OK;
> }
>
> I now see all of them taking around 3 minutes for 100,000 iterations
> but top suggests that smbtorture is getting 88+% of the CPU and smbd
> only around 10%, so there is still a lot of talloc being done in the
> code I am calling.
>
> That is a pity because smbtorture etc seems very useful for some types
> of performance testing.
Well you can allways run smbtorture on a different box, so you
don't have to share the CPU.
More information about the samba-technical
mailing list