)]}'
{
  "commit": "c7e3b8085bb2f74371f5017f42c58b0acf01b915",
  "tree": "1a6147153f6e098a572237105e4ad07dffe3d004",
  "parents": [
    "f368df439b31b422169975cc3c95f7db6a46eada"
  ],
  "author": {
    "name": "Yee Cheng Chin",
    "email": "ychin.git@gmail.com",
    "time": "Thu Nov 27 02:16:06 2025 +0000"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Thu Nov 27 19:11:41 2025 -0800"
  },
  "message": "xdiff: optimize patience diff\u0027s LCS search\n\nThe find_longest_common_sequence() function in patience diff is\ninefficient as it calls binary_search() for every unique line it\nencounters when deciding where to put it in the sequence. From\ninstrumentation (using xctrace) on popular repositories, binary_search()\ntakes up 50-60% of the run time within patience_diff() when performing a\ndiff.\n\nTo optimize this, add a boundary condition check before binary_search()\nis called to see if the encountered unique line is located after the\nentire currently tracked longest subsequence. If so, skip the\nunnecessary binary search and simply append the entry to the end of\nsequence. Given that most files compared in a diff are usually quite\nsimilar to each other, this condition is very common, and should be hit\nmuch more frequently than the binary search.\n\nBelow are some end-to-end performance results by timing `git log\n--shortstat --oneline -500 --patience` on different repositories with\nthe old and new code. Generally speaking this seems to give at least\n8-10% speed up. The \"binary search hit %\" column describes how often the\nalgorithm enters the binary search path instead of the new faster path.\nEven in the WebKit case we can see that it\u0027s quite rare (1.46%).\n\n| Repo     | Speed difference | binary search hit % |\n|----------|------------------|---------------------|\n| vim      | 1.27x            | 0.01%               |\n| pytorch  | 1.16x            | 0.02%               |\n| cpython  | 1.14x            | 0.06%               |\n| ripgrep  | 1.14x            | 0.03%               |\n| git      | 1.13x            | 0.12%               |\n| vscode   | 1.09x            | 0.10%               |\n| WebKit   | 1.08x            | 1.46%               |\n\nThe benchmarks were done using hyperfine, on an Apple M1 Max laptop,\nwith git compiled with `-O3 -flto`.\n\nSigned-off-by: Yee Cheng Chin \u003cychin.git@gmail.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "77dc411d1937abbaf0e7c98f5d5bc68f4553ae64",
      "old_mode": 33188,
      "old_path": "xdiff/xpatience.c",
      "new_id": "d4094e6acf88104383798c38932e21d059f4c157",
      "new_mode": 33188,
      "new_path": "xdiff/xpatience.c"
    }
  ]
}
