git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ramsay Jones <ramsay@ramsayjones.plus.com>
Cc: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
	"Derrick Stolee" <stolee@gmail.com>,
	"GIT Mailing-list" <git@vger.kernel.org>
Subject: Re: [PATCH 3/3] commit-reach.h: add missing declarations (hdr-check)
Date: Mon, 29 Oct 2018 10:13:33 +0900	[thread overview]
Message-ID: <xmqq1s89a72a.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <88102e3a-8a02-fca4-4daf-ab428008afc7@ramsayjones.plus.com> (Ramsay Jones's message of "Sat, 27 Oct 2018 02:53:57 +0100")

Ramsay Jones <ramsay@ramsayjones.plus.com> writes:

> ...
>        24 clear_contains_cache
>   $
>
> you will find 24 copies of the commit-slab routines for the contains_cache.
> Of course, when you enable optimizations again, these duplicate static
> functions (mostly) disappear. Compiling with gcc at -O2, leaves two static
> functions, thus:
>
>   $ nm commit-reach.o | grep contains_cache
>   0000000000000870 t contains_cache_at_peek.isra.1.constprop.6
>   $ nm ref-filter.o | grep contains_cache
>   00000000000002b0 t clear_contains_cache.isra.14
>   $
>
> However, using a shared 'contains_cache' would result in all six of the
> above functions as external public functions in the git binary.

Sorry, but you lost me here.  Where does the 6 in above 'all six'
come from?  I saw 24 (from unoptimized), and I saw 2 (from
optimized), but...

Ah, OK, the slab system gives us a familiy of 6 helper functions to
deal with the "contains_cache" slab, and we call only 3 of them
(i.e. the implementation of other three are left unused).  Makes
sense.

> At present,
> only three of these functions are actually called, so the trade-off
> seems to favour letting the compiler inline the commit-slab functions.

OK.  I vaguely recall using a linker that can excise the
implementation an unused public function out of the resulting
executable in the past, which may tip the balance in the opposite
direction, but the above reasonong certainly makes sense to me.

> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>  commit-reach.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/commit-reach.h b/commit-reach.h
> index 7d313e2975..f41d8f6ba3 100644
> --- a/commit-reach.h
> +++ b/commit-reach.h
> @@ -1,12 +1,13 @@
>  #ifndef __COMMIT_REACH_H__
>  #define __COMMIT_REACH_H__
>  
> +#include "commit.h"
>  #include "commit-slab.h"
>  
> -struct commit;
>  struct commit_list;
> -struct contains_cache;
>  struct ref_filter;
> +struct object_id;
> +struct object_array;
>  
>  struct commit_list *get_merge_bases_many(struct commit *one,
>  					 int n,

  reply	other threads:[~2018-10-29  1:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-27  1:53 [PATCH 3/3] commit-reach.h: add missing declarations (hdr-check) Ramsay Jones
2018-10-29  1:13 ` Junio C Hamano [this message]
2018-10-29 23:59   ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1s89a72a.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).