)]}'
{
  "commit": "c91f7e86727683118b6096757717135463fdcdd7",
  "tree": "cadff450fe5e0c3769df302a93379fc5a7bc2ba3",
  "parents": [
    "755ea88213fc46818ede21a28fc2c191e2a24bcb"
  ],
  "author": {
    "name": "David \u0027Digit\u0027 Turner",
    "email": "digit@google.com",
    "time": "Fri Mar 20 16:20:27 2026 +0000"
  },
  "committer": {
    "name": "GN LUCI",
    "email": "gn-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "time": "Mon Mar 23 09:18:55 2026 -0700"
  },
  "message": "Remove premature target writing before validation during `gn gen`.\n\nThis change modifies the way GN schedules writing targets to the\nNinja build plan to remove random crashes that have been affecting\nthe Fuchsia build for several weeks now.\n\nThe root cause of the problem, described in the associated bug,\nis that a target and *all* its dependencies, including validations,\nmust be resolved to ensure there are no crash during the write\n(which can call Target::GetMetadata() for generated_file() targets,\nwhich will walk standard and validation targets).\n\nBefore this CL, the code used the condition that a target had to\nbe resolved, and all its validations *defined*, which is NOT\nsufficient.\n\nThe crash was hidden by the fact that target resolution was pushed\nto the background, resulting in race conditions and non-deterministic\nordering of the writes. This behavior was removed in a previous CL,\nthe current one focuses on the actual logic fix.\n\nThe fix includes defining a new RecordState enum to better describe\nthe different states of a given BuilderRecord, replacing the simple\n`resolved_` boolean flag. State transitions can only happen under\nspecific conditions that are now properly documented.\n\n- builder_record.h: Introduce RecordState enum to model the\n  state of each record (Init/Defined/Resolved/Finalized). and\n  document them properly, along with the conditions when a\n  record can change state.\n\n  Rename resolved() to is_resolved(), can_write() to can_finalize(),\n  add is_defined() and is_finalized()\n\n  Add Set{Defined,Resolved,Finalized}() methods to change the\n  state and document what the caller should do just after that\n  to ensure proper tracking of state changes.\n\n  Add NotifyWaitingDependentsOnXXX() template methods to\n  clarify the builder.cc code and keep the BuilderRecordSet\n  values hidden.\n\n  Remove validation_deps_ which is no longer useful.\n\n  Rename the BuilderRecordSet variables for clarity, better\n  explaining their purpose.\n\n  Add DEBUG_BUILDER_RECORD macro. Set this to 1 to enable\n  debug logs during Builder operations during development.\n\n- builder.cc: Add FinalizeItem() method, and modify the logic\n  accordingly, using the new BuilderRecord methods. Add\n  DEBUG_BUILDER_RECORD_LOG() statements to print debug traces\n  when DEBUG_BUILD_RECORD is set to 1.\n\n- builder_unittest.cc: Adjust unit-tests to reflect the new\n  logic.\n\nBenchmarking shows now statistically difference in `gn gen`\nand `gn gen --check` times for Fuchsia and Chrome builds on\na local cloudtop.\n\nBug: 494481832\nChange-Id: Ibeae5350818c6b73fb88247fc73f85ab596c9531\nReviewed-on: https://gn-review.googlesource.com/c/gn/+/21721\nCommit-Queue: David Turner \u003cdigit@google.com\u003e\nReviewed-by: Andrew Grieve \u003cagrieve@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "9a85e2063bfc8df69f0cc5e64137d6c46e90e601",
      "old_mode": 33188,
      "old_path": "src/gn/builder.cc",
      "new_id": "cc4d6ffd8b78aeb800947a2059dc2dfc5ccc14d5",
      "new_mode": 33188,
      "new_path": "src/gn/builder.cc"
    },
    {
      "type": "modify",
      "old_id": "ebff0cc3ff88669b99335e0716c144be86189ca0",
      "old_mode": 33188,
      "old_path": "src/gn/builder.h",
      "new_id": "5e6c88a58a7efc8abf74e329a1f659235aea547c",
      "new_mode": 33188,
      "new_path": "src/gn/builder.h"
    },
    {
      "type": "modify",
      "old_id": "ff1a6136e8798d9b91189a4bd3fd2f9f82c5aa8d",
      "old_mode": 33188,
      "old_path": "src/gn/builder_record.cc",
      "new_id": "5c0b84d42e8e2be197a575c3dbb4c1b5ce7df9b4",
      "new_mode": 33188,
      "new_path": "src/gn/builder_record.cc"
    },
    {
      "type": "modify",
      "old_id": "b3b4aba06e1aba67da340c9fc97fe25ef6df7fa3",
      "old_mode": 33188,
      "old_path": "src/gn/builder_record.h",
      "new_id": "9c3f0bea7d37160367d9714b363c69c26f76bb0f",
      "new_mode": 33188,
      "new_path": "src/gn/builder_record.h"
    },
    {
      "type": "modify",
      "old_id": "68f365e1775569626491550ca40c377aba87f25e",
      "old_mode": 33188,
      "old_path": "src/gn/builder_unittest.cc",
      "new_id": "990cb3533b371fff380b644998b3e6eff72e79ba",
      "new_mode": 33188,
      "new_path": "src/gn/builder_unittest.cc"
    }
  ]
}
