git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Han-Wen Nienhuys <hanwenn@gmail.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Taylor Blau <me@ttaylorr.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v3 00/11] reftable: small set of fixes
Date: Mon, 11 Dec 2023 10:07:25 +0100	[thread overview]
Message-ID: <cover.1702285387.git.ps@pks.im> (raw)
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 5933 bytes --]

Hi,

this is the third version of my patch series that addresses several
smallish issues in the reftable backend.

There's only a small set of changes compared to v2:

  - Patch 4: convert to use a `struct strbuf` instead of `snprintf()`.

  - Patch 5: improve commit message.

  - Patch 6: note that `stack_filename()` resets the `struct strbuf` in
    the commit message.

  - Patch 7: use the `struct filelock`'s lock path instead of the
    temporary buffer.

Thanks for your suggestions, Taylor and Eric!

Patrick

Patrick Steinhardt (11):
  reftable: wrap EXPECT macros in do/while
  reftable: handle interrupted reads
  reftable: handle interrupted writes
  reftable/stack: verify that `reftable_stack_add()` uses
    auto-compaction
  reftable/stack: perform auto-compaction with transactional interface
  reftable/stack: reuse buffers when reloading stack
  reftable/stack: fix stale lock when dying
  reftable/stack: fix use of unseeded randomness
  reftable/merged: reuse buffer to compute record keys
  reftable/block: introduce macro to initialize `struct block_iter`
  reftable/block: reuse buffer to compute record keys

 reftable/block.c          |  23 ++++----
 reftable/block.h          |   6 +++
 reftable/block_test.c     |   4 +-
 reftable/blocksource.c    |   2 +-
 reftable/iter.h           |   8 +--
 reftable/merged.c         |  31 +++++------
 reftable/merged.h         |   2 +
 reftable/reader.c         |   7 ++-
 reftable/readwrite_test.c |   6 +--
 reftable/stack.c          |  73 +++++++++++---------------
 reftable/stack_test.c     | 107 +++++++++++++++++++++++++++++++++++++-
 reftable/test_framework.h |  58 ++++++++++++---------
 12 files changed, 213 insertions(+), 114 deletions(-)

Range-diff against v2:
 1:  0ebbb02d32 =  1:  5b2a64ca9f reftable: wrap EXPECT macros in do/while
 2:  b404fdf066 =  2:  3e8e63ece5 reftable: handle interrupted reads
 3:  8c1d78b12b =  3:  1700d00d1c reftable: handle interrupted writes
 4:  8061b9d2fc !  4:  5e27d0a556 reftable/stack: verify that `reftable_stack_add()` uses auto-compaction
    @@ reftable/stack_test.c: static void test_reftable_stack_auto_compaction(void)
     +{
     +	struct reftable_write_options cfg = { 0 };
     +	struct reftable_stack *st = NULL;
    ++	struct strbuf refname = STRBUF_INIT;
     +	char *dir = get_tmp_dir(__LINE__);
     +	int err, i, n = 20;
     +
    @@ reftable/stack_test.c: static void test_reftable_stack_auto_compaction(void)
     +			.value_type = REFTABLE_REF_SYMREF,
     +			.value.symref = "master",
     +		};
    -+		char name[100];
     +
     +		/*
     +		 * Disable auto-compaction for all but the last runs. Like this
    @@ reftable/stack_test.c: static void test_reftable_stack_auto_compaction(void)
     +		 */
     +		st->disable_auto_compact = i != n;
     +
    -+		snprintf(name, sizeof(name), "branch%04d", i);
    -+		ref.refname = name;
    ++		strbuf_reset(&refname);
    ++		strbuf_addf(&refname, "branch-%04d", i);
    ++		ref.refname = refname.buf;
     +
     +		err = reftable_stack_add(st, &write_test_ref, &ref);
     +		EXPECT_ERR(err);
    @@ reftable/stack_test.c: static void test_reftable_stack_auto_compaction(void)
     +	}
     +
     +	reftable_stack_destroy(st);
    ++	strbuf_release(&refname);
     +	clear_dir(dir);
     +}
     +
 5:  77b9ae8aa6 !  5:  dd180eba40 reftable/stack: perform auto-compaction with transactional interface
    @@ Commit message
     
         Whenever updating references or reflog entries in the reftable stack, we
         need to add a new table to the stack, thus growing the stack's length by
    -    one. It can thus happen quite fast that the stack grows very long, which
    -    results in performance issues when trying to read records. But besides
    -    performance issues, this can also lead to exhaustion of file descriptors
    -    very rapidly as every single table requires a separate descriptor when
    +    one. The stack can grow to become quite long rather quickly, leading to
    +    performance issues when trying to read records. But besides performance
    +    issues, this can also lead to exhaustion of file descriptors very
    +    rapidly as every single table requires a separate descriptor when
         opening the stack.
     
         While git-pack-refs(1) fixes this issue for us by merging the tables, it
 6:  f797feff8d !  6:  6ed9ba60db reftable/stack: reuse buffers when reloading stack
    @@ Commit message
         of the allocated buffer outside of the loop.
     
         Refactor the code to instead reuse the buffers to reduce the number of
    -    allocations we need to do.
    +    allocations we need to do. Note that we do not have to manually reset
    +    the buffer because `stack_filename()` does this for us already.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
 7:  e82a68aecd !  7:  fbd9efa56d reftable/stack: fix stale lock when dying
    @@ reftable/stack.c: static int reftable_stack_init_addition(struct reftable_additi
      	}
      	if (st->config.default_permissions) {
     -		if (chmod(add->lock_file_name.buf, st->config.default_permissions) < 0) {
    -+		if (chmod(lock_file_name.buf, st->config.default_permissions) < 0) {
    ++		if (chmod(add->lock_file->filename.buf, st->config.default_permissions) < 0) {
      			err = REFTABLE_IO_ERROR;
      			goto done;
      		}
 8:  bab4fb93df =  8:  5598460b81 reftable/stack: fix use of unseeded randomness
 9:  cbf77ec45a =  9:  79e0382603 reftable/merged: reuse buffer to compute record keys
10:  c9a1405a9a = 10:  8574ad7635 reftable/block: introduce macro to initialize `struct block_iter`
11:  02b11f3a80 = 11:  eeb6c35823 reftable/block: reuse buffer to compute record keys

base-commit: 564d0252ca632e0264ed670534a51d18a689ef5d
-- 
2.43.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-12-11  9:07 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-21  7:04 [PATCH 0/8] reftable: small set of fixes Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 1/8] reftable: wrap EXPECT macros in do/while Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 2/8] reftable: handle interrupted reads Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 3/8] reftable: handle interrupted writes Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 4/8] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 5/8] reftable/stack: perform auto-compaction with transactional interface Patrick Steinhardt
2023-12-21 10:29   ` Han-Wen Nienhuys
2023-12-21 10:45     ` Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 6/8] reftable/stack: reuse buffers when reloading stack Patrick Steinhardt
2023-11-21  7:04 ` [PATCH 7/8] reftable/merged: reuse buffer to compute record keys Patrick Steinhardt
2023-12-21 10:48   ` Han-Wen Nienhuys
2023-11-21  7:04 ` [PATCH 8/8] reftable/stack: fix stale lock when dying Patrick Steinhardt
2023-12-08 14:52 ` [PATCH v2 00/11] reftable: small set of fixes Patrick Steinhardt
2023-12-08 14:52   ` [PATCH v2 01/11] reftable: wrap EXPECT macros in do/while Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 02/11] reftable: handle interrupted reads Patrick Steinhardt
2023-12-08 21:30     ` Taylor Blau
2023-12-11  9:08       ` Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 03/11] reftable: handle interrupted writes Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 04/11] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction Patrick Steinhardt
2023-12-08 21:35     ` Taylor Blau
2023-12-08 23:46       ` Eric Sunshine
2023-12-11  9:08         ` Patrick Steinhardt
2023-12-11  9:36           ` Eric Sunshine
2023-12-08 14:53   ` [PATCH v2 05/11] reftable/stack: perform auto-compaction with transactional interface Patrick Steinhardt
2023-12-08 22:14     ` Taylor Blau
2023-12-11  9:08       ` Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 06/11] reftable/stack: reuse buffers when reloading stack Patrick Steinhardt
2023-12-08 22:17     ` Taylor Blau
2023-12-11  9:08       ` Patrick Steinhardt
2023-12-21 10:58         ` Han-Wen Nienhuys
2023-12-08 14:53   ` [PATCH v2 07/11] reftable/stack: fix stale lock when dying Patrick Steinhardt
2023-12-08 22:24     ` Taylor Blau
2023-12-11  9:08       ` Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 08/11] reftable/stack: fix use of unseeded randomness Patrick Steinhardt
2023-12-21 10:49     ` Han-Wen Nienhuys
2023-12-08 14:53   ` [PATCH v2 09/11] reftable/merged: reuse buffer to compute record keys Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 10/11] reftable/block: introduce macro to initialize `struct block_iter` Patrick Steinhardt
2023-12-08 14:53   ` [PATCH v2 11/11] reftable/block: reuse buffer to compute record keys Patrick Steinhardt
2023-12-21 10:43     ` Han-Wen Nienhuys
2023-12-28  5:53       ` Patrick Steinhardt
2023-12-08 22:26   ` [PATCH v2 00/11] reftable: small set of fixes Taylor Blau
2023-12-11  9:07 ` Patrick Steinhardt [this message]
2023-12-11  9:07   ` [PATCH v3 01/11] reftable: wrap EXPECT macros in do/while Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 02/11] reftable: handle interrupted reads Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 03/11] reftable: handle interrupted writes Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 04/11] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction Patrick Steinhardt
2023-12-11 20:15     ` Taylor Blau
2023-12-12  3:44       ` Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 05/11] reftable/stack: perform auto-compaction with transactional interface Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 06/11] reftable/stack: reuse buffers when reloading stack Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 07/11] reftable/stack: fix stale lock when dying Patrick Steinhardt
2023-12-11  9:07   ` [PATCH v3 08/11] reftable/stack: fix use of unseeded randomness Patrick Steinhardt
2023-12-11  9:08   ` [PATCH v3 09/11] reftable/merged: reuse buffer to compute record keys Patrick Steinhardt
2023-12-11  9:08   ` [PATCH v3 10/11] reftable/block: introduce macro to initialize `struct block_iter` Patrick Steinhardt
2023-12-11  9:08   ` [PATCH v3 11/11] reftable/block: reuse buffer to compute record keys Patrick Steinhardt
2023-12-11 20:16   ` [PATCH v3 00/11] reftable: small set of fixes Taylor Blau
2023-12-12  3:45     ` Patrick Steinhardt
2023-12-21 11:08 ` [PATCH 0/8] " Han-Wen Nienhuys

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=cover.1702285387.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=hanwenn@gmail.com \
    --cc=jrnieder@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=sunshine@sunshineco.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).