{"thread":{"id":"37103","subject":"[PATCH v3 0/2] alloc.c: remove alloc_raw_commit_node() function","startedAt":"2014-07-10T23:57:11Z","lastAt":"2014-07-10T23:57:11Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"245741","messageId":"53BF2857.8000603@ramsay1.demon.co.uk","threadId":"37103","inReplyTo":null,"subject":"[PATCH v3 0/2] alloc.c: remove alloc_raw_commit_node() function","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2014-07-10T23:57:11Z","receivedAt":"2014-07-10T23:57:11Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nHi Jeff,\n\nAnother attempt to remove this intermediate allocator. ;-)\n\nI didn't think I would like this approach before I started to look at\ndoing this patch, but now I think I rather like it!\n\nThe first patch uses an inline function (alloc_node()) to implement the\nallocators, redefining the macro to declare the allocators to, basically:\n\n    static struct alloc_state something_state;\n    void *alloc_something_node(void)\n    {\n    \treturn alloc_node(&something_state, sizeof(struct something));\n    }\n\nThen alloc_commit_node() can also use the alloc_node() function in its\nimplementation.\n\nI checked that the alloc_node() function was actually inlined by gcc,\nwhich it was for -O1 -> -O3 (but not for -O0, obviously). The generated\nassembler looked very similar (but not identical) to the code generated\nwithout this patch. Also, I did a quick (and admittedly unsophisticated)\nperformance test. I could not detect any difference, within the noise\nlevel of the timings, between the two. (Also, operf barely registered\nany samples against the alloc functions, for './git log -p >/dev/null').\n\nI also checked the assembler generated by clang, and the story was _almost_\nthe same. For -O2 -> -O3, clang produced very similar results to gcc.\nFor -O1, clang didn't inline alloc_node(), but used it as a 'leaf'\nfunction; the blob allocator function 'fell into' alloc_node() and the\nother DEFINE-ed allocators 'jmp'-ed to alloc_node() rather than call-ing\nit. The alloc_commit_node() allocator did actually call alloc_node().\n(probably because it was more complicated than a single return ...).\n\nNote this was tested (on 32-bit Linux Mint 17) with gcc 4.8.2 and\nclang 3.4. (Other compilers probably will behave differently ...)\n\nThe second patch is just a minor clean-up and could be squashed into\nthe first patch. (NOTE: I assume that you want c->index to start at\nzero; if not ...)\n\nATB,\nRamsay Jones\n\nRamsay Allan Jones (2):\n  alloc.c: remove the alloc_raw_commit_node() function\n  alloc.c: remove the redundant commit_count variable\n\n alloc.c | 50 ++++++++++++++++++++++++++++++--------------------\n 1 file changed, 30 insertions(+), 20 deletions(-)\n\n-- \n2.0.0\n"}]}