)]}'
{
  "commit": "17cd994d6e46f7d28ec90d68fb91815770538565",
  "tree": "b6fb1f017e58b2a703484624c9bbaff440db3b3a",
  "parents": [
    "6531a981a86daf8c83ba7d933d824bab27f6e02a"
  ],
  "author": {
    "name": "Heejin Ahn",
    "email": "aheejin@gmail.com",
    "time": "Sat Aug 29 08:05:59 2026"
  },
  "committer": {
    "name": "Heejin Ahn",
    "email": "aheejin@gmail.com",
    "time": "Tue Sep 01 00:56:15 2026"
  },
  "message": "[wasm-split] Split immutable globals\n\nPreviously, we treated all modules items in the same way: if a module\nitem was used in the primary module or multiple secondary modules, we\nput the item in the primary module and exported it from there, and\nsecondary modules using the item imported it. So\n1. When an item was used in both the primary and secondary modules, it\n   was placed in the primary module and exported from there, and\n   imported from the secondary modules\n2. When an item was not used in the primary module but used in multiple\n   secondary modules, it was still placed in the primary module and\n   exported from there, and imported from the secondary modules\n\nBut in case of immutable globals, we can have as many copies of the same\nglobal as possible, and we can just copy them to the secondary modules.\nSo whether it is used in the primary module or multiple secondary\nmodules, each module that uses it has its own copy. This reduces the\nprimary module size because, in case of 1, we don\u0027t need to put the\nglobal in the primary module in the first place. Also in case of 2, we\ndon\u0027t need to add an export of a global to the primary module.\n\nThis is a trade-off and may increase the secondary module sizes instead.\nBut given that the main goal of using wasm-split is mostly to reduce the\nloading time of the primary module, I think this trade-off is worth it.\n\nIn case of merge-opt-split workflow, after interprocedural\noptimizations, many globals that used to be only used in a single\nsecondary module gets used in multiple secondary modules, and thus are\nplaced in the primary module after splitting, increasing the primary\nmodule size. This undoes this effect.\n\nNote that this also copy immutable global imports to secondary modules\nwhenever it is possible, because we didn\u0027t exclude them in\n`shareElement`.\n\n---\n\nResults\n\n- acx_gallery\n  - Input\n    - Total: 23648k\n    - Primary: 1337k\n  - Current\n    - Total: 22240k\n    - Primary: 1579k\n  - This PR\n    - Total: 22884k\n      - vs. Current: +2.8%\n      - vs. Input: -3.2%\n    - Primary: 1348k\n      - vs. Current: -14.6%\n      - vs. Input: +0.8%\n\n- essentials\n  - Input\n    - Total: 83384k\n    - Primary: 5600k\n  - Current\n    - Total: 77060k\n    - Primary: 6396k\n  - This PR\n    - Total: 79624k\n      - vs. Current: +3.3%\n      - vs. Input: -4.5%\n    - Primary: 5715k\n      - vs. Current: -10.6%\n      - vs. Input: +2.0%\n\nCompared to the current code (without this patch), we can see this\nreduces the primary module size significantly (-14.6% and -10.6% each)\nat the expense of slight increase of the total combined module size\n(+3-4%).\n\nBut compared to the original input, this still does not reduce the\nprimary module size (+1-2%), while it decreases the combined\nmodule size slightly (-3-4%).\n\nThe measurements were done with with 07/2026 version of Dart apps, and\nafter removing all (internal) exports that were not marked as\n`@binaryen.js.called`. (I have a pass that does this in my local\nmachine, but I haven\u0027t uploaded it yet)\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b340ad5f874746b7d3d9b35563b11af57c39334a",
      "old_mode": 33188,
      "old_path": "src/ir/module-splitting.cpp",
      "new_id": "f4ed8e61fbe98c65de15dbca1172c3ddab8d2417",
      "new_mode": 33188,
      "new_path": "src/ir/module-splitting.cpp"
    },
    {
      "type": "modify",
      "old_id": "b860fb144a5adb7b5a822891df43ae24c22146ac",
      "old_mode": 33188,
      "old_path": "test/lit/wasm-split/dispatch-table-base-global-used-elsewhere.wast",
      "new_id": "a19bf77b939b14cf6e5a017e7407e1e5b7faf5a0",
      "new_mode": 33188,
      "new_path": "test/lit/wasm-split/dispatch-table-base-global-used-elsewhere.wast"
    },
    {
      "type": "modify",
      "old_id": "9c14bb09e9862a8a6020adf14af2fb93ea4321f9",
      "old_mode": 33188,
      "old_path": "test/lit/wasm-split/passive-deps.wast",
      "new_id": "5f16ebc596ce79fd4d1af544f9c9851313317080",
      "new_mode": 33188,
      "new_path": "test/lit/wasm-split/passive-deps.wast"
    },
    {
      "type": "modify",
      "old_id": "b4a8b3db881910a305101b8202cb639c3cffb0a2",
      "old_mode": 33188,
      "old_path": "test/lit/wasm-split/split-module-items.wast",
      "new_id": "eb5f59b962c9055b1253e26ebff30cfd51ab837f",
      "new_mode": 33188,
      "new_path": "test/lit/wasm-split/split-module-items.wast"
    },
    {
      "type": "modify",
      "old_id": "ad702a4363bd52867a9c7e7b02f82feebd0c6771",
      "old_mode": 33188,
      "old_path": "test/lit/wasm-split/transitive-globals.wast",
      "new_id": "00fc2d3bd3efb6dc5bb711367464573ab7383f3d",
      "new_mode": 33188,
      "new_path": "test/lit/wasm-split/transitive-globals.wast"
    },
    {
      "type": "modify",
      "old_id": "56e96807aae790f2a9fb4d8d79ca9f61f7ff206e",
      "old_mode": 33188,
      "old_path": "test/lit/wasm-split/transitive-globals2.wast",
      "new_id": "04944971521f0057aaa592ab986525c70b4ceba2",
      "new_mode": 33188,
      "new_path": "test/lit/wasm-split/transitive-globals2.wast"
    },
    {
      "type": "modify",
      "old_id": "3f2cb97c392221e27f0d7f9389c6ae608cb2ff1c",
      "old_mode": 33188,
      "old_path": "test/lit/wasm-split/transitive-immutable-globals-multi.wast",
      "new_id": "72949f83972fa6c01fa65b25c969dbfb08631727",
      "new_mode": 33188,
      "new_path": "test/lit/wasm-split/transitive-immutable-globals-multi.wast"
    }
  ]
}
