[PATCH v3 0/2] alloc.c: remove alloc_raw_commit_node() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jeff,

Another attempt to remove this intermediate allocator. ;-)

I didn't think I would like this approach before I started to look at
doing this patch, but now I think I rather like it!

The first patch uses an inline function (alloc_node()) to implement the
allocators, redefining the macro to declare the allocators to, basically:

    static struct alloc_state something_state;
    void *alloc_something_node(void)
    {
    	return alloc_node(&something_state, sizeof(struct something));
    }

Then alloc_commit_node() can also use the alloc_node() function in its
implementation.

I checked that the alloc_node() function was actually inlined by gcc,
which it was for -O1 -> -O3 (but not for -O0, obviously). The generated
assembler looked very similar (but not identical) to the code generated
without this patch. Also, I did a quick (and admittedly unsophisticated)
performance test. I could not detect any difference, within the noise
level of the timings, between the two. (Also, operf barely registered
any samples against the alloc functions, for './git log -p >/dev/null').

I also checked the assembler generated by clang, and the story was _almost_
the same. For -O2 -> -O3, clang produced very similar results to gcc.
For -O1, clang didn't inline alloc_node(), but used it as a 'leaf'
function; the blob allocator function 'fell into' alloc_node() and the
other DEFINE-ed allocators 'jmp'-ed to alloc_node() rather than call-ing
it. The alloc_commit_node() allocator did actually call alloc_node().
(probably because it was more complicated than a single return ...).

Note this was tested (on 32-bit Linux Mint 17) with gcc 4.8.2 and
clang 3.4. (Other compilers probably will behave differently ...)

The second patch is just a minor clean-up and could be squashed into
the first patch. (NOTE: I assume that you want c->index to start at
zero; if not ...)

ATB,
Ramsay Jones

Ramsay Allan Jones (2):
  alloc.c: remove the alloc_raw_commit_node() function
  alloc.c: remove the redundant commit_count variable

 alloc.c | 50 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 20 deletions(-)

-- 
2.0.0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]