)]}'
{
  "commit": "a61035fab9299de25ef46bbaedccd08734ce66c9",
  "tree": "b2b5c4a55fafc6ede4d9f2f7b79bc421c5dfcb62",
  "parents": [
    "a018953688f1b10bddf91bff8747068f5f4746a4"
  ],
  "author": {
    "name": "Karthik Nayak",
    "email": "karthik.188@gmail.com",
    "time": "Wed Oct 07 13:20:16 2026 +0200"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Wed Oct 07 07:13:41 2026 -0700"
  },
  "message": "packed-refs: use `fwrite()` when passing refs verbatim\n\nThe `write_with_updates()` function uses a `struct ref_iterator` to\niterate over all refs to write to the temporary packed-refs file. It\nreceives the iterator from `packed_ref_iterator_begin()` which takes a\nsnapshot of the \u0027packed-refs\u0027 file.\n\nWhile writing to the new packed-refs file, writes are routed via\n`write_packed_entry()` which uses `fprintf()`. Even for references which\nhaven\u0027t changed, we use the same mechanism. This is slow since we need\nto do string parsing and formatting. Instead, let\u0027s track the position\nof unchanged references in the snapshot iterator and directly write\nverbatim via `fwrite()`.\n\nWith this, any sanitization which was happening as a side effect of\nreformatting is now lost. But that was never the job of this section of\nthe code, since the main intention is to simply rewrite the remaining\nrefs post deletion of the selective few.\n\nThis removes the unnecessary formatting operation involved. We can see a\nconsistent ~20% performance improvement when deleting from packed\nreferences.\n\nBenchmark 1: update-ref: delete ref (refcount \u003d 100000, revision \u003d master)\n  Time (mean ± σ):      28.7 ms ±   1.7 ms    [User: 22.5 ms, System: 5.9 ms]\n  Range (min … max):    26.7 ms …  33.3 ms    46 runs\n\nBenchmark 2: update-ref: delete ref (refcount \u003d 100000, revision \u003d b4/kn-speedup-packed-refs)\n  Time (mean ± σ):      23.8 ms ±   1.2 ms    [User: 17.5 ms, System: 6.0 ms]\n  Range (min … max):    22.1 ms …  27.7 ms    56 runs\n\nSummary\n  update-ref: delete ref (refcount \u003d 100000, revision \u003d b4/kn-speedup-packed-refs) ran\n    1.21 ± 0.09 times faster than update-ref: delete ref (refcount \u003d 100000, revision \u003d master)\n\nSigned-off-by: Karthik Nayak \u003ckarthik.188@gmail.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "a73fc6aca78023314fb59ce8803e6293d2dd453d",
      "old_mode": 33188,
      "old_path": "refs/packed-backend.c",
      "new_id": "53511f2d91900a92afc0b436ea3b79007cc172e1",
      "new_mode": 33188,
      "new_path": "refs/packed-backend.c"
    }
  ]
}
