All of lore.kernel.org
 help / color / mirror / Atom feed
From: Justin Tobler <jltobler@gmail.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/3] reftable/stack: move list lock to `struct reftable_stack`
Date: Wed, 19 Aug 2026 11:39:52 -0500	[thread overview]
Message-ID: <aoXaDW1Ifjys8HTr@denethor> (raw)
In-Reply-To: <20260819-740-optimize-reloading-the-reftable-stack-v1-2-6bf5305d4e43@gmail.com>

On 26/08/19 03:19PM, Karthik Nayak wrote:
> The struct `reftable_addition` is used to modify a given stack, as such,
> it also includes a `struct reftable_flock` used to obtain the lock to
> the list file. While the scope of the field lies within this struct, it
> doesn't allow for optimizations to be made on `struct reftable_stack`
> itself.

Hmmm IIUC, there can only be a single lock for the reftable stack
correct? If that is the case, it sounds like `struct reftable_stack` may
conceptually be the better place for the field regardless.

> Move the field to `struct reftable_stack`, allowing us to make a simple
> optimization around avoiding a stack reload when we have already
> obtained a lock. While this is currently possible in the write path, the
> write path also contains multiple branches to reads which only work
> on top of `struct reftable_stack`, and we would miss the optimization in
> such paths.

Ok, so if we know the reftable stack is alreay locked, there is no need
to reload it since it can't change. Makes sense.

> While here, remove an unused header file from 'reftable/stack.h'.
> 
> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> ---
[snip]
>  struct reftable_stack {
> @@ -18,6 +17,12 @@ struct reftable_stack {
>  	char *list_file;
>  	int list_fd;
>  
> +	/*
> +	 * Set while an addition holds the stack locked. Used by
> +	 * stack_uptodate() to skip reload checks while locked.
> +	 */
> +	struct reftable_flock list_lock;
> +

As mentioned in the log message, the lock is now tracked in `struct
reftable_stack` and the rest of this patch just wires it accordingly.
Looks good.

-Justin

  reply	other threads:[~2026-08-19 16:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 13:19 [PATCH 0/3] reftable/stack: avoid reloading the stack when locked Karthik Nayak
2026-08-19 13:19 ` [PATCH 1/3] reftable/stack: remove `REFTABLE_STACK_NEW_ADDITION_RELOAD` Karthik Nayak
2026-08-19 16:28   ` Justin Tobler
2026-08-19 13:19 ` [PATCH 2/3] reftable/stack: move list lock to `struct reftable_stack` Karthik Nayak
2026-08-19 16:39   ` Justin Tobler [this message]
2026-08-19 17:17   ` Junio C Hamano
2026-08-19 13:19 ` [PATCH 3/3] reftable/stack: avoid reloading the stack when already locked Karthik Nayak
2026-08-19 16:49   ` Justin Tobler

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=aoXaDW1Ifjys8HTr@denethor \
    --to=jltobler@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.