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

Re: [PATCH 06/11] refs/reftable: allow configuring block size

From
Patrick Steinhardt <ps@pks.im>
Date
May 10, 2024, 10:13 UTC
Message-ID
<Zj3zVQbASOx4EPgu@tanuki>
In-Reply-To
<CAOLa=ZR7=hVXyGr2iSZW2C8mtwR2SHLikuCVKS-qTB7AE+0+hQ@mail.gmail.com>
On Fri, May 10, 2024 at 02:29:19AM -0700, Karthik Nayak wrote:
Show 22 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> [snip]
> 
> > @@ -230,6 +231,23 @@ static int read_ref_without_reload(struct reftable_stack *stack,
> >  	return ret;
> >  }
> >
> > +static int reftable_be_config(const char *var, const char *value,
> > +			      const struct config_context *ctx,
> > +			      void *_opts)
> > +{
> > +	struct reftable_write_options *opts = _opts;
> > +
> > +	if (!strcmp(var, "reftable.blocksize")) {
> > +		unsigned long block_size = git_config_ulong(var, value, ctx->kvi);
> > +		if (block_size > 16777215)
> > +			die("reftable block size cannot exceed 16MB");
> > +		opts->block_size = block_size;
> > +		return 0;
> 
> nit: unecessary return

It's unnecessary indeed. I first wanted to defend this, but then I noticed that I'm also being inconsistent here where the last branch won't have `return 0;` at the end of this series.

Will remove.
Show 16 quoted lines
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static struct ref_store *reftable_be_init(struct repository *repo,
> >  					  const char *gitdir,
> >  					  unsigned int store_flags)
> > @@ -245,12 +263,24 @@ static struct ref_store *reftable_be_init(struct repository *repo,
> >  	base_ref_store_init(&refs->base, repo, gitdir, &refs_be_reftable);
> >  	strmap_init(&refs->worktree_stacks);
> >  	refs->store_flags = store_flags;
> > -	refs->write_options.block_size = 4096;
> > +
> 
> Nit: do we need this newline?
I think it's easier to read that way.
Show 19 quoted lines
> >  	refs->write_options.hash_id = repo->hash_algo->format_id;
> >  	refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
> >  	refs->write_options.disable_auto_compact =
> >  		!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
> >
> > +	git_config(reftable_be_config, &refs->write_options);
> > +
> > +	/*
> > +	 * It is somewhat unfortunate that we have to mirror the default block
> > +	 * size of the reftable library here. But given that the write options
> > +	 * wouldn't be updated by the library here, and given that we require
> > +	 * the proper block size to trim reflog message so that they fit, we
> > +	 * must set up a proper value here.
> > +	 */
> > +	if (!refs->write_options.block_size)
> > +		refs->write_options.block_size = 4096;
> > +
> 
> Wouldn't it be to import and use `reftable/constants.h` here?

Headers in the "reftable/" directory which do not have a "reftable-" prefix are considered to be private. So those shouldn't be used.

Patrick
Previous: Karthik NayakNext: Patrick Steinhardt
Message 11 of 78 in “reftable: expose write options as config”
  1. 00/11 reftable: expose write options as configPatrick Steinhardt, May 2, 2024
  2. 01/11 reftable: consistently refer to `reftable_write_options` as `opts`Patrick Steinhardt, May 2, 2024
  3. Karthik NayakMay 10, 2024
  4. Patrick SteinhardtMay 10, 2024
  5. 02/11 reftable: consistently pass write opts as valuePatrick Steinhardt, May 2, 2024
  6. 03/11 reftable/writer: drop static variable used to initialize strbufPatrick Steinhardt, May 2, 2024
  7. 04/11 reftable/writer: improve error when passed an invalid block sizePatrick Steinhardt, May 2, 2024
  8. 05/11 reftable/dump: support dumping a table's block structurePatrick Steinhardt, May 2, 2024
  9. 06/11 refs/reftable: allow configuring block sizePatrick Steinhardt, May 2, 2024
  10. Karthik NayakMay 10, 2024
  11. Patrick SteinhardtMay 10, 2024
  12. 07/11 reftable: use `uint16_t` to track restart intervalPatrick Steinhardt, May 2, 2024
  13. 08/11 refs/reftable: allow configuring restart intervalPatrick Steinhardt, May 2, 2024
  14. 09/11 refs/reftable: allow disabling writing the object indexPatrick Steinhardt, May 2, 2024
  15. 10/11 reftable: make the compaction factor configurablePatrick Steinhardt, May 2, 2024
  16. Karthik NayakMay 10, 2024
  17. Patrick SteinhardtMay 10, 2024
  18. 11/11 refs/reftable: allow configuring geometric factorPatrick Steinhardt, May 2, 2024
  19. Karthik NayakMay 10, 2024
  20. Patrick SteinhardtMay 10, 2024
  21. Patrick SteinhardtMay 2, 2024
  22. Junio C HamanoMay 3, 2024
  23. Patrick SteinhardtMay 6, 2024
  24. Justin ToblerMay 6, 2024
  25. Karthik NayakMay 10, 2024
  26. Patrick SteinhardtMay 10, 2024
  27. 00/11 reftable: expose write options as configPatrick Steinhardt, May 10, 2024
  28. 01/11 reftable: consistently refer to `reftable_write_options` as `opts`Patrick Steinhardt, May 10, 2024
  29. Junio C HamanoMay 10, 2024
  30. 02/11 reftable: consistently pass write opts as valuePatrick Steinhardt, May 10, 2024
  31. Junio C HamanoMay 10, 2024
  32. Patrick SteinhardtMay 13, 2024
  33. 03/11 reftable/writer: drop static variable used to initialize strbufPatrick Steinhardt, May 10, 2024
  34. Junio C HamanoMay 10, 2024
  35. 04/11 reftable/writer: improve error when passed an invalid block sizePatrick Steinhardt, May 10, 2024
  36. Junio C HamanoMay 10, 2024
  37. Patrick SteinhardtMay 13, 2024
  38. 05/11 reftable/dump: support dumping a table's block structurePatrick Steinhardt, May 10, 2024
  39. Junio C HamanoMay 13, 2024
  40. 06/11 refs/reftable: allow configuring block sizePatrick Steinhardt, May 10, 2024
  41. 07/11 reftable: use `uint16_t` to track restart intervalPatrick Steinhardt, May 10, 2024
  42. Junio C HamanoMay 13, 2024
  43. Patrick SteinhardtMay 14, 2024
  44. 08/11 refs/reftable: allow configuring restart intervalPatrick Steinhardt, May 10, 2024
  45. Junio C HamanoMay 10, 2024
  46. Patrick SteinhardtMay 13, 2024
  47. 09/11 refs/reftable: allow disabling writing the object indexPatrick Steinhardt, May 10, 2024
  48. 10/11 reftable: make the compaction factor configurablePatrick Steinhardt, May 10, 2024
  49. Junio C HamanoMay 10, 2024
  50. Patrick SteinhardtMay 13, 2024
  51. Junio C HamanoMay 13, 2024
  52. Patrick SteinhardtMay 14, 2024
  53. 11/11 refs/reftable: allow configuring geometric factorPatrick Steinhardt, May 10, 2024
  54. Karthik NayakMay 10, 2024
  55. 00/11 reftable: expose write options as configPatrick Steinhardt, May 13, 2024
  56. 01/11 reftable: consistently refer to `reftable_write_options` as `opts`Patrick Steinhardt, May 13, 2024
  57. 02/11 reftable: pass opts as constant pointerPatrick Steinhardt, May 13, 2024
  58. Karthik NayakMay 17, 2024
  59. Justin ToblerMay 21, 2024
  60. Patrick SteinhardtMay 22, 2024
  61. 03/11 reftable/writer: drop static variable used to initialize strbufPatrick Steinhardt, May 13, 2024
  62. 04/11 reftable/writer: improve error when passed an invalid block sizePatrick Steinhardt, May 13, 2024
  63. 05/11 reftable/dump: support dumping a table's block structurePatrick Steinhardt, May 13, 2024
  64. Justin ToblerMay 21, 2024
  65. Patrick SteinhardtMay 22, 2024
  66. 06/11 refs/reftable: allow configuring block sizePatrick Steinhardt, May 13, 2024
  67. Karthik NayakMay 17, 2024
  68. 07/11 reftable: use `uint16_t` to track restart intervalPatrick Steinhardt, May 13, 2024
  69. 08/11 refs/reftable: allow configuring restart intervalPatrick Steinhardt, May 13, 2024
  70. Justin ToblerMay 21, 2024
  71. Patrick SteinhardtMay 22, 2024
  72. 09/11 refs/reftable: allow disabling writing the object indexPatrick Steinhardt, May 13, 2024
  73. 10/11 reftable: make the compaction factor configurablePatrick Steinhardt, May 13, 2024
  74. 11/11 refs/reftable: allow configuring geometric factorPatrick Steinhardt, May 13, 2024
  75. Karthik NayakMay 17, 2024
  76. Patrick SteinhardtMay 17, 2024
  77. Justin ToblerMay 21, 2024
  78. Patrick SteinhardtMay 22, 2024

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.