Closed Bug 1244845 Opened 4 years ago Closed 4 years ago

Share script-sources between asm.js modules

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED DUPLICATE of bug 1211723
Tracking Status
firefox47 --- affected

People

(Reporter: jujjyl, Unassigned)

Details

Bug 1168981 discusses sharing compiled asm.js code, however, looking at about:memory reports, it looks like script-sources are not being shared either, which creates a lot of wasted memory.

STR:

1. Visit https://dl.dropboxusercontent.com/u/40949268/emcc/bugs/PhysicsStressTest_16threads/12_PhysicsStressTest.html

or offline downloadable zip of the same:

https://dl.dropboxusercontent.com/u/40949268/emcc/bugs/PhysicsStressTest_16threads/PhysicsStressTest_16threads.zip

2. After the page loads, take an about:memory snapshot

Observed:

Each web worker (16 of them + main thread) duplicates 64MB of identical UTF-16 string data in memory corresponding to the asm.js module of the page. The log reads

6,164.81 MB (100.0%) -- explicit
├──5,393.87 MB (87.49%) -- workers/workers(/C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.html)
│  ├────339.34 MB (05.50%) -- worker(pthread-main.js, 0x1de87b16000)
│  │    ├──272.99 MB (04.43%) ++ zone(0x1ded5b29800)
│  │    ├───66.17 MB (01.07%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───2.69 MB (00.04%) ++ (12 tiny)
│  │    └────0.18 MB (00.00%) ++ (2 tiny)
│  ├────339.34 MB (05.50%) -- worker(pthread-main.js, 0x1de87b17000)
│  │    ├──272.99 MB (04.43%) ++ zone(0x1ded5b20800)
│  │    ├───66.17 MB (01.07%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───2.69 MB (00.04%) ++ (12 tiny)
│  │    └────0.18 MB (00.00%) ++ (2 tiny)
│  ├────339.34 MB (05.50%) -- worker(pthread-main.js, 0x1de87b16800)
│  │    ├──272.99 MB (04.43%) ++ zone(0x1ded0f4e800)
│  │    ├───66.17 MB (01.07%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───2.69 MB (00.04%) ++ (12 tiny)
│  │    └────0.18 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de84b31800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0d6b800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b0c800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded5b28000)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b0d800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0f43000)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b0e000)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0d72800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b0e800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0d6f800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b0f000)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded5b1e800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b10800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0d7b800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b11800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0f5b000)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b13000)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded0d6c800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b13800)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1de87b0a800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b14000)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded5b2b800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  ├────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b15000)
│  │    ├──271.57 MB (04.41%) ++ zone(0x1ded5b26800)
│  │    ├───64.81 MB (01.05%) -- runtime
│  │    │   ├──63.47 MB (01.03%) -- script-sources
│  │    │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│  │    │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│  │    │   └───1.33 MB (00.02%) ++ (12 tiny)
│  │    └────0.23 MB (00.00%) ++ (2 tiny)
│  └────336.60 MB (05.46%) -- worker(pthread-main.js, 0x1de87b15800)
│       ├──271.57 MB (04.41%) ++ zone(0x1de80e27800)
│       ├───64.81 MB (01.05%) -- runtime
│       │   ├──63.47 MB (01.03%) -- script-sources
│       │   │  ├──63.47 MB (01.03%) ++ source(scripts=1, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│       │   │  └───0.00 MB (00.00%) ++ source(scripts=3, <non-notable files>)
│       │   └───1.33 MB (00.02%) ++ (12 tiny)
│       └────0.23 MB (00.00%) ++ (2 tiny)
├────551.99 MB (08.95%) -- window-objects
│    ├──279.66 MB (04.54%) ++ top(file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.html, id=4294967301)
│    └──272.34 MB (04.42%) ++ top(none)/detached/window([system])
├────157.95 MB (02.56%) -- js-non-window
│    ├──137.74 MB (02.23%) -- runtime
│    │  ├──128.48 MB (02.08%) -- script-sources
│    │  │  ├──126.94 MB (02.06%) ++ source(scripts=2, file:///C:/code/Urho3D/build_emcc_sse2_relwithdebinfo/bin/12_PhysicsStressTest.js)
│    │  │  └────1.54 MB (00.03%) ++ (26 tiny)
│    │  └────9.26 MB (00.15%) ++ (12 tiny)
│    └───20.21 MB (00.33%) ++ (2 tiny)
└─────61.00 MB (00.99%) ++ (19 tiny)

The script-sources are immutable(?), or could be treated with copy-on-write semantics(?) to share the memory. This would save up 16*64MB = 1GB of memory when running this page.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1211723
You need to log in before you can comment on or make changes to this bug.