)]}'
{
  "commit": "04570ef122fd4e428ffb9e8a5ddd691aff6b456b",
  "tree": "945f96c315015620912b2de8df83547d59304706",
  "parents": [
    "5c8f3a64d4133aedf0fce7bfeb8f80ffec3e5f9f"
  ],
  "author": {
    "name": "Lalit Maganti",
    "email": "lalitm@google.com",
    "time": "Tue Oct 20 00:06:40 2026 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Oct 20 07:06:40 2026 +0000"
  },
  "message": "perfetto: hold StatusOr\u0027s value in a union (#8126)\n\n**Summary**\n\n`StatusOr\u003cT\u003e` holds its value in a union rather than a `std::optional`,\nand `ASSIGN_OR_RETURN` moves an error out rather than copying it.\nStacked on #8121.\n\n**Why**\n\nThe optional\u0027s \"has value\" flag duplicated what the status already\nsays. It cost a byte plus padding in every StatusOr, and a check on\nevery access. `ASSIGN_OR_RETURN` also copied the error before returning\nit. Since #8120 holds errors on the heap, that copy was an allocation\nfor every error propagated.\n\n**Changes**\n\n- The value lives in an anonymous union, as `std::optional` keeps its\n  own, and exists exactly while the status is ok.\n- A value is only constructed where there was none, and only destroyed\n  where there will be none. One value replaces another by `T`\u0027s own\n  assignment, so no object is ever replaced in place. This needs no\n  casts and no `std::launder`.\n- A moved-from StatusOr keeps its status, and so keeps its moved-from\n  value, which it still destroys.\n- `StatusOr\u003cconst T\u003e` is no longer allowed: constructing into a const\n  member would need a cast. Its two uses, `StatusOr\u003cconst char* const\u003e`\n  in the winscope plugins, now return `StatusOr\u003cconst char*\u003e`.\n- `status() \u0026\u0026` moves an error out, and leaves the value of an ok\n  StatusOr in place. `ASSIGN_OR_RETURN` returns through it.\n\n**Binary size**\n\nStripped, against #8121: `trace_processor_shell` -40 KB, `perfetto`\n-0.9 KB, `libperfetto.so` -0.6 KB.\n\n**Benchmarks**\n\nBoth builds alternated three times, pinned to one CPU.\n\n| Benchmark               | #8121    | this     |        |\n| ----------------------- | -------- | -------- | ------ |\n| BM_StatusOrOkChain      | 15.0 ns  | 11.8 ns  | -21%   |\n| BM_StatusOrErrorChain   | 77.2 ns  | 53.5 ns  | -31%   |\n| BM_StatusOkChain        | 4.4 ns   | 4.4 ns   |        |\n| Others                  |          |          | +/-2%  |\n\nMoving rather than copying the error takes `StatusOr` error propagation\nbelow `main` (63.9 ns before the stack).\n\n**Testing**\n\n- New `StatusOrTest` cases use a type which counts its live objects.\n  They cover copy and move, every assignment between holding a value\n  and holding an error, self-assignment, `status() \u0026\u0026`, and\n  `ASSIGN_OR_RETURN`.\n- All unit, diff and integration tests pass locally, and the whole\n  Linux clang build compiles.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "12a4cb3f18ce0ada413f8ae7385efdc91cc5545d",
      "old_mode": 33188,
      "old_path": "include/perfetto/ext/base/status_macros.h",
      "new_id": "0accc256ea6a2c1db593d946200ec6b4c6b87556",
      "new_mode": 33188,
      "new_path": "include/perfetto/ext/base/status_macros.h"
    },
    {
      "type": "modify",
      "old_id": "81b6449213f924d844237aececa1427affd58143",
      "old_mode": 33188,
      "old_path": "include/perfetto/ext/base/status_or.h",
      "new_id": "16f6b79f79d3707c0b690b352f0ea406df04be56",
      "new_mode": 33188,
      "new_path": "include/perfetto/ext/base/status_or.h"
    },
    {
      "type": "modify",
      "old_id": "16489b358e8bf2d03404ac6e2661295481123d98",
      "old_mode": 33188,
      "old_path": "src/base/status_or_unittest.cc",
      "new_id": "f1b77214400e067e1d1c827f9dc5e803dcaefd9c",
      "new_mode": 33188,
      "new_path": "src/base/status_or_unittest.cc"
    },
    {
      "type": "modify",
      "old_id": "024b06ea60dfba13f19824be1c7a5090a8a595ba",
      "old_mode": 33188,
      "old_path": "src/trace_processor/plugins/winscope_importer/winscope_proto_mapping.h",
      "new_id": "e9493c84020f3b07190cb51ea03add4512de9815",
      "new_mode": 33188,
      "new_path": "src/trace_processor/plugins/winscope_importer/winscope_proto_mapping.h"
    },
    {
      "type": "modify",
      "old_id": "cdd6c9f3b2f351c2d4203f92e2740f650a8324a8",
      "old_mode": 33188,
      "old_path": "src/trace_processor/plugins/winscope_proto_to_args_with_defaults/winscope_proto_to_args_with_defaults.cc",
      "new_id": "becf92700f5327e4657823d1a40fb929235bd24b",
      "new_mode": 33188,
      "new_path": "src/trace_processor/plugins/winscope_proto_to_args_with_defaults/winscope_proto_to_args_with_defaults.cc"
    }
  ]
}
