)]}'
{
  "commit": "f2f5b23ea7bf95492c683c046b5e7a624364e3b7",
  "tree": "eed3170638cda94a77cbfaf287d6f6729623c13b",
  "parents": [
    "844bbe7cf8c8bf3dd2678c4b1f3a001af295f7ee"
  ],
  "author": {
    "name": "Takuto Ikuta",
    "email": "tikuta@google.com",
    "time": "Wed May 20 13:08:07 2026 +0900"
  },
  "committer": {
    "name": "gn-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "email": "gn-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "time": "Tue May 19 21:31:19 2026 -0700"
  },
  "message": "Reduce ResolvedTargetData lock contention by sharding targets map\n\nIn the parallel writing phase of \u0027gn gen\u0027, multiple threads access a\nsingle \u0027std::shared_mutex\u0027 and \u0027UniqueVector\u0027 inside ResolvedTargetData\nat high frequency. Although shared locks (read locks) are used, the\natomic reference count operations within the shared mutex cause massive\ncache line bouncing (lock contention) on multi-core systems, severely\ndegrading parallel performance.\n\nTo resolve this, this CL shards the shared targets map and its mutex\ninto 128 independent shards. We also use std::hash to distribute targets\nevenly across shards and avoid pointer alignment biases (which would\nhappen with simple pointer bit shifts).\n\nWe conducted hyperfine benchmarks on Chromium \u0027out/Default\u0027 across\ndifferent shard counts to find the optimal value, compared to the\noriginal baseline:\n- Base (No sharding, 1 lock): 2.716s ± 0.059s\n- 8 shards: 2.723s ± 0.056s (Lock contention unresolved)\n- 16 shards: 2.755s ± 0.096s\n- 32 shards: 2.495s ± 0.011s (approx. 8.1% faster than Base)\n- 64 shards: 2.531s ± 0.062s\n- 128 shards: 2.443s ± 0.089s (approx. 10.0% faster than Base / -0.27s, Optimal spot)\n- 256 shards: 2.507s ± 0.064s\n- 512 shards: 2.523s ± 0.093s\n- 1024 shards: 2.534s ± 0.073s\n\n128 shards is chosen as it provides the best performance scaling for\nhigh-core workstations while keeping minimal memory overhead.\n\nCumulative CPU time of \u0027file_write_ninja\u0027 phase: approx. 33% reduction.\n\nBug: 502431091\nChange-Id: I366057a87e17e3438f028e1142928ba55e47dc69\nReviewed-on: https://gn-review.googlesource.com/c/gn/+/22801\nReviewed-by: Matt Stark \u003cmsta@google.com\u003e\nCommit-Queue: Takuto Ikuta \u003ctikuta@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "628e6a4bdf28a258dec899982f9263385de1a48a",
      "old_mode": 33188,
      "old_path": "src/gn/resolved_target_data.cc",
      "new_id": "db5a8ed898fdf50ffce7cbc87f0a31a471e87903",
      "new_mode": 33188,
      "new_path": "src/gn/resolved_target_data.cc"
    },
    {
      "type": "modify",
      "old_id": "a184e3d2722932f80faafb637076bb0833db6edb",
      "old_mode": 33188,
      "old_path": "src/gn/resolved_target_data.h",
      "new_id": "0046481706a123fe91e68ee6daa7fb01789965af",
      "new_mode": 33188,
      "new_path": "src/gn/resolved_target_data.h"
    }
  ]
}
