)]}'
{
  "commit": "1970333644fad127c68046697b9b86fd8d7f28c2",
  "tree": "dab35d0b98e60ba8a927e1b16debddb4a17c2ebe",
  "parents": [
    "e0011188ca0edc31ed861357014fd0f229d67448"
  ],
  "author": {
    "name": "Patrick Steinhardt",
    "email": "ps@pks.im",
    "time": "Mon May 12 17:15:56 2025 +0200"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Mon May 12 10:55:24 2025 -0700"
  },
  "message": "reftable: fix perf regression when reading blocks of unwanted type\n\nIn fd888311fbc (reftable/table: move reading block into block reader,\n2025-04-07), we have refactored how reftable blocks are read so that\nmost of the logic is contained in the \"block.c\" subsystem itself. Most\nimportantly, the whole logic to read the data itself is now contained in\nthat subsystem.\n\nThis change caused a significant performance regression though when\nreading blocks that aren\u0027t of the specific type one is searching for:\n\n    Benchmark 1: update-ref: create 100k refs (revision \u003d fd888311fbc~)\n      Time (mean ± σ):      2.171 s ±  0.028 s    [User: 1.189 s, System: 0.977 s]\n      Range (min … max):    2.117 s …  2.206 s    10 runs\n\n    Benchmark 2: update-ref: create 100k refs (revision \u003d fd888311fbc)\n      Time (mean ± σ):      3.418 s ±  0.030 s    [User: 2.371 s, System: 1.037 s]\n      Range (min … max):    3.377 s …  3.473 s    10 runs\n\n    Summary\n      update-ref: create 100k refs (revision \u003d fd888311fbc~) ran\n        1.57 ± 0.02 times faster than update-ref: create 100k refs (revision \u003d fd888311fbc)\n\nThe root caute of the performance regression is that we changed when\nexactly blocks of an uninteresting type are being discarded. Previous to\nthe refactoring in the mentioned commit we\u0027d load the block data, read\nits type, notice that it\u0027s not the wanted type and discard the block.\nAfter the commit though we don\u0027t discard the block immediately, but we\nfully decode it only to realize that it\u0027s not the desired type. We then\ndiscard the block again, but have already performed a bunch of pointless\nwork.\n\nFix the regression by making `reftable_block_init()` return early in\ncase the block is not of the desired type. This fixes the performance\nhit:\n\n    Benchmark 1: update-ref: create 100k refs (revision \u003d HEAD~)\n      Time (mean ± σ):      2.712 s ±  0.018 s    [User: 1.990 s, System: 0.716 s]\n      Range (min … max):    2.682 s …  2.741 s    10 runs\n\n    Benchmark 2: update-ref: create 100k refs (revision \u003d HEAD)\n      Time (mean ± σ):      1.670 s ±  0.012 s    [User: 0.991 s, System: 0.676 s]\n      Range (min … max):    1.652 s …  1.693 s    10 runs\n\n    Summary\n      update-ref: create 100k refs (revision \u003d HEAD) ran\n        1.62 ± 0.02 times faster than update-ref: create 100k refs (revision \u003d HEAD~)\n\nNote that the baseline performance is lower than in the original due to\na couple of unrelated performance improvements that have landed since\nthe original commit.\n\nSigned-off-by: Patrick Steinhardt \u003cps@pks.im\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "795815b47629912997a55cc08693de39caab6381",
      "old_mode": 33188,
      "old_path": "reftable/block.c",
      "new_id": "31569cba593abc0266c511b2f9b7cbe28df8e6ee",
      "new_mode": 33188,
      "new_path": "reftable/block.c"
    },
    {
      "type": "modify",
      "old_id": "04c3b518c8746092bb1b1b5456b107c9981fbdc4",
      "old_mode": 33188,
      "old_path": "reftable/reftable-block.h",
      "new_id": "0b05a8f7e376bc897399d701f9634f650e4d87c8",
      "new_mode": 33188,
      "new_path": "reftable/reftable-block.h"
    },
    {
      "type": "modify",
      "old_id": "ee831276158c93a1e6daba219fce182a653eac45",
      "old_mode": 33188,
      "old_path": "reftable/table.c",
      "new_id": "56362df0eda5a6b63fbbac5395c97ce05b822596",
      "new_mode": 33188,
      "new_path": "reftable/table.c"
    },
    {
      "type": "modify",
      "old_id": "7dbd93601c769650ca8adaa78d0b384c6bebbf71",
      "old_mode": 33188,
      "old_path": "t/unit-tests/t-reftable-block.c",
      "new_id": "52f1dae1c9576de8ffd82bfca1b84089bc11cdc5",
      "new_mode": 33188,
      "new_path": "t/unit-tests/t-reftable-block.c"
    }
  ]
}
