git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] reftable/stack: move list lock to `struct reftable_stack`

From
Justin Tobler <jltobler@gmail.com>
Date
Aug 19, 2026, 16:39 UTC
Message-ID
<aoXaDW1Ifjys8HTr@denethor>
In-Reply-To
<20260819-740-optimize-reloading-the-reftable-stack-v1-2-6bf5305d4e43@gmail.com>
On 26/08/19 03:19PM, Karthik Nayak wrote:
Show 5 quoted lines
> 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.

Show 6 quoted lines
> 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]
Show 11 quoted lines
>  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
Previous: Karthik NayakNext: Junio C Hamano
Message 9 of 17 in “reftable/stack: avoid reloading the stack when locked”
  1. 0/3 reftable/stack: avoid reloading the stack when lockedKarthik Nayak, Aug 19, 2026
  2. 1/3 reftable/stack: remove `REFTABLE_STACK_NEW_ADDITION_RELOAD`Karthik Nayak, Aug 19, 2026
  3. Justin ToblerAug 19, 2026
  4. Karthik NayakAug 20, 2026
  5. Patrick SteinhardtAug 20, 2026
  6. Karthik NayakAug 20, 2026
  7. Karthik NayakAug 20, 2026
  8. 2/3 reftable/stack: move list lock to `struct reftable_stack`Karthik Nayak, Aug 19, 2026
  9. Justin ToblerAug 19, 2026
  10. Junio C HamanoAug 19, 2026
  11. Karthik NayakAug 23, 2026
  12. 3/3 reftable/stack: avoid reloading the stack when already lockedKarthik Nayak, Aug 19, 2026
  13. Justin ToblerAug 19, 2026
  14. Karthik NayakAug 23, 2026
  15. Jeff KingAug 20, 2026
  16. Karthik NayakAug 23, 2026
  17. Jeff KingAug 24, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.